fastapi-postgres-stack
2
总安装量
2
周安装量
#71403
全站排名
安装命令
npx skills add https://github.com/zentik-ai/fastapi-postgres-stack --skill fastapi-postgres-stack
Agent 安装分布
opencode
2
gemini-cli
2
antigravity
2
claude-code
2
github-copilot
2
codex
2
Skill 文档
FastAPI + PostgreSQL
Tech Stack
- Runtime: Python ^3.11 + Poetry ^2.1
- Web: FastAPI ^0.104.1, Uvicorn ^0.34.0
- Validation: Pydantic ^2.4.2, pydantic-settings ^2.9.1
- Database: PostgreSQL 15+, SQLAlchemy ^2.0.23, SQLModel ^0.0.24, asyncpg ^0.30.0
- Migrations: dbmate (latest)
- Cache/Queue: Redis ^6.2.0, Celery ^5.5.3
- Observability: Sentry ^2.39.0, Loguru ^0.7.2, OpenTelemetry ^1.22.0
- Testing: pytest ^7.4.2, pytest-asyncio ^0.21.1, pytest-cov ^5.0.0
- HTTP clients: httpx ^0.25.0 (async), requests ^2.31.0 (sync)
- Auth: python-jose ^3.4.0
- Utils: python-dotenv ^1.0.0, pytz ^2025.1, backoff ^2.2.1, cachetools ^5.5.0
For full version table see references/stack.md.
Layered Architecture
HTTP Request
â
â¼
PRESENTATION LAYER app/api/{domain}/points.py (FastAPI Routers)
â Receives HTTP, validates input via Pydantic, delegates to service
â¼
BUSINESS LAYER app/api/{domain}/service.py (Services)
â Business logic, orchestration, validations
â¼
DATA ACCESS LAYER app/db/{entity}/table.py (Repositories)
â CRUD ops, complex queries, DB abstraction
â¼
DATABASE LAYER PostgreSQL + SQLAlchemy/SQLModel
Key Conventions
- Files:
snake_caseâuser_service.py,auth_middleware.py - Classes:
PascalCaseâUserService,MessagesTable - Functions/Methods/Variables:
snake_case - Constants:
UPPER_SNAKE_CASEâMAX_RETRIES,DEFAULT_TIMEOUT - Domain modules: singular snake_case â
messaging/,webhook/ - DB tables: plural snake_case â
messages,webhooks
Reference Files
Load only what is relevant to the current task:
| File | When to read |
|---|---|
| references/architecture.md | Folder structure, domain layout, DI pattern |
| references/patterns.md | Code patterns: models, endpoints, services, repositories |
| references/database.md | Migrations, BaseTable CRUD methods, SQLModel conventions |
| references/devops.md | Docker, Celery tasks, testing, env config, security, checklist |
Quick Start: Adding a New Domain
- Create
app/api/{domain}/with__init__.py,models.py,points.py,service.py - Create
app/db/{entity}/withmodel.py(SQLModel) andtable.py(BaseTable) - Write migration in
db/migrations/{number}_{description}.sql - Register router in
app/api/api.py - Add tests in
tests/api/test_{domain}.pyandtests/db/test_{entity}.py
See references/patterns.md for complete code templates.