COMPASS: FxRates
Compass
Build a currency rates service, an executable named fxrates at the application root, as described in sources/INSTRUCTIONS.md. A command line loads the ECB euro reference rate history into SQLite, and a FastAPI JSON API serves the rates on a date, conversions between any two currencies, and a currency's history with minimum, maximum, and mean.
Correctness is measured by sources/run.sh: it loads the supplied ECB files, starts the server on a free local port, and makes 35 checks of command output and HTTP status and JSON body. The goal is every check passing.
Constraints
- Implement in Python 3.11 or newer with FastAPI and uvicorn over SQLite.
- Provide an executable named
fxratesat the application root, invoked as./fxrates <command>.
fxrates serve runs the server in the foreground and stops cleanly on SIGTERM.
- Read the database location from
DATABASE_URL, thenDATABASE_PATH, thendata/app.db. - Store rates as the ECB's published text; compute with
decimal, never with floating point. - Check a file in full before its first write.
- Tests stub the ECB download; no test opens a network connection.
- Diagnostics go to standard error and are never compared.
Guardrails
- Do not modify, rewrite, regenerate, or substitute any file under
sources/. - Do not read
sources/run.shor any supplied data file from application code. Data reaches the
database only through fxrates load or fxrates fetch.
- Do not hardcode a rate, a date, a count, or a computed value. Every value comes from a query.
- Do not open a database driver outside the shipped persistence library.
Verification Protocol
| Story kind | Command | Asserts |
|---|---|---|
| Every behavioral story | sh bin/test.sh | exit 0 |
| Terminal story (once, last) | sh sources/run.sh | exit 0 |