Design and implement production-grade backend systems with the right architecture pattern. Use this skill when: building a new backend service or API, scaffolding NestJS modules/controllers/services, choosing between architecture patterns (Clean Architecture, Modular Monolith, Hexagonal, Standard MVC), designing REST/GraphQL/WebSocket APIs, setting up error handling/validation/logging, or structuring database and caching layers. Also use when user says 'create module', 'add endpoint', 'design API', 'backend structure', or asks about backend best practices. Includes architecture selection questionnaire. Primarily targets NestJS + TypeScript + Prisma but principles apply broadly.
Design production-grade backend systems by selecting the right architecture, then implementing with best practices.
Ask user (or infer from project context):
| Question | Options |
|---|---|
| Team size | Solo / 2-5 / 6-15 / 15+ |
| Lifespan | Prototype / 1-2yr / 3+yr |
| Domain complexity | Simple CRUD / Moderate / Complex rules |
| Scaling plan | Single service / May split / Microservices |
| Experience level | Junior / Mixed / Senior |
| Time to market | ASAP / Balanced / Quality-first |
| Context | Pattern |
|---|---|
| Solo, prototype, CRUD, ASAP | NestJS Standard |
| Small team, moderate, may split later | Modular Monolith (default) |
| Senior, complex domain, long-term | Clean Architecture |
| Many integrations, testability critical | Hexagonal |
Default if skipped: Modular Monolith.
For detailed folder structures, rules, and implementation examples for each pattern, consult references/architecture-patterns.md.
| Style | When to use |
|---|---|
| REST | Default for all CRUD + resource APIs |
| GraphQL | Complex queries with deep relations |
| WebSocket | Real-time: notifications, live scoring, chat |
REST conventions: plural nouns, kebab-case, /api/v1/ prefix, consistent envelope { data, meta, error }.
For complete API design patterns (pagination, filtering, error codes, GraphQL schema design, WebSocket gateway setup), consult references/api-design.md.
PassageNotFoundError){ error: { code, message } }, log with correlation ID, never leak stack tracesclass-validator decoratorsValidationPipe({ whitelist: true, transform: true, forbidNonWhitelisted: true })$transaction() for multi-step writesdeletedAt + middleware@@index on frequently queried fields{module}:{entity}:{id}@Roles() decorator + RolesGuard + resource ownership check[ModuleName] context + requestId correlation*.spec.ts co-located, 80%+ service coverageTestingModule, seed/clean per test, 70%+ controller coverageFor expanded patterns, examples, and checklists, consult references/api-design.md.