Clean Architecture Framework

Structure software around the Dependency Rule: source code dependencies point inward from frameworks to use cases to entities.

How to use it

  1. Hit Copy the whole skill.
  2. Claude: ⋯ → Download .md, then Customize → Skills → Add → Upload skill.
    ChatGPT: make a Project and paste it into Instructions.
    Neither? Paste it at the top of a new chat — it works for that chat.
  3. Describe your job in plain words. The AI follows the skill from there.
Claude Code — installs the whole folder, not just SKILL.md
npx degit wondelai/skills/clean-architecture#main ~/.claude/skills/clean-architecture

For one project only, change the path to .claude/skills/clean-architecture.

Not working?
  • Check which app you pasted it into — the steps above name the right one.
  • Some skills need the paid tier of Claude or ChatGPT.
Step-by-step guide with screenshots · Ask in the forum

Paste into Claude, ChatGPT or Cursor.

Show the full text197 lines
clean-architecture/SKILL.md197 lines16.0 KBpushed 83d agoRawView on GitHub

Clean Architecture Framework

A disciplined approach to structuring software so that business rules remain independent of frameworks, databases, and delivery mechanisms. Apply these principles when designing system architecture, reviewing module boundaries, or advising on dependency management.

Core Principle

Source code dependencies must point inward — toward higher-level policies. Nothing in an inner circle can know anything about an outer circle. This single rule produces systems that are testable and independent of frameworks, UI, database, and any external agency. Business rules are what matter; databases, web frameworks, and delivery mechanisms are details — when details depend on policies, you can defer decisions, swap implementations, and test business logic in isolation.

Scoring

Goal: 10/10. Score one point for each of the seven Quick Diagnostic rows the architecture satisfies (0-7), then map to a 0-10 band: 6-7 satisfied = 9-10 (Dependency Rule holds, business logic is framework- and DB-independent); 4-5 = 6-8 (core is testable but some details leak inward); 2-3 = 3-5 (framework or persistence dictates structure); 0-1 = 0-2 (no boundaries — business rules live in controllers and ORM models). Report the score, the failed diagnostic rows, and the specific inversion needed to fix each.

1. Dependency Rule and Concentric Circles

Core concept: Organize the architecture as concentric circles — Entities (enterprise business rules) innermost, then Use Cases (application business rules), then Interface Adapters, with Frameworks and Drivers outermost. Source code dependencies always point inward.

Why it works: When high-level policies don't depend on low-level details, you can swap the database, web framework, or API style without touching business logic — the system becomes resilient to the most volatile parts of the stack.

Key insights:

  • Inner circles cannot mention outer circle names — no classes, functions, variables, or data formats from outside
  • Data crossing a boundary must be in the form most convenient for the inner circle, never dictated by the outer
  • Dependency Inversion (interfaces defined inward, implemented outward) is the mechanism that enforces the rule
  • The number of circles is not fixed — four is typical; the rule stays the same
  • Frameworks are details, not architecture — they belong in the outermost circle

Code applications:

Context Pattern Example
Layer direction Inner circles define interfaces; outer implement UserRepository interface in Use Cases; PostgresUserRepository in Adapters
Data crossing DTOs cross boundaries, not ORM entities Use Case returns UserResponse DTO, not an ActiveRecord model
Dependency direction Import arrows always point inward Controller imports Use Case; Use Case never imports Controller

See references/dependency-rule.md when an inner-circle import points outward and you need the four-circle code walkthrough, the data-crossing rules, and the four-step dependency-inversion procedure to fix it.

2. Entities and Use Cases

Core concept: Entities encapsulate enterprise-wide business rules — rules that would exist even without software. Use Cases contain application-specific rules that orchestrate the flow of data to and from Entities.

Why it works: Separating what the business does (Entities) from how the application orchestrates it (Use Cases) lets you reuse Entities across applications and change application behavior without altering core business rules.

Key insights:

  • Entities are not database rows — they are objects or pure functions encapsulating critical business rules
  • Use Cases accept Request Models and return Response Models — never framework objects
  • Each Use Case is a single application operation (CreateOrder, ApproveExpense)
  • The Interactor pattern: a Use Case class implements an input boundary interface and calls an output boundary interface
  • Changes to a Use Case should never affect an Entity; Entity changes may ripple to Use Cases

