How the server side of this app is built
app.py, database.py, and fhir_service.pyrequirements.txt and installed with pippython-dotenv librarypytest and run locally and in CI@app.route()render_template() — serving HTML files from templates/jsonify() — serving JSON data consumed by JavaScriptapp.py covering pages, diary APIs, FHIR, summaries, and emaildatabase.py — a custom Database classDATABASE_URL environment variabledatabase.py code works for both — it detects which one to use automaticallyentries (diary), summaries, settingsProcfile: web: gunicorn app:appgunicorn, find the Flask app object named app in app.pygit push heroku mainrequirements.txt, and starts Gunicorn automaticallyhttps://j4h-be058543801b.herokuapp.com — also served at https://j4h.org via Cloudflare/api/summary endpoint sends diary entries to Claude and returns a plain-language medical summaryanthropic Python library with the claude-haiku modelANTHROPIC_API_KEYsummaries database table for reuse/api/email-summary endpointfhir_service.py — a FHIRService classfhirclient Python library handles authentication and resource parsing/vitals page/health-record pagesettings tablesmtp.gmail.com, port 587, TLS)MAIL_USERNAME, MAIL_PASSWORD/api/email-summary) and exporting encrypted history (/api/send-history).j4h file — the server only handles ciphertext, never plaintext entries
A single app.py file contains all Flask routes. It talks to PostgreSQL via database.py,
reads FHIR health records via fhir_service.py, and calls the Claude API for AI summaries.
Gunicorn runs Flask in production. Heroku hosts everything. The backend never sees plaintext diary entries —
only the encrypted ciphertext stored in the database.