← ClaudeAtlas

ddd-fastapilisted

Write Domain-Driven Design code in FastAPI / Python — bounded contexts as packages with four layers, aggregates as plain classes with behavior, value objects as frozen dataclasses, application services, repository ports with async SQLAlchemy adapters and Alembic migrations, domain events, anti-corruption layers, and the REST interface with Pydantic schemas. Use when implementing or refactoring a FastAPI service around business rules, structuring a new bounded context in Python, or pulling business logic out of route handlers into a domain model. It carries the DDD design rules it depends on, so it works on its own. Not for FastAPI configuration, deployment, or framework questions unrelated to domain modeling.
salimramirez/agent-skills · ★ 4 · API & Backend · score 75
Install: claude install-skill salimramirez/agent-skills
# DDD in FastAPI Write the actual code for a Domain-Driven Design model in **FastAPI / Python**. The core rules below say *what* the building blocks are and when to reach for each; the references say *how to express them idiomatically* in FastAPI, and the assets and scripts write the parts that should come out the same every time. This is an **opinionated** house style: for every decision it names one convention and says what that convention buys, rather than listing options. It is one coherent way to do this, not the only correct one; where a choice is genuinely open, the reference says so. Python leaves more to taste than Java does, and the house style respects that: it fixes the decisions that make every bounded context look alike — where a file goes, what it is called, which layer may import which — and leaves the rest to the code in front of it. Examples use the **QuickBite** food-delivery domain — an `Order` in the `ordering` bounded context, a `Customer` in `customers`. The idioms are FastAPI with `async` routes, Pydantic v2 for the request and response schemas and the settings, SQLAlchemy 2 with its asyncio extension over PostgreSQL (`asyncpg`), Alembic for the schema, and plain Python — classes and frozen dataclasses — for the domain. The shipped code targets **Python 3.12+** and was run on 3.12 and 3.13, from the lowest versions `pyproject.toml` allows (FastAPI 0.122, SQLAlchemy 2.0.0, Alembic 1.16) to the current ones. The one floor that is behavior and not just