@martinffx/atelier 1.4.0 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +38 -0
- package/README.md +95 -220
- package/agents/architect.md +6 -6
- package/agents/oracle.md +1 -1
- package/agents/{recon.md → sentinel.md} +3 -3
- package/dist/atelier.js +167 -26
- package/package.json +2 -1
- package/skills/atelier-orchestrator/SKILL.md +180 -0
- package/skills/atelier-setup/SKILL.md +80 -0
- package/skills/code-review/SKILL.md +2 -2
- package/skills/code-review/references/reviewers.md +3 -3
- package/skills/code-review/references/rq.md +9 -9
- package/skills/code-subagents/SKILL.md +44 -75
- package/skills/code-subagents/references/batch-reviewer-prompt.md +44 -0
- package/skills/code-subagents/references/implementor-prompt.md +10 -11
- package/skills/spec-brainstorm/SKILL.md +21 -16
- package/skills/spec-finish/SKILL.md +14 -14
- package/skills/spec-implement/SKILL.md +42 -42
- package/skills/spec-plan/SKILL.md +72 -26
- package/skills/spec-plan/references/plan_template.md +77 -0
- package/skills/code-subagents/references/code-quality-reviewer-prompt.md +0 -48
- package/skills/code-subagents/references/spec-reviewer-prompt.md +0 -62
- package/skills/python-architecture/SKILL.md +0 -148
- package/skills/python-architecture/references/data-modeling.md +0 -558
- package/skills/python-architecture/references/ddd.md +0 -569
- package/skills/python-architecture/references/functional-core.md +0 -337
- package/skills/python-build-tools/SKILL.md +0 -153
- package/skills/python-build-tools/references/basedpyright.md +0 -321
- package/skills/python-build-tools/references/ruff.md +0 -225
- package/skills/python-build-tools/references/uv.md +0 -257
- package/skills/python-fastapi/SKILL.md +0 -184
- package/skills/python-fastapi/references/api-design.md +0 -563
- package/skills/python-fastapi/references/dependencies.md +0 -479
- package/skills/python-fastapi/references/middleware.md +0 -475
- package/skills/python-fastapi/references/validation.md +0 -497
- package/skills/python-modern-python/SKILL.md +0 -201
- package/skills/python-modern-python/references/async.md +0 -76
- package/skills/python-modern-python/references/pattern-matching.md +0 -89
- package/skills/python-modern-python/references/typing.md +0 -96
- package/skills/python-monorepo/SKILL.md +0 -146
- package/skills/python-monorepo/references/docker.md +0 -515
- package/skills/python-monorepo/references/namespace-packages.md +0 -426
- package/skills/python-monorepo/references/workspace-config.md +0 -341
- package/skills/python-sqlalchemy/SKILL.md +0 -119
- package/skills/python-sqlalchemy/references/async.md +0 -51
- package/skills/python-sqlalchemy/references/models.md +0 -67
- package/skills/python-sqlalchemy/references/queries.md +0 -57
- package/skills/python-temporal/SKILL.md +0 -128
- package/skills/python-temporal/references/patterns.md +0 -87
- package/skills/python-temporal/references/testing.md +0 -54
- package/skills/python-testing/SKILL.md +0 -161
- package/skills/python-testing/references/boundaries.md +0 -449
- package/skills/python-testing/references/mocking.md +0 -449
- package/skills/python-testing/references/pytest.md +0 -524
- package/skills/spec-orchestrator/SKILL.md +0 -145
- package/skills/typescript-api-design/SKILL.md +0 -396
- package/skills/typescript-api-design/references/error-responses.md +0 -469
- package/skills/typescript-build-tools/SKILL.md +0 -447
- package/skills/typescript-build-tools/references/biome.md +0 -436
- package/skills/typescript-build-tools/references/bun.md +0 -432
- package/skills/typescript-build-tools/references/turborepo.md +0 -426
- package/skills/typescript-build-tools/references/vitest.md +0 -518
- package/skills/typescript-drizzle-orm/SKILL.md +0 -398
- package/skills/typescript-drizzle-orm/references/cloudflare.md +0 -392
- package/skills/typescript-drizzle-orm/references/entity-pattern.md +0 -412
- package/skills/typescript-drizzle-orm/references/postgresql.md +0 -191
- package/skills/typescript-drizzle-orm/references/repository-pattern.md +0 -479
- package/skills/typescript-drizzle-orm/references/sqlite.md +0 -291
- package/skills/typescript-dynamodb-toolbox/SKILL.md +0 -370
- package/skills/typescript-dynamodb-toolbox/references/entity-layer.md +0 -574
- package/skills/typescript-dynamodb-toolbox/references/error-handling.md +0 -495
- package/skills/typescript-dynamodb-toolbox/references/modeling.md +0 -332
- package/skills/typescript-dynamodb-toolbox/references/repository-layer.md +0 -631
- package/skills/typescript-dynamodb-toolbox/references/testing.md +0 -718
- package/skills/typescript-dynamodb-toolbox/references/transactions.md +0 -423
- package/skills/typescript-effect-ts/SKILL.md +0 -341
- package/skills/typescript-effect-ts/references/core.md +0 -412
- package/skills/typescript-effect-ts/references/error-handling.md +0 -468
- package/skills/typescript-effect-ts/references/resources.md +0 -476
- package/skills/typescript-effect-ts/references/schema.md +0 -536
- package/skills/typescript-effect-ts/references/services.md +0 -461
- package/skills/typescript-fastify/SKILL.md +0 -405
- package/skills/typescript-fastify/references/plugins.md +0 -329
- package/skills/typescript-fastify/references/typeid.md +0 -315
- package/skills/typescript-functional-patterns/SKILL.md +0 -402
- package/skills/typescript-functional-patterns/references/adts.md +0 -497
- package/skills/typescript-functional-patterns/references/branded-types.md +0 -542
- package/skills/typescript-functional-patterns/references/migration-guide.md +0 -695
- package/skills/typescript-functional-patterns/references/option-result.md +0 -585
- package/skills/typescript-testing/SKILL.md +0 -353
- package/skills/typescript-testing/references/mocking.md +0 -675
- package/skills/typescript-testing/references/msw.md +0 -852
- package/skills/typescript-testing/references/snapshot-testing.md +0 -774
|
@@ -1,257 +0,0 @@
|
|
|
1
|
-
# uv - Fast Python Package Manager
|
|
2
|
-
|
|
3
|
-
Rust-based Python package manager that replaces pip, pip-tools, and virtualenv. 10-100x faster than pip with full pip and setuptools compatibility.
|
|
4
|
-
|
|
5
|
-
## Installation
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
curl -LsSf https://astral.sh/uv/install.sh | sh
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
## Project Setup
|
|
12
|
-
|
|
13
|
-
```bash
|
|
14
|
-
# Create new project with uv template
|
|
15
|
-
uv init my-project
|
|
16
|
-
cd my-project
|
|
17
|
-
|
|
18
|
-
# Initialize uv in existing project
|
|
19
|
-
uv init
|
|
20
|
-
|
|
21
|
-
# Install Python version
|
|
22
|
-
uv python install 3.12
|
|
23
|
-
|
|
24
|
-
# Install dependencies
|
|
25
|
-
uv sync
|
|
26
|
-
|
|
27
|
-
# Add dependencies
|
|
28
|
-
uv add fastapi pydantic
|
|
29
|
-
|
|
30
|
-
# Add dev dependencies
|
|
31
|
-
uv add --dev pytest ruff basedpyright
|
|
32
|
-
|
|
33
|
-
# Remove dependency
|
|
34
|
-
uv remove fastapi
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
## Running Commands
|
|
38
|
-
|
|
39
|
-
```bash
|
|
40
|
-
# Run Python script
|
|
41
|
-
uv run python script.py
|
|
42
|
-
|
|
43
|
-
# Run module
|
|
44
|
-
uv run python -m my_module
|
|
45
|
-
|
|
46
|
-
# Run installed tool (no venv activation needed)
|
|
47
|
-
uv run pytest
|
|
48
|
-
uv run ruff check .
|
|
49
|
-
uv run basedpyright
|
|
50
|
-
|
|
51
|
-
# Run with specific Python version
|
|
52
|
-
uv run --python 3.12 python script.py
|
|
53
|
-
|
|
54
|
-
# Run script in context with venv
|
|
55
|
-
uv run python -c "import fastapi; print(fastapi.__version__)"
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
## Dependency Management
|
|
59
|
-
|
|
60
|
-
```bash
|
|
61
|
-
# Update all dependencies
|
|
62
|
-
uv lock --upgrade
|
|
63
|
-
|
|
64
|
-
# Update specific package
|
|
65
|
-
uv lock --upgrade-package fastapi
|
|
66
|
-
|
|
67
|
-
# Show dependency tree
|
|
68
|
-
uv tree
|
|
69
|
-
|
|
70
|
-
# Export requirements.txt
|
|
71
|
-
uv pip compile pyproject.toml -o requirements.txt
|
|
72
|
-
|
|
73
|
-
# Sync after manual pyproject.toml edits
|
|
74
|
-
uv sync
|
|
75
|
-
|
|
76
|
-
# Sync and skip lock file update
|
|
77
|
-
uv sync --frozen
|
|
78
|
-
|
|
79
|
-
# Reinstall all
|
|
80
|
-
uv sync --reinstall
|
|
81
|
-
```
|
|
82
|
-
|
|
83
|
-
## Workspace Configuration
|
|
84
|
-
|
|
85
|
-
For monorepos with multiple packages:
|
|
86
|
-
|
|
87
|
-
```toml
|
|
88
|
-
[workspace]
|
|
89
|
-
members = ["packages/core", "packages/api", "packages/cli"]
|
|
90
|
-
|
|
91
|
-
[project]
|
|
92
|
-
name = "monorepo"
|
|
93
|
-
version = "0.1.0"
|
|
94
|
-
|
|
95
|
-
[tool.uv.workspace]
|
|
96
|
-
exclude = ["docs"]
|
|
97
|
-
```
|
|
98
|
-
|
|
99
|
-
Then within each member:
|
|
100
|
-
|
|
101
|
-
```toml
|
|
102
|
-
[project]
|
|
103
|
-
name = "core"
|
|
104
|
-
version = "0.1.0"
|
|
105
|
-
dependencies = []
|
|
106
|
-
|
|
107
|
-
[project.optional-dependencies]
|
|
108
|
-
dev = ["pytest>=8.0.0"]
|
|
109
|
-
```
|
|
110
|
-
|
|
111
|
-
## Scripts in pyproject.toml
|
|
112
|
-
|
|
113
|
-
```toml
|
|
114
|
-
[tool.uv.scripts]
|
|
115
|
-
dev = "uvicorn my_app.main:app --reload"
|
|
116
|
-
migrate = "alembic upgrade head"
|
|
117
|
-
test = "pytest tests/"
|
|
118
|
-
lint = "ruff check ."
|
|
119
|
-
format = "ruff format ."
|
|
120
|
-
typecheck = "basedpyright"
|
|
121
|
-
check = { chain = ["lint", "format", "typecheck", "test"] }
|
|
122
|
-
```
|
|
123
|
-
|
|
124
|
-
Run scripts:
|
|
125
|
-
|
|
126
|
-
```bash
|
|
127
|
-
uv run dev
|
|
128
|
-
uv run migrate
|
|
129
|
-
uv run test
|
|
130
|
-
uv run check # Runs all checks in sequence
|
|
131
|
-
```
|
|
132
|
-
|
|
133
|
-
## Version Pinning
|
|
134
|
-
|
|
135
|
-
Specify exact versions in pyproject.toml:
|
|
136
|
-
|
|
137
|
-
```toml
|
|
138
|
-
dependencies = [
|
|
139
|
-
"fastapi>=0.100.0,<1.0.0",
|
|
140
|
-
"pydantic==2.0.0",
|
|
141
|
-
"sqlalchemy>=2.0.0",
|
|
142
|
-
]
|
|
143
|
-
|
|
144
|
-
[project.optional-dependencies]
|
|
145
|
-
dev = [
|
|
146
|
-
"pytest>=8.0.0",
|
|
147
|
-
"pytest-cov>=5.0.0",
|
|
148
|
-
"ruff>=0.8.0",
|
|
149
|
-
"basedpyright>=1.0.0",
|
|
150
|
-
]
|
|
151
|
-
```
|
|
152
|
-
|
|
153
|
-
The lock file (`uv.lock`) records exact versions used.
|
|
154
|
-
|
|
155
|
-
## Environment Variables
|
|
156
|
-
|
|
157
|
-
Create `.env` file in project root:
|
|
158
|
-
|
|
159
|
-
```bash
|
|
160
|
-
DATABASE_URL="postgresql://user:pass@localhost/mydb"
|
|
161
|
-
PYTHONPATH="src"
|
|
162
|
-
LOG_LEVEL="INFO"
|
|
163
|
-
```
|
|
164
|
-
|
|
165
|
-
Load in Python:
|
|
166
|
-
|
|
167
|
-
```python
|
|
168
|
-
import os
|
|
169
|
-
from dotenv import load_dotenv
|
|
170
|
-
|
|
171
|
-
load_dotenv()
|
|
172
|
-
db_url = os.getenv("DATABASE_URL")
|
|
173
|
-
```
|
|
174
|
-
|
|
175
|
-
Or use `python-dotenv`:
|
|
176
|
-
|
|
177
|
-
```bash
|
|
178
|
-
uv add python-dotenv
|
|
179
|
-
```
|
|
180
|
-
|
|
181
|
-
## Advanced Options
|
|
182
|
-
|
|
183
|
-
### Custom Index
|
|
184
|
-
|
|
185
|
-
```toml
|
|
186
|
-
[tool.uv]
|
|
187
|
-
index-url = "https://pypi.org/simple"
|
|
188
|
-
extra-index-urls = ["https://test.pypi.org/simple"]
|
|
189
|
-
```
|
|
190
|
-
|
|
191
|
-
### Dev Dependencies Separation
|
|
192
|
-
|
|
193
|
-
```toml
|
|
194
|
-
[project]
|
|
195
|
-
dependencies = ["fastapi>=0.100.0"]
|
|
196
|
-
|
|
197
|
-
[project.optional-dependencies]
|
|
198
|
-
dev = ["pytest>=8.0.0", "ruff>=0.8.0"]
|
|
199
|
-
test = ["pytest>=8.0.0"]
|
|
200
|
-
docs = ["sphinx>=6.0.0"]
|
|
201
|
-
|
|
202
|
-
[tool.uv]
|
|
203
|
-
dev-dependencies = [
|
|
204
|
-
"pytest>=8.0.0",
|
|
205
|
-
"ruff>=0.8.0",
|
|
206
|
-
"basedpyright>=1.0.0",
|
|
207
|
-
]
|
|
208
|
-
```
|
|
209
|
-
|
|
210
|
-
### Constraints File
|
|
211
|
-
|
|
212
|
-
Use constraints.txt to pin versions without changing dependencies:
|
|
213
|
-
|
|
214
|
-
```bash
|
|
215
|
-
# constraints.txt
|
|
216
|
-
sqlalchemy==2.0.0
|
|
217
|
-
pydantic==2.5.0
|
|
218
|
-
```
|
|
219
|
-
|
|
220
|
-
Apply constraints:
|
|
221
|
-
|
|
222
|
-
```bash
|
|
223
|
-
uv pip compile pyproject.toml --constraint constraints.txt -o requirements.txt
|
|
224
|
-
```
|
|
225
|
-
|
|
226
|
-
## Performance
|
|
227
|
-
|
|
228
|
-
uv is 10-100x faster because it:
|
|
229
|
-
- Written in Rust (native performance)
|
|
230
|
-
- Parallel dependency resolution
|
|
231
|
-
- Intelligent caching
|
|
232
|
-
- Compiled wheels by default
|
|
233
|
-
- Local disk cache
|
|
234
|
-
|
|
235
|
-
Typical project:
|
|
236
|
-
- pip: 30-60 seconds
|
|
237
|
-
- uv: 1-5 seconds
|
|
238
|
-
|
|
239
|
-
## Troubleshooting
|
|
240
|
-
|
|
241
|
-
```bash
|
|
242
|
-
# Clear cache
|
|
243
|
-
uv cache clean
|
|
244
|
-
|
|
245
|
-
# Verbose output
|
|
246
|
-
uv sync -v
|
|
247
|
-
|
|
248
|
-
# Check Python installation
|
|
249
|
-
uv python list
|
|
250
|
-
|
|
251
|
-
# Update uv itself
|
|
252
|
-
uv self update
|
|
253
|
-
|
|
254
|
-
# Check project structure
|
|
255
|
-
uv tree
|
|
256
|
-
uv tree --depth 2
|
|
257
|
-
```
|
|
@@ -1,184 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: python-fastapi
|
|
3
|
-
description: Building REST APIs with FastAPI, Pydantic validation, and OpenAPI. Use when creating routes, handling requests, designing endpoints, implementing validation, error responses, pagination, or generating API documentation.
|
|
4
|
-
user-invocable: false
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
# FastAPI - Modern Python Web APIs
|
|
8
|
-
|
|
9
|
-
FastAPI is a modern, fast web framework for building APIs with Python, using standard Python type hints. FastAPI automatically validates requests, generates OpenAPI documentation, and provides excellent developer experience.
|
|
10
|
-
|
|
11
|
-
## Quick Start
|
|
12
|
-
|
|
13
|
-
### Basic Application
|
|
14
|
-
|
|
15
|
-
```python
|
|
16
|
-
from fastapi import FastAPI
|
|
17
|
-
from pydantic import BaseModel
|
|
18
|
-
|
|
19
|
-
app = FastAPI(
|
|
20
|
-
title="My API",
|
|
21
|
-
description="API for my application",
|
|
22
|
-
version="1.0.0",
|
|
23
|
-
)
|
|
24
|
-
|
|
25
|
-
class Item(BaseModel):
|
|
26
|
-
name: str
|
|
27
|
-
price: float
|
|
28
|
-
|
|
29
|
-
@app.get("/")
|
|
30
|
-
def read_root():
|
|
31
|
-
return {"message": "Hello World"}
|
|
32
|
-
|
|
33
|
-
@app.post("/items", response_model=Item)
|
|
34
|
-
def create_item(item: Item):
|
|
35
|
-
return item
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
**Run with:**
|
|
39
|
-
```bash
|
|
40
|
-
uvicorn main:app --reload
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
## Core Concepts
|
|
44
|
-
|
|
45
|
-
### Request & Response Models
|
|
46
|
-
|
|
47
|
-
Use Pydantic models for automatic validation and serialization:
|
|
48
|
-
|
|
49
|
-
```python
|
|
50
|
-
from pydantic import BaseModel, EmailStr, Field
|
|
51
|
-
|
|
52
|
-
class CreateUserRequest(BaseModel):
|
|
53
|
-
email: EmailStr
|
|
54
|
-
name: str = Field(min_length=1, max_length=100)
|
|
55
|
-
age: int = Field(ge=18, le=120)
|
|
56
|
-
|
|
57
|
-
class UserResponse(BaseModel):
|
|
58
|
-
id: int
|
|
59
|
-
email: str
|
|
60
|
-
name: str
|
|
61
|
-
model_config = {"from_attributes": True} # Enable ORM mode
|
|
62
|
-
|
|
63
|
-
@app.post("/users", response_model=UserResponse)
|
|
64
|
-
def create_user(user: CreateUserRequest):
|
|
65
|
-
"""Request validated, response serialized automatically"""
|
|
66
|
-
return user
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
See `references/validation.md` for detailed validation patterns including custom validators and field constraints.
|
|
70
|
-
|
|
71
|
-
### Routers for Organization
|
|
72
|
-
|
|
73
|
-
Split routes across routers for clean organization:
|
|
74
|
-
|
|
75
|
-
```python
|
|
76
|
-
# routers/users.py
|
|
77
|
-
from fastapi import APIRouter
|
|
78
|
-
|
|
79
|
-
router = APIRouter(prefix="/users", tags=["users"])
|
|
80
|
-
|
|
81
|
-
@router.get("/")
|
|
82
|
-
def list_users():
|
|
83
|
-
...
|
|
84
|
-
|
|
85
|
-
@router.post("/")
|
|
86
|
-
def create_user(user: CreateUserRequest):
|
|
87
|
-
...
|
|
88
|
-
|
|
89
|
-
# main.py
|
|
90
|
-
app.include_router(users.router)
|
|
91
|
-
```
|
|
92
|
-
|
|
93
|
-
### Dependency Injection
|
|
94
|
-
|
|
95
|
-
FastAPI's core feature for managing dependencies like database sessions and authentication:
|
|
96
|
-
|
|
97
|
-
```python
|
|
98
|
-
from fastapi import Depends
|
|
99
|
-
from sqlalchemy.orm import Session
|
|
100
|
-
|
|
101
|
-
def get_db() -> Session:
|
|
102
|
-
"""Database session dependency"""
|
|
103
|
-
db = SessionLocal()
|
|
104
|
-
try:
|
|
105
|
-
yield db
|
|
106
|
-
finally:
|
|
107
|
-
db.close()
|
|
108
|
-
|
|
109
|
-
@app.get("/users")
|
|
110
|
-
def list_users(db: Session = Depends(get_db)):
|
|
111
|
-
"""db automatically injected"""
|
|
112
|
-
return db.query(User).all()
|
|
113
|
-
```
|
|
114
|
-
|
|
115
|
-
See `references/dependencies.md` for advanced patterns including auth services, scoped dependencies, and dependency classes.
|
|
116
|
-
|
|
117
|
-
## Error Handling
|
|
118
|
-
|
|
119
|
-
### HTTP Exceptions
|
|
120
|
-
|
|
121
|
-
```python
|
|
122
|
-
from fastapi import HTTPException
|
|
123
|
-
|
|
124
|
-
@app.get("/users/{user_id}")
|
|
125
|
-
def get_user(user_id: int):
|
|
126
|
-
user = db.get(user_id)
|
|
127
|
-
if not user:
|
|
128
|
-
raise HTTPException(status_code=404, detail="User not found")
|
|
129
|
-
return user
|
|
130
|
-
```
|
|
131
|
-
|
|
132
|
-
### Custom Exception Handlers
|
|
133
|
-
|
|
134
|
-
```python
|
|
135
|
-
from fastapi import Request
|
|
136
|
-
from fastapi.responses import JSONResponse
|
|
137
|
-
|
|
138
|
-
class BusinessError(Exception):
|
|
139
|
-
def __init__(self, message: str):
|
|
140
|
-
self.message = message
|
|
141
|
-
|
|
142
|
-
@app.exception_handler(BusinessError)
|
|
143
|
-
async def business_error_handler(request: Request, exc: BusinessError):
|
|
144
|
-
return JSONResponse(
|
|
145
|
-
status_code=400,
|
|
146
|
-
content={"error": exc.message},
|
|
147
|
-
)
|
|
148
|
-
```
|
|
149
|
-
|
|
150
|
-
## Project Structure
|
|
151
|
-
|
|
152
|
-
```
|
|
153
|
-
my-api/
|
|
154
|
-
├── main.py # FastAPI app
|
|
155
|
-
├── routers/ # Route handlers
|
|
156
|
-
│ ├── users.py
|
|
157
|
-
│ └── products.py
|
|
158
|
-
├── schemas/ # Pydantic models
|
|
159
|
-
│ ├── users.py
|
|
160
|
-
│ └── products.py
|
|
161
|
-
├── services/ # Business logic
|
|
162
|
-
│ └── users.py
|
|
163
|
-
├── repositories/ # Data access
|
|
164
|
-
│ └── users.py
|
|
165
|
-
└── dependencies.py # Dependency injection
|
|
166
|
-
```
|
|
167
|
-
|
|
168
|
-
## Reference Materials
|
|
169
|
-
|
|
170
|
-
Detailed patterns for common scenarios:
|
|
171
|
-
|
|
172
|
-
- **Validation**: `references/validation.md` - Field constraints, custom validators, model validation
|
|
173
|
-
- **Dependencies**: `references/dependencies.md` - Auth services, scoped dependencies, advanced injection patterns
|
|
174
|
-
- **Middleware**: `references/middleware.md` - CORS, custom middleware, request/response processing
|
|
175
|
-
- **API Design**: `references/api-design.md` - REST naming, pagination, OpenAPI customization, status codes
|
|
176
|
-
|
|
177
|
-
## Best Practices
|
|
178
|
-
|
|
179
|
-
1. **Use response_model** - Always define explicit response schemas
|
|
180
|
-
2. **Validate inputs** - Use Pydantic models with constraints
|
|
181
|
-
3. **Dependency injection** - Manage sessions, auth, and cross-cutting concerns
|
|
182
|
-
4. **Router organization** - Split routes by resource/domain
|
|
183
|
-
5. **Error handling** - Use HTTP exceptions and custom handlers appropriately
|
|
184
|
-
6. **Type hints** - FastAPI uses them for both validation and documentation
|