Match the discord bot's CI pattern — trigger on CalVer tag push instead of branch push/PR. Removes auto-CalVer generation and simplifies to a single build step. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
52 lines
2.7 KiB
Markdown
52 lines
2.7 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:814` / `ssh sba-db` → `cd container-data/dev-sba-database` | **Adminer**: `http://10.10.0.42:8080`
|
|
- **Production**: `ssh akamai` → `cd container-data/sba-database`
|
|
- **Deploy (dev/prod)**: `docker-compose pull && docker-compose down && docker-compose up -d` (on the remote server)
|
|
|
|
## 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)
|
|
|
|
## Production Environment
|
|
- **Host**: `ssh akamai`
|
|
- **Path**: `~/container-data/sba-database`
|
|
- **Bot container**: `sba_postgres` (PostgreSQL) + `sba_db_api` (API) — check with `docker ps`
|
|
- **Other services on same host**: `major-domo-discord-app-1`, `sba_adminer`, `sba-website_sba-web_1`, `sba-ghost_sba-ghost_1`
|
|
- **Image**: `manticorum67/major-domo-database` (Docker Hub)
|
|
- **Version file**: `VERSION` — bump before merge to `main`
|
|
- **Health**: API Port 80 — `/health`, `/ready`, `/metrics`, `/diagnostics`
|
|
- **Env vars**: Set in `docker-compose.prod.yml` and passed to the container on startup (not stored in GitHub)
|
|
|
|
## Development Environment
|
|
- **Host**: `ssh sba-db`
|
|
- **Path**: `~/container-data/dev-sba-database`
|
|
- **Bot container**: `dev_sba_postgres` (PostgreSQL) + `dev_sba_db_api` (API) — check with `docker ps`
|
|
- **Image**: `manticorum67/major-domo-database:dev` (Docker Hub)
|
|
|
|
- **CI/CD**: Gitea Actions — tag-triggered Docker builds. Push a CalVer tag to release: `git tag -a 2026.4.5 -m "description" && git push origin 2026.4.5`
|
|
|
|
## 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`
|
|
- **NEVER run or test against the local docker compose** — always deploy to and test against the dev server (`10.10.0.42:814`). The local container has no meaningful data.
|