Clean Architecture

Use when: structure an app so business logic is independent of frameworks, UI, and databases.

kimtth 268d4b8 1.0 KB Updated

File contents

Goal: a core domain that does not depend on delivery or infrastructure.

Use for:

  • keeping business rules testable and framework-agnostic
  • isolating database and UI choices from core logic
  • structuring layers and their dependencies

Workflow:

  1. Put business rules in a core that imports nothing external.
  2. Define ports (interfaces) the core needs.
  3. Implement adapters for db, UI, and services at the edges.
  4. Point all dependencies inward, toward the core.
  5. Pass data across boundaries as plain structures.
  6. Test the core without frameworks or a database.

Layers:

  • entities and use cases at the center
  • interface adapters (controllers, presenters, gateways)
  • frameworks and drivers at the outer edge

Rules:

  • dependencies point inward only; core knows no framework
  • depend on interfaces, inject implementations
  • keep framework code out of use cases
  • the domain must be testable in isolation

kimtth/agent-skill-100-lines-or-less/tree/main/skills/clean-architecture commit 268d4b85eb

Frequently asked questions

npx skillmds@latest add kimtth/clean-architecture