With the shipped local default (DEBUG=true) the root logger was set to DEBUG, so
aiosqlite printed every cursor operation and the console became unreadable
(hundreds of lines per request).
- only the `app` namespace follows DEBUG; the root logger stays at INFO
- SQLAlchemy / aiosqlite / asyncpg / asyncio are pinned to WARNING, or INFO when
DB_ECHO is explicitly enabled (the engine already emits SQL at INFO then)
- uvicorn loggers are aligned to INFO and propagate to our handler as before
Observed on the running dev server: startup went from ~40 driver lines to 4
(Starting / Database target / connection established / Application startup
complete) and requests log a single uvicorn.access line.
docs: also document the Windows `--reload` caveat found while verifying: uvicorn
restarts the child with CTRL_C_EVENT, which cannot reach a child in a different
console / redirected-stdio environment, so the reloader prints "Reloading..."
and then blocks in process.join() while the old code keeps serving.
Verification: ruff + ruff format clean, pytest 14 passed, and the fix was proven
in isolation (aiosqlite effective level 30, app 10) and on the restarted server.
The database is no longer part of the stack, so the Compose project only builds
and runs the two application services.
- docker-compose.yml: drop the `postgres` service and the `postgres-data` volume;
the backend now receives DATABASE_URL as a plain environment variable
(default `postgresql+asyncpg://app:app@host.docker.internal:5432/app`, i.e. a
database running on the Docker host)
- add `extra_hosts: host.docker.internal:host-gateway` so the host name also
resolves on Linux, not just Docker Desktop
- plumb DB_WAIT_TIMEOUT through to the container; the entrypoint still waits for
the database and then runs `alembic upgrade head` before serving traffic, so a
slow or temporarily unreachable external instance no longer crash-loops the API
- .env.example: replace POSTGRES_USER/PASSWORD/DB/PORT with a single documented
DATABASE_URL (host DB / sibling container / managed instance examples, plus the
SQLite escape hatch and password percent-encoding note)
- README: prerequisites now create the role and database up front, the env table
and Docker section describe the three external-database scenarios, and the FAQ
covers "container cannot reach the database" and auth failures
Verification
- docker-compose.yml parsed and asserted: exactly {backend, frontend}, no volumes,
backend has no depends_on, frontend gates on service_started, extra_hosts set,
no nested ${} defaults
- repo-wide grep confirms no POSTGRES_* / postgres-data / `down -v` leftovers
pydantic-settings merges multiple env files in order and the last one wins
(verified experimentally). Listing ".env" last means the backend-local file takes
precedence over the repository-root .env that drives Docker Compose, while real
environment variables still win over both. The comment now documents that rule.
- stack table, annotated directory tree and both quick-start paths
(Docker Compose and native hot-reload development)
- environment variable reference for .env, backend/.env and frontend/.env
- v1 endpoint table, migration workflow and per-side command cheatsheet
- Docker service matrix plus the WAIT_FOR_DATABASE / RUN_MIGRATIONS switches
- step-by-step recipe for adding a new module (mirrors the items example)
- verification matrix and FAQ, including the honest note that Docker images
could not be built in the initialization environment (no Docker CLI)
Backend image (backend/Dockerfile)
- two stages: build-essential builder produces a venv, slim runtime carries only
the venv (no compilers), runs as non-root user `app`
- docker-entrypoint.sh: optional DB wait -> `alembic upgrade head` -> exec CMD
- app/cli/wait_for_db.py: retry loop with timeout so the API no longer
crash-loops when Postgres is still starting (run as a module so `app` is
importable inside the container)
- HEALTHCHECK on /api/v1/health/live, uvicorn with proxy headers
Frontend image (frontend/Dockerfile)
- node:22-alpine builds the SPA with `yarn install --frozen-lockfile && yarn build`
- nginx:1.27-alpine serves dist, HEALTHCHECK via wget
- nginx.conf: history fallback, immutable caching for hashed assets, no-cache for
index.html, and a reverse proxy for /api, /docs, /redoc using Docker DNS with a
resolver variable so nginx still boots when the backend is down
Compose stack (docker-compose.yml)
- postgres:17-alpine with pg_isready healthcheck and a named volume
- backend built from ./backend, gated on `service_healthy`, DATABASE_URL composed
from POSTGRES_* so credentials stay in sync with the database service
- frontend published on ${FRONTEND_PORT}, all ports/credentials from .env
- documented external-database path via a git-ignored docker-compose.override.yml
Verification
- compose YAML parsed and asserted (services, deps, ports, no nested ${} defaults)
- `sh -n` clean for the entrypoint; `python -m app.cli.wait_for_db` tested against
SQLite (ready, exit 0) and an unreachable Postgres (retries, exit 1)
- ruff clean on the new CLI module
- NOTE: no Docker CLI in this environment, so images were not built here.
- git repo on main branch
- .gitignore for Python/FastAPI + Node/Vue + env + Docker
- .gitattributes with LF normalization for container-safe text files
- .editorconfig, VS Code recommendations and settings example
- root .env.example documenting Compose variables