CL

Clean Architecture

Used in 498 javascript projects (avg ★81)

Details

Language / Topic
javascriptJavaScript
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.
- Domain logic lives in plain JavaScript/TypeScript functions with no framework imports — React, Express, or DB libraries stay in the outer layers.
- 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.