Files
mixmaker/.cursor/rules/go-clean-architecture.mdc
2026-07-18 23:32:11 +03:00

19 lines
1.1 KiB
Plaintext

---
description: Go Clean Architecture rules for Mixmaker backend
globs: backend/**/*.go
alwaysApply: false
---
# Go Backend Architecture
- Keep dependency direction strict: `domain` has no outward dependencies; `application` depends on domain and ports; adapters depend on application contracts; `cmd/api` performs wiring.
- `backend/internal/domain` must not import HTTP routers, SQL drivers, configuration, loggers, or framework code.
- `backend/internal/application` must depend on domain types and consumer-owned ports, never concrete adapters.
- Put request and response DTOs in HTTP adapters, not in domain entities.
- Prefer explicit domain errors and small interfaces owned by their consumers.
- Keep SQL, migrations, and PostgreSQL-specific types inside output adapters.
- Make transactions explicit at the application boundary for multi-step state changes.
- Keep balancing and draft validation deterministic and free of infrastructure dependencies.
- Pass clocks, random sources, and ID generators through ports when behavior must be testable.
- Add focused unit tests whenever domain behavior or a use case changes.