--- 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.