FastAPI Best Architecture
Official documentation: https://fastapi-practices.github.io/fastapi_best_architecture_docs/
Use this skill to follow fba architecture and plugin conventions. Read only the references needed for the task. For cross-layer feature work, read references/development.md first, then load the layer-specific references.
Core Architecture
Project adopts a layered backend architecture centered on API, Service, and CRUD, with Schema and Model as explicit data contracts:
| Layer | Responsibility |
|---|---|
| API | Route processing, parameter validation, and response return |
| Schema | Data transfer objects, request/response data structure definitions |
| Service | Business logic, data processing, exception handling |
| CRUD | Database operations (inherits CRUDPlus) |
| Model | ORM models (inherits Base) |
Development Workflow
- Define database models (model)
- Define data validation models (schema)
- Define routes (router)
- Write business logic (service)
- Write database operations (crud)
Reference Selection
| Task | Read |
|---|---|
| Feature/module development flow, Service/CRUD placement, pagination, cache, Celery, i18n, code generation | references/development.md |
| API routes, dependencies, response patterns, auth, permissions | references/api.md |
| Pydantic request/response DTOs | references/schema.md |
| SQLAlchemy models and migrations | references/model.md |
| CRUD, Service, API, Schema, entity and table prefix naming | references/naming.md |
| Backend/frontend plugin development and plugin README files | references/plugin.md |
| Plugin sharing, public repositories, marketplace PRs, submodules, updates | references/plugin-sharing.md |
| Formatting, comments, docstrings, commit style | references/coding-style.md |
| Global settings and configuration | references/config.md |
Plugin Work
When creating, reviewing, or updating plugins:
- Read
references/plugin.mdfor plugin type, structure, manifest, configuration, hooks, SQL, and README rules - Read
references/plugin-sharing.mdwhen the task involves sharing, publishing, updating, marketplace PRs, plugin repositories, or Git submodules - Prefer source-code behavior from
fastapi-best-architecturewhen docs and implementation differ - Do not perform git add, commit, push, or PR actions unless the user explicitly asks
CLI
Execute fba -h for more details.