Fastapi Agent Blueprint
AI Agent Backend Platform on FastAPI β MCP server + AI orchestration + async DDD architecture. Zero-boilerplate CRUD, auto domain discovery, 14 Claude Code AI development skills.
Ask AI about Fastapi Agent Blueprint
Powered by Claude Β· Grounded in docs
I know everything about Fastapi Agent Blueprint. Ask me about installation, configuration, usage, or troubleshooting.
0/500
Reviews
Documentation
FastAPI Agent Blueprint
Production FastAPI architecture, with AI-assisted domain scaffolding built in.
DDD layers Β· zero-boilerplate CRUD Β· 4 interfaces. Claude Code and Codex CLI can scaffold new domains through the same production workflow.
60s Quickstart Β· Why Β· Comparison Β· Architecture Β· νκ΅μ΄
Try it in 60 seconds
No Docker, no PostgreSQL, no cloud credentials β SQLite + in-memory broker.
git clone https://github.com/Mr-DooSun/fastapi-agent-blueprint.git
cd fastapi-agent-blueprint
make setup # one-time: venv + deps via uv
make quickstart # FastAPI on :8001, SQLite schema auto-created
In a second terminal, make demo exercises the auth + user domains
(JWT register β CRUD β refresh β logout) and make demo-rag exercises the
docs domain (end-to-end RAG: upload β chunk β embed β retrieve β answer
with citations, zero credentials):
β Health check
{ "status": "ok" }
β Register
{ "success": true, "data": { "accessToken": "...", "refreshToken": "..." } }
β Create a user
{ "success": true, "data": { "id": 2, "username": "bob", ... } }
β List users (page=1, pageSize=10)
{ "data": [ { "id": 1, "username": "alice" }, { "id": 2, "username": "bob" } ],
"pagination": { "currentPage": 1, "totalItems": 2, "hasNext": false } }
β Update the user β Delete the user
β Refresh token β Logout
β Done. API docs: http://127.0.0.1:8001/docs
- API docs: http://127.0.0.1:8001/docs (Stoplight Elements & Scalar recommended; spec download + frontend handoff link on the same page)
- Admin UI: http://127.0.0.1:8001/admin (
admin/admin) - Full walkthrough:
docs/quickstart.md - Frontend handoff:
docs/frontend-handoff.md - Real dev stack (PostgreSQL + migrations):
docs/reference.md
Platform in action
Clone β quickstart β CRUD β JWT auth β background worker β RAG query:
make quickstart && make demo && make demo-rag