Code applications:

Context Pattern Example
Entity design Critical business rules, zero framework dependencies Order.calculateTotal() applies tax rules; knows nothing about HTTP
Request/Response Simple data structures cross the boundary CreateOrderRequest { items, customerId } — no ORM models
Single responsibility One Use Case per operation PlaceOrder, CancelOrder, RefundOrder as separate classes
Interactor Implements Input Port, calls Output Port PlaceOrderInteractor implements PlaceOrderInput

See references/entities-use-cases.md when designing an Interactor or deciding what belongs in an Entity versus a Use Case — full Enterprise vs. Application Business Rules treatment with request/response model examples.

3. Interface Adapters and Frameworks

Core concept: Interface Adapters convert data between the form convenient for Use Cases/Entities and the form required by external agencies. Frameworks and Drivers are the outermost layer — glue code to the outside world.

Why it works: When the web framework, ORM, or message queue is confined to the outer circles, replacing any of them is a localized change. The database is a detail; the web is a detail; details should be plugins to your business rules, not the skeleton of the application.

Key insights:

  • Controllers translate HTTP into Use Case input; Presenters translate Use Case output into view models
  • Gateways implement repository interfaces defined by Use Cases — the inner circle defines the contract, the outer fulfills it
  • Business rules never know whether data lives in SQL, NoSQL, or flat files, or that delivery is HTTP
  • Treat frameworks with suspicion — they want you to couple to them; keep them at arm's length

Code applications:

Context Pattern Example
Controller Delivery mechanism → Use Case input OrderController.create(req) builds CreateOrderRequest, calls Interactor
Presenter Use Case output → view model OrderPresenter.present(response) formats for JSON/HTML
Gateway Repository interface implemented per DB SqlOrderRepository implements OrderRepository
Framework boundary Framework calls inward, never the reverse Express route handler calls Controller; Controller never imports Express

See references/adapters-frameworks.md when wiring controllers, presenters, or gateways, or arguing that the database/web is a detail — covers plugin architecture and how to confine a framework to the edges.

4. Component Principles

Core concept: Components are the units of deployment. Three cohesion principles govern what goes inside a component; three coupling principles govern relationships between components.

Why it works: Poorly composed components create ripple effects where one change forces redeployment of unrelated code; the principles keep changes localized and releases independent.

Key insights:

  • REP (Reuse/Release Equivalence): classes in a component must be versionable and releasable as a unit
  • CCP (Common Closure): classes that change for the same reason at the same time belong together — SRP for components
  • CRP (Common Reuse): don't force users to depend on classes they don't use
  • ADP (Acyclic Dependencies): the component graph must have no cycles — break them with DIP or a new component
  • SDP (Stable Dependencies): depend in the direction of stability
  • SAP (Stable Abstractions): stable components should be abstract; unstable ones concrete

Code applications:

Context Pattern Example
Component grouping Group classes that change together (CCP) All order-related Use Cases in one component
Breaking cycles Apply DIP to invert a dependency edge Extract an interface into a new component to break the cycle
Stability metrics Instability I = Ce / (Ca + Ce) Many incoming, no outgoing deps → I near 0 (stable)

See references/component-principles.md when grouping classes into deployable components or breaking a dependency cycle — each of REP, CCP, CRP, ADP, SDP, SAP worked through with the instability metric.

5. SOLID Principles

Core concept: Five class-and-module-level principles — Single Responsibility, Open-Closed, Liskov Substitution, Interface Segregation, Dependency Inversion — the mid-level building blocks that make the Dependency Rule possible.

Why it works: Each principle addresses a specific way dependencies go wrong, preventing the rigidity, fragility, and immobility that turn codebases into legacy nightmares.

Key insights:

  • SRP: a module has one reason to change — it serves one actor (not "does one thing")
  • OCP: extend behavior by adding new code, not modifying existing code — strategy and plugin patterns
  • LSP: subtypes must be usable through the base interface without the client knowing — violated by unexpected exceptions or ignored methods
  • ISP: clients should not depend on methods they don't use — fat interfaces create needless coupling
  • DIP: high-level modules and low-level modules both depend on abstractions defined by the high-level module

Code applications:

