major-domo-database/CLAUDE.md
Cal Corum 49911c53ac
All checks were successful
Build Docker Image / build (pull_request) Successful in 2m23s
ci: Switch to CalVer (YYYY.MM.BUILD) with auto-generated versions
Remove manual semver validation from PR checks. Versions are now
auto-generated on merge to main by counting existing monthly tags.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-17 17:32:36 -06:00

39 lines
1.6 KiB
Markdown

# Major Domo Database API
FastAPI backend serving SBA fantasy league data. Peewee ORM with PostgreSQL.
## Commands
```bash
docker-compose up # Start PostgreSQL + API + Adminer
docker-compose up --build # Rebuild and start
docker-compose --profile sync up sync-prod # One-time production data sync
python migrations.py # Run migrations (SQL files in migrations/)
```
- **Dev server**: `10.10.0.42` | **Adminer**: `http://10.10.0.42:8080`
- **Production**: `ssh akamai``cd container-data/sba-database`
## Architecture
- **Routers**: Domain-based in `app/routers_v3/` under `/api/v3/` prefix
- **ORM**: Peewee — always specify `Meta.table_name` to match PostgreSQL naming
- **Auth**: OAuth2 bearer token via `API_TOKEN` env var
- **Error handling**: `@handle_db_errors` decorator (logging, rollback, HTTP errors)
- **POST models**: Use `Optional[int] = None` for `id` fields (DB auto-generates)
- **Logging**: Rotating file handler (`/tmp/sba-database.log`, 8MB max, 5 backups)
## Environment Variables
**Required**: `API_TOKEN`, `POSTGRES_HOST`, `POSTGRES_DB`, `POSTGRES_USER`, `POSTGRES_PASSWORD`
**Optional**: `POSTGRES_PORT` (5432), `LOG_LEVEL` (WARNING), `PRIVATE_IN_SCHEMA`
- **CI/CD**: Gitea Actions on PR to `main` — builds Docker image, auto-generates CalVer version (`YYYY.MM.BUILD`) on merge
## Important
- All active code is in `/app` — root-level `main.py`, `db_engine.py` are legacy, not in use
- PostgreSQL only (no SQLite fallback)
- Migrations are SQL files in `migrations/`, applied manually via psql
- API docs auto-generated at `/api/docs`