Clean Architecture

Clean Architecture References

This directory contains a comprehensive layer-by-layer walkthrough of Clean Architecture with TypeScript examples for both backend (Node.js/Express) and frontend (React/Redux) applications.

Quick Navigation

Reference FileTopics CoveredWhen to Read
layer-examples.mdDomain entities, Application use cases, Infrastructure adapters, Presentation controllers, folder structures, common mistakesWhen implementing any layer, wiring dependencies, or diagnosing a dependency rule violation

Reading Strategy

For implementing a new feature end-to-end

  1. Read main SKILL.md for decision criteria and Critical Patterns
  2. MUST read: layer-examples.md for the layer-by-layer breakdown and folder structure

For reviewing or debugging a dependency violation

  1. Read main SKILL.md Decision Tree
  2. CHECK: layer-examples.md Common Mistakes section for the specific anti-pattern

For setting up a new project structure

  1. Read main SKILL.md
  2. MUST read: layer-examples.md Folder Structure Examples section

File Descriptions

layer-examples.md

Complete layer-by-layer reference with TypeScript code for all four Clean Architecture rings

  • Domain layer: Order and OrderItem entities with encapsulated business rules and validation
  • Application layer: PlaceOrder and CancelOrder use cases with port interfaces (IOrderRepository, IPaymentGateway)
  • Infrastructure layer: PostgresOrderRepository and StripePaymentGateway adapter implementations
  • Presentation layer: Express OrderController with dependency wiring and route setup
  • Frontend example: React/Redux equivalent using the same four-layer structure with RTK Query
  • Folder structure templates for both backend (Node.js) and frontend (React) projects
  • Common mistakes: domain depending on infrastructure, use case knowing about HTTP, business logic in controllers

Cross-Reference Map