|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +## Project Overview |
| 4 | + |
| 5 | +Full-stack web app template: FastAPI backend + React frontend + PostgreSQL. JWT auth, user management, CRUD, auto-generated API client. Docker Compose-based monorepo with Traefik reverse proxy. |
| 6 | + |
| 7 | +## Technology Stack |
| 8 | + |
| 9 | +| Category | Technology | |
| 10 | +|----------|-----------| |
| 11 | +| Backend | Python >=3.10, FastAPI >=0.114.2 | |
| 12 | +| ORM | SQLModel >=0.0.21 (SQLAlchemy) | |
| 13 | +| Database | PostgreSQL 18, Alembic migrations | |
| 14 | +| Frontend | TypeScript 5.9, React 19.1, Vite 7.3 (SWC) | |
| 15 | +| Routing | TanStack Router 1.157+ (file-based) | |
| 16 | +| Server State | TanStack Query 5.90+ | |
| 17 | +| Styling | Tailwind CSS 4.2, shadcn/ui (new-york) | |
| 18 | +| Auth | JWT (HS256) via PyJWT, Argon2+Bcrypt | |
| 19 | + |
| 20 | +**Key Libraries:** Zod 4.x, React Hook Form 7.x, Axios 1.13, lucide-react, sonner |
| 21 | + |
| 22 | +## Architecture Overview |
| 23 | + |
| 24 | +**Pattern:** Layered monorepo — `backend/` (Python) + `frontend/` (TypeScript) |
| 25 | + |
| 26 | +``` |
| 27 | +backend/app/ |
| 28 | + api/routes/ # FastAPI endpoint handlers |
| 29 | + core/ # config.py, db.py, security.py |
| 30 | + alembic/versions/ # Database migrations |
| 31 | + models.py # SQLModel tables + Pydantic schemas |
| 32 | + crud.py # Data access functions |
| 33 | +frontend/src/ |
| 34 | + routes/ # TanStack file-based routing (pages) |
| 35 | + components/ # UI (Admin/, Items/, Common/, UserSettings/, Sidebar/, ui/) |
| 36 | + client/ # Auto-generated OpenAPI client — DON'T EDIT |
| 37 | + hooks/ # Custom React hooks |
| 38 | +``` |
| 39 | + |
| 40 | +**Important Patterns:** |
| 41 | +- Backend models: `ModelBase → ModelCreate → ModelUpdate → Model(table=True) → ModelPublic` |
| 42 | +- `src/client/`, `src/routeTree.gen.ts`, `src/components/ui/` are auto-generated — don't edit |
| 43 | + |
| 44 | +**Key Files:** `backend/app/main.py` (FastAPI entry), `backend/app/core/config.py` (settings from `.env`), `frontend/src/main.tsx` (React app + QueryClient + Router) |
| 45 | + |
| 46 | +## Development Commands |
| 47 | + |
| 48 | +```bash |
| 49 | +# Setup |
| 50 | +cd backend && uv sync # Backend deps |
| 51 | +bun install # Frontend deps |
| 52 | +cd backend && uv run prek install -f # Pre-commit hooks |
| 53 | +docker compose watch # Start full stack |
| 54 | + |
| 55 | +# Development |
| 56 | +docker compose watch # Full stack (recommended) |
| 57 | +bun run dev # Frontend only (:5173) |
| 58 | +cd backend && fastapi dev app/main.py # Backend only (:8000) |
| 59 | + |
| 60 | +# Testing |
| 61 | +bash ./scripts/test.sh # All backend tests (Pytest) |
| 62 | +bunx playwright test # Frontend E2E |
| 63 | +bunx playwright test tests/login.spec.ts # Single E2E test |
| 64 | + |
| 65 | +# Quality |
| 66 | +bun run lint # Frontend (Biome) |
| 67 | +uv run ruff check --fix # Backend lint |
| 68 | +uv run ruff format # Backend format |
| 69 | +uv run mypy backend/app # Backend type check |
| 70 | + |
| 71 | +# Utilities |
| 72 | +bash ./scripts/generate-client.sh # Regenerate OpenAPI client |
| 73 | +``` |
| 74 | + |
| 75 | +## Code Conventions |
| 76 | + |
| 77 | +- **Backend:** snake_case files/functions, PascalCase classes, absolute imports `from app.*`, Ruff + strict mypy |
| 78 | +- **Frontend:** PascalCase components, camelCase utils, `@/` alias → `./src/*`, Biome (double quotes, no semicolons) |
| 79 | + |
| 80 | +## Testing |
| 81 | + |
| 82 | +**Backend:** Pytest in `backend/tests/` (api/routes/, crud/, scripts/) — `uv run pytest backend/tests/path/to/test.py` |
| 83 | +**Frontend:** Playwright E2E in `frontend/tests/` — `bunx playwright test tests/file.spec.ts` |
| 84 | + |
| 85 | +See `@docs/testing/strategy.md` for coverage requirements and mocking patterns. |
| 86 | + |
| 87 | +## Database & Migrations |
| 88 | + |
| 89 | +**ORM:** SQLModel | **Models:** `backend/app/models.py` |
| 90 | + |
| 91 | +```bash |
| 92 | +alembic revision --autogenerate -m "desc" # Create migration |
| 93 | +alembic upgrade head # Apply pending |
| 94 | +alembic downgrade -1 # Rollback last |
| 95 | +alembic history --verbose # View history |
| 96 | +``` |
| 97 | + |
| 98 | +Always review autogenerated migrations before applying. See `@docs/data/models.md`. |
| 99 | + |
| 100 | +## Known Issues |
| 101 | + |
| 102 | +- `SECRET_KEY`, `POSTGRES_PASSWORD`, `FIRST_SUPERUSER_PASSWORD` default to `changethis` — change for staging/production |
| 103 | +- Backend syntax errors crash dev container — restart with `docker compose watch` |
| 104 | +- Pre-commit hook auto-regenerates frontend SDK on backend changes |
| 105 | +- Alembic autogenerated migrations need manual review |
| 106 | + |
| 107 | +## Documentation |
| 108 | + |
| 109 | +Key references in `docs/`: |
| 110 | +- `@docs/getting-started/setup.md` - Setup and environment |
| 111 | +- `@docs/getting-started/development.md` - Daily development workflow |
| 112 | +- `@docs/architecture/overview.md` - System architecture |
| 113 | +- `@docs/api/overview.md` - API documentation |
| 114 | +- `@docs/data/models.md` - Data models and schemas |
| 115 | +- `@docs/testing/strategy.md` - Testing approach |
| 116 | +- `@docs/deployment/environments.md` - Deployment guides |
| 117 | +- `@docs/deployment/ci-pipeline.md` - CI/CD pipeline documentation |
0 commit comments