Full integration walkthrough (auth Β· RBAC Β· worker Β· admin Β· RAG Β· OTEL): docs/canonical-demo.md
Why this blueprint
|
Production rigor
|
AI-assisted acceleration
|
How it compares
| Feature | FastAPI Agent Blueprint | tiangolo/full-stack | s3rius/template | teamhide/boilerplate |
|---|---|---|---|---|
| Zero-boilerplate CRUD (8 methods) | Yes | No | No | No |
| Auto domain discovery | Yes | No | No | No |
| Architecture enforcement (pre-commit) | Yes | No | No | No |
| AI workflow skills (Claude + Codex) | 14 + 14 | 0 | 0 | 0 |
| Vector infrastructure (S3 Vectors) | Yes | No | No | No |
| Multi-interface (API + Worker + Admin + MCP) | 3 + 1 planned | 2 | 1 | 1 |
| Architecture Decision Records | 18 active Β· 30 archived | 0 | 0 | 0 |
| Type-safe generics across layers | Yes | Partial | Partial | No |
| IoC container DI | Yes | No | No | No |
Full comparison including Litestar, Robyn, cookiecutter, and adoption paths: docs/comparison.md
AI use case: document QA (src/docs/)
The blueprint ships a worked RAG example β upload documents, ask questions, get structured answers with citations. It proves the building blocks (vectors, embeddings, LLM agent, worker, admin) compose end-to-end.
make quickstart # terminal 1
make demo-rag # terminal 2 β seeds 3 docs, runs a query
POST /v1/docs/documents # chunk β embed β upsert
POST /v1/docs/query # embed question β top-k retrieval β agent answer
GET /admin/docs # browse + query playground
Under the hood, the RAG orchestration is a reusable _core pattern
(ADR 040), not a domain.
src/docs/ is one consumer; future AI domains (support_bot, product_qa)
inject the same RagPipeline instead of duplicating chunking + retrieval
code:
# src/_core/domain/services/rag_pipeline.py
class RagPipeline(Generic[TChunk]):
async def answer(self, question, top_k=5, filters=None) -> tuple[QueryAnswer, list[TChunk]]:
... # embed β vector_store.search β answer_agent.answer
Zero-config path uses a stub embedder (keyword bag-of-words) and stub
answer agent (templated response from retrieved chunks), both in
src/_core/infrastructure/rag/. Set EMBEDDING_PROVIDER + LLM_PROVIDER
in .env to swap in real providers β the pipeline is the same.
Architecture at a glance
Every domain under src/{domain}/ has four DDD layers. Arrows mean
"depends on". Application (use cases) is optional β the dotted
line is the common path for simple CRUD (Router β Service directly).
flowchart LR
subgraph domain["src/{domain}/ (4 DDD layers)"]
I["Interface<br/>routers Β· admin Β· worker Β· schemas"]
A["Application<br/>use cases β optional"]
D["Domain<br/>services Β· protocols Β· DTOs Β· value objects"]
Inf["Infrastructure<br/>repositories Β· models Β· DI container"]
I --> A
A --> D
Inf --> D
I -. direct when no UseCase .-> D
end
Core["src/_core/<br/>Base classes Β· CoreContainer Β· shared VOs"]
I --> Core
A --> Core
D --> Core
Inf --> Core
Other["Another domain"] -. via Protocol-based DIP .-> D
| Layer | Role | Base class |
|---|---|---|
| Interface | Router Β· Request/Response Β· Admin Β· Worker task | β |
| Domain | Service Β· Protocol Β· DTO Β· Exceptions | BaseService[CreateDTO, UpdateDTO, ReturnDTO] |
| Infrastructure | Repository Β· Model Β· DI container | BaseRepository[ReturnDTO] |
| Application | UseCase β optional orchestrator | β |
Full set of diagrams (Layer Β· Write Β· Read) plus RDB / DynamoDB / S3 Vectors variants lives in
docs/ai/shared/architecture-diagrams.md. Non-Mermaid viewers: SVG exports.
Data flow β Write (POST / PUT / DELETE)
flowchart LR
C[Client] -->|"HTTP + JSON"| R[Router]
R -->|"Request schema"| S[Service]
S -->|"entity"| Re["Repository<br/>BaseRepository[DTO]"]
Re -->|"Model(**dto.model_dump())"| M[ORM Model]
M -->|"SQLAlchemy"| DB[(Database)]
- Request β Service directly when fields match (no intermediate DTO β ADR 004).
- Model β DTO conversion happens only inside the Repository.
- Read flow is the mirror image; the Router strips sensitive fields on the way out.
Storage variants
Same flow, different base classes:
| Storage | Service base | Repository / Store base | List return |
|---|---|---|---|
| RDB (default) | BaseService[Create, Update, DTO] | BaseRepository[DTO] | (list[DTO], PaginationInfo) |
| DynamoDB | BaseDynamoService[β¦] | BaseDynamoRepository[DTO] | CursorPage[DTO] |
| S3 Vectors | domain-specific | BaseS3VectorStore[DTO] | VectorSearchResult[DTO] |
Interfaces
One business logic, multiple surfaces:
| Interface | Tech | Status | Purpose |
|---|---|---|---|
| HTTP API | FastAPI | Stable | REST endpoints |
| Async worker | Taskiq + SQS / RabbitMQ / InMemory | Stable | Background jobs |
| Admin UI | NiceGUI | Stable | Auto-generated admin CRUD |
| MCP server | FastMCP | Planned (#18) | AI agent tool interface |
Learn more
| I want to⦠| Read |
|---|---|
| Spin it up and poke around | docs/quickstart.md |
| See everything work end-to-end (auth Β· RBAC Β· worker Β· RAG Β· OTEL) | docs/canonical-demo.md |
| Build a real domain, end-to-end | docs/tutorial/first-domain.md |
| See small, pattern-focused example apps | examples/ |
| Understand the architecture in depth | docs/ai/shared/architecture-diagrams.md Β· AGENTS.md |
| Set up Claude Code or Codex CLI | docs/ai-development.md |
| Add a domain by hand (no AI tools) | docs/tutorial/first-domain.md (Path B) |
| Adopt into an existing FastAPI project | docs/adoption.md |
| Check Python / FastAPI / tool version support | docs/compatibility.md |
| See detailed env vars, tech stack, project tree | docs/reference.md |
| Understand why a decision was made | ADR index (18 active Β· 30 archived) |
| Follow what's next | Roadmap Β· issue tracker |
Roadmap
- MCP server interface β expose domain services as agent tools via FastMCP (#18)
- pgvector β additional vector backend alongside S3 Vectors (#11)
See full roadmap Β· open issues
Contributing
See CONTRIBUTING.md for dev setup, coding guidelines,
and the PR workflow. Newcomers β check the
good first issue
label; the small apps tracked under examples/ are a
low-friction place to land your first PR.
License
MIT β free for commercial use, modification, and distribution.