Context Pattern Example
SRP violation Class serves multiple actors Employee handles pay (CFO), reporting (COO), persistence (CTO)
OCP via strategy New behavior through new classes Add ExpressShipping implementing ShippingStrategy; Order untouched
LSP violation Subtype changes expected behavior Square extends Rectangle breaks the setWidth()/setHeight() contract
ISP application Split fat interfaces into role interfaces Printer, Scanner, Fax instead of one MultiFunctionDevice
DIP wiring High-level defines interface; low-level implements OrderService depends on PaymentGateway, not StripeClient

See references/solid-principles.md when applying SRP/OCP/LSP/ISP/DIP to a specific class or diagnosing a violation — each principle worked through with code examples and the smell it prevents.

6. Boundaries and Boundary Anatomy

Core concept: A boundary is a line between things that matter and things that are details, implemented through polymorphism: dependencies cross pointing inward while control flow may cross either way.

Why it works: Every boundary buys the option to defer a decision or swap an implementation; strategic boundary placement determines whether a system is a joy or a pain to maintain over years.

Key insights:

  • Full boundaries use reciprocal interfaces on both sides; partial boundaries use a simpler strategy or facade
  • Humble Object pattern: split boundary code into a hard-to-test part (close to the boundary) and an easy-to-test part (the logic)
  • Services are not automatically architectural boundaries — a microservice with a fat shared data model is a monolith with network calls
  • Tests are the most isolated component: they depend inward, nothing depends on them
  • Premature boundaries are expensive, but so are missing ones — draw them at points of likely volatility

Code applications:

Context Pattern Example
Full vs. partial boundary Reciprocal ports, or a lone strategy Use Case defines PlaceOrderInput/PlaceOrderOutput; simpler cases take a ShippingStrategy
Humble Object Separate testable logic from infrastructure PresenterLogic (testable) produces ViewModel; View (humble) renders it
Main as plugin Composition root assembles the system main() wires all concrete implementations and starts the app

See references/boundaries.md when deciding where to draw a boundary, choosing full vs. partial, or applying the Humble Object pattern — also covers services as boundaries, test boundaries, and Main as the ultimate plugin.

Common Mistakes

Mistake Why It Fails Fix
ORM leaking into business logic Entities couple to the schema; DB changes rewrite business rules Separate domain entities from persistence models; map at the adapter layer
Business rules in controllers Untestable without HTTP; duplicated across endpoints Move logic into Use Case Interactors; controllers only translate and delegate
Framework-first architecture Framework dictates structure; swapping means a rewrite Treat the framework as a plugin; structure code by business capability
Circular component dependencies Changes ripple unpredictably; no independent releases Apply DIP or extract a shared abstraction component
One giant Use Case per feature Bloated thousand-line orchestrators Split into focused single-operation Use Cases
Skipping boundaries "because it's simple" Coupling accumulates silently until the cost is enormous Draw boundaries proactively at points of likely volatility
Microservices as automatic good architecture A distributed monolith is worse than a clean monolith Apply the Dependency Rule within and across services; services are deployment boundaries, not architectural ones

Quick Diagnostic

Question If No Action
Can you test business rules without DB, web server, or framework? Rules coupled to infrastructure Extract entities and use cases behind interfaces; mock outer layers
Do all source dependencies point inward? Dependency Rule violated Introduce boundary interfaces; invert the offending dependency
Can you swap the database without touching business logic? Persistence leaking inward Repository pattern; isolate persistence in adapters
Are Use Cases independent of delivery mechanism? Use Cases know HTTP/CLI/queues Use plain DTOs in Use Case signatures
Is the framework confined to the outermost circle? Framework is your architecture Wrap framework calls behind interfaces; push to the edges
Is the component graph cycle-free? Circular dependencies exist Apply ADP: DIP or new components to break every cycle
Does Main (composition root) wire all dependencies? Concrete classes instantiated in inner circles Move construction to Main; use DI or factories

Further Reading

Based on Robert C. Martin's definitive guide to software architecture:

About the Author

Robert C. Martin ("Uncle Bob") is a software engineer programming since 1970, a founding signatory of the Agile Manifesto, and the author of Clean Code, The Clean Coder, Clean Architecture, and Clean Agile. His SOLID principles are foundational vocabulary in object-oriented design, and his work argues that architecture is about managing dependencies and keeping business rules independent of infrastructure details.

