A clean slice end to end

You have seen every layer in isolation. Time to walk the full slice from HTTP to domain to database. This is the refactor the DDD workshop module is asking you to do.

after/
text
after/
├── controllers/
│   └── order.controller.ts       # thin HTTP handlers
├── use-cases/
│   └── order/
│       ├── place-order.ts        # orchestration
│       └── get-order.ts          # orchestration
├── domain/
│   ├── order/
│   │   ├── order.types.ts        # schemas and entity types
│   │   ├── order.entity.ts       # pure functions
│   │   └── order.repository.ts   # DB queries for orders
│   └── book/
│       └── book.repository.ts    # DB queries for books
├── db/
│   └── schema.ts                 # Drizzle tables
└── index.ts                      # wiring

The file layout for a clean vertical slice of the order workflow.

Each domain folder contains everything related to that concept. Types live with their entity and repository. Use cases import from domain. Controllers import from use cases. Nothing in domain imports from controllers or use cases. That one rule is the whole architecture.

AI prompt: Try it: refactor a fat service with Claude

Loading practice…

Validation checklist: Refactor the order slice in the workshop

Loading practice…

Checkpoint: DDD and functional architecture checkpoint

Loading practice…