Imported from zamminhduy123/daucv (
cv-fit-app/backend/AGENTS.md). Install upstream withnpx skills add zamminhduy123/daucv --skill backend. Copyright stays with the author.
Agent Guidelines — FastAPI MVP
Read this before every task. Follow exactly.
Folder Structure
app/
├── main.py # FastAPI app, route registration
├── config.py # Settings via pydantic-settings (reads .env)
├── dependencies.py # Shared Depends() functions
├── schemas/ # Pydantic request/response models (one file per domain)
├── services/ # Business logic + LLM calls (one file per domain)
└── api/ # Routers (one file per domain)
└── v1/
tests/
.env # Never commit
.env.example # Commit this instead
Rules
- New domain (e.g.
summary) → always createschemas/summary.py,services/summary_service.py,api/routes/summary.py. Never partial. - Database Integration: Connect to Supabase PostgreSQL using
app.core.db.Databaseasync pool. All transactions affecting credits MUST be run transactionally (async with conn.transaction()) to prevent race conditions or double deductions. - Authentication & Security: Secure all user endpoints using
Depends(get_current_user)orDepends(verify_credits(N)). - JWT Handling: Symmetrically verify frontend NextAuth JWT sessions using
pyjwtwith the sharedNEXTAUTH_SECRET(HS256). - All LLM calls live in
services/only — never in routers. - Use environment variables (via
os.getenvor pydantic config) for settings — never hardcode secrets. - Type hints required on every function. No
print()— uselogging. - Routers handle HTTP only. Services handle logic. Keep them separate.