1---
2name: clean-architecture
3description: 'Structure software around the Dependency Rule: source code dependencies point inward from frameworks to use cases to entities. Use when the user mentions "architecture layers", "dependency rule", "ports and adapters (hexagonal)", "onion architecture", "screaming architecture", "where should business logic go", "decouple from the database", "swap the framework without a rewrite", or "keep business rules independent". Also trigger when deciding which layer code belongs in, isolating core logic from infrastructure, defining module boundaries, or debating whether the framework should call your code or the reverse. Covers component principles, boundaries, and SOLID. For code-level quality, see clean-code. For domain modeling, see domain-driven-design.'
4license: MIT
5metadata:
6 author: wondelai
7 version: "1.4.0"
8---
9 
10# Clean Architecture Framework
11 
12A disciplined approach to structuring software so that business rules remain independent of frameworks, databases, and delivery mechanisms. Apply these principles when designing system architecture, reviewing module boundaries, or advising on dependency management.
13 
14## Core Principle
15 
16**Source code dependencies must point inward — toward higher-level policies.** Nothing in an inner circle can know anything about an outer circle. This single rule produces systems that are testable and independent of frameworks, UI, database, and any external agency. Business rules are what matter; databases, web frameworks, and delivery mechanisms are details — when details depend on policies, you can defer decisions, swap implementations, and test business logic in isolation.
17 
18## Scoring
19 
20**Goal: 10/10.** Score one point for each of the seven Quick Diagnostic rows the architecture satisfies (0-7), then map to a 0-10 band: 6-7 satisfied = **9-10** (Dependency Rule holds, business logic is framework- and DB-independent); 4-5 = **6-8** (core is testable but some details leak inward); 2-3 = **3-5** (framework or persistence dictates structure); 0-1 = **0-2** (no boundaries — business rules live in controllers and ORM models). Report the score, the failed diagnostic rows, and the specific inversion needed to fix each.
21 
22### 1. Dependency Rule and Concentric Circles
23 
24**Core concept:** Organize the architecture as concentric circles — Entities (enterprise business rules) innermost, then Use Cases (application business rules), then Interface Adapters, with Frameworks and Drivers outermost. Source code dependencies always point inward.
25 
26**Why it works:** When high-level policies don't depend on low-level details, you can swap the database, web framework, or API style without touching business logic — the system becomes resilient to the most volatile parts of the stack.
27 
28**Key insights:**
29- Inner circles cannot mention outer circle names — no classes, functions, variables, or data formats from outside
30- Data crossing a boundary must be in the form most convenient for the inner circle, never dictated by the outer
31- Dependency Inversion (interfaces defined inward, implemented outward) is the mechanism that enforces the rule
32- The number of circles is not fixed — four is typical; the rule stays the same
33- Frameworks are details, not architecture — they belong in the outermost circle
34 
35**Code applications:**
36 
37| Context | Pattern | Example |
38|---------|---------|---------|
39| **Layer direction** | Inner circles define interfaces; outer implement | `UserRepository` interface in Use Cases; `PostgresUserRepository` in Adapters |
40| **Data crossing** | DTOs cross boundaries, not ORM entities | Use Case returns `UserResponse` DTO, not an ActiveRecord model |
41| **Dependency direction** | Import arrows always point inward | Controller imports Use Case; Use Case never imports Controller |
42 
43See [references/dependency-rule.md](references/dependency-rule.md) when an inner-circle import points outward and you need the four-circle code walkthrough, the data-crossing rules, and the four-step dependency-inversion procedure to fix it.
44 
45### 2. Entities and Use Cases
46 
47**Core concept:** Entities encapsulate enterprise-wide business rules — rules that would exist even without software. Use Cases contain application-specific rules that orchestrate the flow of data to and from Entities.
48 
49**Why it works:** Separating what the business does (Entities) from how the application orchestrates it (Use Cases) lets you reuse Entities across applications and change application behavior without altering core business rules.
50 
51**Key insights:**
52- Entities are not database rows — they are objects or pure functions encapsulating critical business rules
53- Use Cases accept Request Models and return Response Models — never framework objects
54- Each Use Case is a single application operation (`CreateOrder`, `ApproveExpense`)
55- The Interactor pattern: a Use Case class implements an input boundary interface and calls an output boundary interface
56- Changes to a Use Case should never affect an Entity; Entity changes may ripple to Use Cases
57 
58**Code applications:**
59 
60| Context | Pattern | Example |
61|---------|---------|---------|
62| **Entity design** | Critical business rules, zero framework dependencies | `Order.calculateTotal()` applies tax rules; knows nothing about HTTP |
63| **Request/Response** | Simple data structures cross the boundary | `CreateOrderRequest { items, customerId }` — no ORM models |
64| **Single responsibility** | One Use Case per operation | `PlaceOrder`, `CancelOrder`, `RefundOrder` as separate classes |
65| **Interactor** | Implements Input Port, calls Output Port | `PlaceOrderInteractor implements PlaceOrderInput` |
66 
67See [references/entities-use-cases.md](references/entities-use-cases.md) when designing an Interactor or deciding what belongs in an Entity versus a Use Case — full Enterprise vs. Application Business Rules treatment with request/response model examples.
68 
69### 3. Interface Adapters and Frameworks
70 
71**Core concept:** Interface Adapters convert data between the form convenient for Use Cases/Entities and the form required by external agencies. Frameworks and Drivers are the outermost layer — glue code to the outside world.
72 
73**Why it works:** When the web framework, ORM, or message queue is confined to the outer circles, replacing any of them is a localized change. The database is a detail; the web is a detail; details should be plugins to your business rules, not the skeleton of the application.
74 
75**Key insights:**
76- Controllers translate HTTP into Use Case input; Presenters translate Use Case output into view models
77- Gateways implement repository interfaces defined by Use Cases — the inner circle defines the contract, the outer fulfills it
78- Business rules never know whether data lives in SQL, NoSQL, or flat files, or that delivery is HTTP
79- Treat frameworks with suspicion — they want you to couple to them; keep them at arm's length
80 
81**Code applications:**
82 
83| Context | Pattern | Example |
84|---------|---------|---------|
85| **Controller** | Delivery mechanism → Use Case input | `OrderController.create(req)` builds `CreateOrderRequest`, calls Interactor |
86| **Presenter** | Use Case output → view model | `OrderPresenter.present(response)` formats for JSON/HTML |
87| **Gateway** | Repository interface implemented per DB | `SqlOrderRepository implements OrderRepository` |
88| **Framework boundary** | Framework calls inward, never the reverse | Express route handler calls Controller; Controller never imports Express |
89 
90See [references/adapters-frameworks.md](references/adapters-frameworks.md) when wiring controllers, presenters, or gateways, or arguing that the database/web is a detail — covers plugin architecture and how to confine a framework to the edges.
91 
92### 4. Component Principles
93 
94**Core concept:** Components are the units of deployment. Three cohesion principles govern what goes inside a component; three coupling principles govern relationships between components.
95 
96**Why it works:** Poorly composed components create ripple effects where one change forces redeployment of unrelated code; the principles keep changes localized and releases independent.
97 
98**Key insights:**
99- REP (Reuse/Release Equivalence): classes in a component must be versionable and releasable as a unit
100- CCP (Common Closure): classes that change for the same reason at the same time belong together — SRP for components
101- CRP (Common Reuse): don't force users to depend on classes they don't use
102- ADP (Acyclic Dependencies): the component graph must have no cycles — break them with DIP or a new component
103- SDP (Stable Dependencies): depend in the direction of stability
104- SAP (Stable Abstractions): stable components should be abstract; unstable ones concrete
105 
106**Code applications:**
107 
108| Context | Pattern | Example |
109|---------|---------|---------|
110| **Component grouping** | Group classes that change together (CCP) | All order-related Use Cases in one component |
111| **Breaking cycles** | Apply DIP to invert a dependency edge | Extract an interface into a new component to break the cycle |
112| **Stability metrics** | Instability I = Ce / (Ca + Ce) | Many incoming, no outgoing deps → I near 0 (stable) |
113 
114See [references/component-principles.md](references/component-principles.md) when grouping classes into deployable components or breaking a dependency cycle — each of REP, CCP, CRP, ADP, SDP, SAP worked through with the instability metric.
115 
116### 5. SOLID Principles
117 
118**Core concept:** Five class-and-module-level principles — Single Responsibility, Open-Closed, Liskov Substitution, Interface Segregation, Dependency Inversion — the mid-level building blocks that make the Dependency Rule possible.
119 
120**Why it works:** Each principle addresses a specific way dependencies go wrong, preventing the rigidity, fragility, and immobility that turn codebases into legacy nightmares.
121 
122**Key insights:**
123- SRP: a module has one reason to change — it serves one actor (not "does one thing")
124- OCP: extend behavior by adding new code, not modifying existing code — strategy and plugin patterns
125- LSP: subtypes must be usable through the base interface without the client knowing — violated by unexpected exceptions or ignored methods
126- ISP: clients should not depend on methods they don't use — fat interfaces create needless coupling
127- DIP: high-level modules and low-level modules both depend on abstractions defined by the high-level module
128 
129**Code applications:**
130 
131| Context | Pattern | Example |
132|---------|---------|---------|
133| **SRP violation** | Class serves multiple actors | `Employee` handles pay (CFO), reporting (COO), persistence (CTO) |
134| **OCP via strategy** | New behavior through new classes | Add `ExpressShipping` implementing `ShippingStrategy`; `Order` untouched |
135| **LSP violation** | Subtype changes expected behavior | `Square extends Rectangle` breaks the `setWidth()`/`setHeight()` contract |
136| **ISP application** | Split fat interfaces into role interfaces | `Printer`, `Scanner`, `Fax` instead of one `MultiFunctionDevice` |
137| **DIP wiring** | High-level defines interface; low-level implements | `OrderService` depends on `PaymentGateway`, not `StripeClient` |
138 
139See [references/solid-principles.md](references/solid-principles.md) when applying SRP/OCP/LSP/ISP/DIP to a specific class or diagnosing a violation — each principle worked through with code examples and the smell it prevents.
140 
141### 6. Boundaries and Boundary Anatomy
142 
143**Core concept:** A boundary is a line between things that matter and things that are details, implemented through polymorphism: dependencies cross pointing inward while control flow may cross either way.
144 
145**Why it works:** Every boundary buys the option to defer a decision or swap an implementation; strategic boundary placement determines whether a system is a joy or a pain to maintain over years.
146 
147**Key insights:**
148- Full boundaries use reciprocal interfaces on both sides; partial boundaries use a simpler strategy or facade
149- Humble Object pattern: split boundary code into a hard-to-test part (close to the boundary) and an easy-to-test part (the logic)
150- Services are not automatically architectural boundaries — a microservice with a fat shared data model is a monolith with network calls
151- Tests are the most isolated component: they depend inward, nothing depends on them
152- Premature boundaries are expensive, but so are missing ones — draw them at points of likely volatility
153 
154**Code applications:**
155 
156| Context | Pattern | Example |
157|---------|---------|---------|
158| **Full vs. partial boundary** | Reciprocal ports, or a lone strategy | Use Case defines `PlaceOrderInput`/`PlaceOrderOutput`; simpler cases take a `ShippingStrategy` |
159| **Humble Object** | Separate testable logic from infrastructure | `PresenterLogic` (testable) produces `ViewModel`; `View` (humble) renders it |
160| **Main as plugin** | Composition root assembles the system | `main()` wires all concrete implementations and starts the app |
161 
162See [references/boundaries.md](references/boundaries.md) when deciding where to draw a boundary, choosing full vs. partial, or applying the Humble Object pattern — also covers services as boundaries, test boundaries, and Main as the ultimate plugin.
163 
164## Common Mistakes
165 
166| Mistake | Why It Fails | Fix |
167|---------|-------------|-----|
168| **ORM leaking into business logic** | Entities couple to the schema; DB changes rewrite business rules | Separate domain entities from persistence models; map at the adapter layer |
169| **Business rules in controllers** | Untestable without HTTP; duplicated across endpoints | Move logic into Use Case Interactors; controllers only translate and delegate |
170| **Framework-first architecture** | Framework dictates structure; swapping means a rewrite | Treat the framework as a plugin; structure code by business capability |
171| **Circular component dependencies** | Changes ripple unpredictably; no independent releases | Apply DIP or extract a shared abstraction component |
172| **One giant Use Case per feature** | Bloated thousand-line orchestrators | Split into focused single-operation Use Cases |
173| **Skipping boundaries "because it's simple"** | Coupling accumulates silently until the cost is enormous | Draw boundaries proactively at points of likely volatility |
174| **Microservices as automatic good architecture** | A distributed monolith is worse than a clean monolith | Apply the Dependency Rule within and across services; services are deployment boundaries, not architectural ones |
175 
176## Quick Diagnostic
177 
178| Question | If No | Action |
179|----------|-------|--------|
180| Can you test business rules without DB, web server, or framework? | Rules coupled to infrastructure | Extract entities and use cases behind interfaces; mock outer layers |
181| Do all source dependencies point inward? | Dependency Rule violated | Introduce boundary interfaces; invert the offending dependency |
182| Can you swap the database without touching business logic? | Persistence leaking inward | Repository pattern; isolate persistence in adapters |
183| Are Use Cases independent of delivery mechanism? | Use Cases know HTTP/CLI/queues | Use plain DTOs in Use Case signatures |
184| Is the framework confined to the outermost circle? | Framework is your architecture | Wrap framework calls behind interfaces; push to the edges |
185| Is the component graph cycle-free? | Circular dependencies exist | Apply ADP: DIP or new components to break every cycle |
186| Does Main (composition root) wire all dependencies? | Concrete classes instantiated in inner circles | Move construction to Main; use DI or factories |
187 
188## Further Reading
189 
190Based on Robert C. Martin's definitive guide to software architecture:
191 
192- [*"Clean Architecture: A Craftsman's Guide to Software Structure and Design"*](https://www.amazon.com/Clean-Architecture-Craftsmans-Software-Structure/dp/0134494164?tag=wondelai00-20) by Robert C. Martin
193 
194## About the Author
195 
196**Robert C. Martin ("Uncle Bob")** is a software engineer programming since 1970, a founding signatory of the Agile Manifesto, and the author of *Clean Code*, *The Clean Coder*, *Clean Architecture*, and *Clean Agile*. His SOLID principles are foundational vocabulary in object-oriented design, and his work argues that architecture is about managing dependencies and keeping business rules independent of infrastructure details.
197 

Discussion

Alternatives

Also in Architecture
A Philosophy of Software Design FrameworkManage software complexity through deep modules, information hiding, and strategic programming. Use when the user mentions "module design", "API too complex", "shallow class", "complexity budget", "strategic vs tactical", "deep module", "information leakage", "pass-through method", "this code is over-engineered", or "simplify this design". Also trigger when reviewing an interface for simplicity, evaluating whether an abstraction is pulling its weight, deciding whether a comment is worth writing, or choosing between general-purpose and special-purpose approaches. Covers deep vs shallow modules, red flags for complexity, and comments as design documentation. For code quality, see clean-code. For architecture boundaries, see clean-architecture.Coding · MITArchitecture optimizationGuided journey from a working codebase grown slow and tangled to one measurably fast, cleanly bounded, and readable. Orchestrates eight skills phase by phase - working-with-legacy-code, clean-architecture, software-design-philosophy, refactoring-patterns, system-design, ddia-systems, release-it, pragmatic-programmer - every phase carries its method inline so it runs standalone, asking the user questions at every decision point and recording results in the project docs/ folder (PERFORMANCE.md, ARCHITECTURE.md, ARCHITECTURE-OPTIMIZATION-PLAN.md) so the journey resumes across sessions. Use when the user wants to make an app faster, untangle drifted boundaries, fix slow endpoints and queries, or says ''it works but it is slow and getting worse''. For an untested prototype, improve-code-quality; for an aged codebase you fear to touch, remove-technical-debt; for greenfield structure, design-code-architecture; for marketing-site page speed, improve-website. For one framework in isolation, invoke that skill directly.Coding · MITArchitecture & UI/UX AuditIt asks an AI to assume the persona of a Senior Frontend Engineer & Product Reviewer to perform a high-level critique of a Next.js (App Router) project. Instead of writing code, the prompt focuses on evaluating the architecture (folder structure, scalability), UI/UX (hierarchy, consistency), and design system (component reuse) of a developer community platform to identify anti-patterns and suggest high-impact improvements.Coding · CC0-1.0Candle pattern trading chart generatorGenerate a chart showing buy below and sell above candle patterns to indicate optimal trading points.Coding · CC0-1.0