An async REST backend for tracking blood-pressure measurements and medication prescriptions/intake. A Python/FastAPI rebuild of an earlier C# service.
- FastAPI (
fastapi[standard]) - SQLModel over async SQLAlchemy 2.0
- psycopg3 (async driver)
- PostgreSQL 18
- Alembic for migrations
- PyJWT for stateless access tokens
- py_webauthn for passkey/WebAuthn authentication
- Managed with uv, linted with ruff
- Tested with pytest + pytest-asyncio
Prerequisites: uv and Docker.
# 1. Bring up PostgreSQL (single service, see compose.yaml)
docker compose up -d
# 2. Copy the env template and fill in real values
cp .env.example .env
# 3. Apply database migrations
uv run alembic upgrade head
# 4. Run the app
uv run fastapi dev main.py
# 5. Run tests (uses a separate <POSTGRES_DB>_test database)
uv run pytest- auth — magic-link and WebAuthn/passkey authentication, JWT access/refresh
tokens, session management. All other endpoints require an
Authorization: Bearer <token>header. - users — user profile (
GET /users/me,PATCH /users/me,DELETE /users/me). - measurements — blood-pressure readings (systolic/diastolic/pulse). Plain CRUD
plus photo recognition via Gemini API (
POST /measurements/analyze). - prescriptions — a prescription (doctor, date, active flag) with its medication items (dose, frequency, time-of-day slots, course).
- reminders — per-user reminder configuration (slot times) and an append-only log of confirmed medication intakes.
- export — CSV and print-ready PDF export of measurement history (with optional date range), delivered via email.
- email_infra — SMTP delivery and async email outbox with retries.
- cleanup — background worker for expired magic links, challenges, and sessions.
See README_DEV.md for design rationale, technical debt, and the API contracts consumed by the frontend/native client.