How it works, end to end
This page follows the moving parts in order: what .\vesper does, what a fresh database goes through, and what happens when the app asks for a trip. Each section links to the page that owns the detail.
1. The .\vesper task runner
vesper.cmdis the entry point. In PowerShell,.\vesperfindsvesper.cmdbecause there is novesper.ps1in the root. The.cmdfile starts PowerShell with-ExecutionPolicy Bypass, so it works on machines where scripts are blocked.scripts/vesper.ps1does the work. The first argument picks the command, and everything after it is passed through untouched. So.\vesper test -k tripsrunspytest -k trips, and.\vesper frontend -crunsexpo start -c.- Every native command is checked. PowerShell 5.1 doesn't stop when
docker,alembicorpytestfail, so the script checks each exit code and stops at the first failure.vesper.cmdpasses the exit code on to your terminal. - Commands run in the right folder. Backend commands run in
apps/backend, so Alembic findsalembic.ini. Expo runs inapps/frontend.
Daily development lists every command.
2. What .\vesper setup builds
- Roles are created once. Postgres runs
apps/backend/db/init/only when the data volume is new. If you change that script, run.\vesper db-destroyand then.\vesper setup. - The health check runs over TCP on purpose. During first-run init, Postgres listens only on its socket, so a TCP check can't pass until the roles exist.
- The two roles have different rights.
vesper_migratorowns the schema and is the only role that can run DDL.vesper_appcan only read and write rows, and a test checks that it can't create tables. See Database → Roles. - Setup is safe to rerun. Existing
.envfiles are kept, and a database that already has data isn't reseeded.
3. A request, from screen to row
The screens still read the sample data in apps/frontend/src/data/trips.ts. Steps 1 and 6 describe how they'll call the API once it's wired up. Steps 2 to 5 work today: try curl http://localhost:8000/trips.
- The app calls
GET /tripson the URL inapps/frontend/.env. The right URL depends on where the app runs; see Daily development. - FastAPI opens a database session as
vesper_appthrough theget_sessiondependency. The session closes when the request ends. - The API loads the trips, then the members of all of them in one query, so the number of queries doesn't grow with the number of trips.
TripOutturnsstart_dateintostartDate, and so on, so the JSON matches the frontend'sTriptype exactly. A test (test_get_trip_matches_frontend_shape) fails if the shape drifts.- An unknown id returns
404, and an id that isn't a UUID returns422. - The app renders the same data it renders from the sample file today. The seed data matches that file, so nothing visible changes when the screens switch to the API.
4. Settings and startup
uvicorn app.main:app reads apps/backend/.env from an absolute path, so it works from any folder. It checks the settings at startup, so a missing DATABASE_URL stops the server immediately instead of failing on the first request. GET /health runs SELECT 1 and returns 200, or 503 if Postgres is unreachable. See Backend overview.
5. Tests
.\vesper test starts Postgres, applies migrations, then runs pytest. The tests use the real local database, not a mock:
- The
sessionfixture rolls back. It opens a transaction and rolls it back at the end of each test, so tests can run against your seeded data without changing it. - API tests share that session. They point
get_sessionat the test's session, so the API sees the test's rows and the rollback removes them afterwards. - Schema tests run against Postgres itself. They check that the
end_date >= start_dateconstraint holds, thatvesper_appcan't run DDL, and that/healthreturns 503 when the database is down.
6. Changing things
| You change | Also do | Details |
|---|---|---|
| A model | .\vesper makemigration "msg", read the file, .\vesper reset-db | Database → Changing the schema |
| An API response | Keep it matching the frontend type; update the shape test | Database → How it maps |
| An env var | Add it to .env.example and the settings table | Backend overview |
A .\vesper command | Keep it PowerShell 5.1-compatible; update the command table | Daily development |
| How or why something works | Update the page in the same PR; add an ADR for decisions | Writing docs |
How these docs work
This site is Docusaurus and lives in docs/ as its own npm project (see ADR 0002).
- Pages are Markdown files in
docs/docs/. Each folder is a sidebar section, ordered by its_category_.json, andsidebar_positionorders the pages inside it. - Diagrams are Mermaid code blocks, so they're reviewed as text in PRs.
- Broken links fail the build. Use relative
.mdlinks;.\vesper docs-buildfails on any link that points nowhere. - Run it locally with
.\vesper docs(http://localhost:3000). The page reloads as you save. - AI assistants read these pages. The root
CLAUDE.mdsends Claude Code here first, so keeping these pages current keeps the AI following the same conventions.