CL

Clean Architecture

Used in 498 typescript projects (avg ★81)

Details

Language / Topic
typescriptTypeScript
Category
Architecture

Rules

balanced
- Separate code into layers: domain (entities, business rules), application (use cases), infrastructure (frameworks, DB, APIs).
- Dependencies point inward: infrastructure depends on application, application depends on domain. Never the reverse.
- Define ports as TypeScript interfaces in the domain layer — adapters implement these interfaces in the infrastructure layer.
- Define interfaces (ports) in the domain/application layer. Implement them in infrastructure (adapters).
- Keep domain logic framework-agnostic: no Express, no React, no Prisma imports in domain code.
- Use cases orchestrate domain logic for specific operations: one use case = one business operation.
- Wire layers together with dependency injection at the application entry point.