fastapi-patternslisted
Install: claude install-skill RahulDas-dev/skill_builder
# FastAPI Project Structure & Patterns
## When to Use This Skill
* Scaffolding a new route, service, component, config concern, or startup step in a FastAPI project
* Deciding which directory/file a piece of logic belongs in (`routes/` vs `services/` vs `db/` vs `startops/`)
* Reviewing whether an existing FastAPI project follows consistent structure and naming
* Adding SSE streaming endpoints, dependency injection, or error-handling to a route
## Dependencies
| Package | Role | Required |
| --- | --- | --- |
| `fastapi` | Web framework — routing, DI, `StreamingResponse` | Yes |
| `pydantic` v2 | `BaseModel` request/response models, `Field`, `alias_generators.to_camel` | Yes |
| `pydantic-settings` | `BaseSettings` config classes (see `references/configs.md`) | Yes |
| `sqlalchemy` (async, 2.0-style `Mapped`/`mapped_column`) | ORM layer (`db/`) | Yes, if using a database |
| `asyncpg` / `aiosqlite` | Async DB drivers for Postgres / SQLite respectively | Yes, matching your `DB_TYPE` |
| `python-dotenv` | Loads the `.config` env file at startup (`startops/set_env.py`) | Yes |
| `sse-starlette` | Alternative SSE response wrapper (see `references/routes.md`) | Optional |
| `uvicorn` | ASGI server to run the app | Yes, for local/dev running |
This skill documents *conventions* on top of these libraries, not the libraries themselves — see each library's own docs for API details.
## Project Layout
```
<package>/
├── app.py # FastAPI app factory + lifesp