Thermograph monorepo: graded-climate API + SSR frontend + infra, domain-specific containerized deploys
Find a file
Emi Griffith 41e84060ab Link a Thermograph account to Discord via OAuth2 (#208)
Lets a signed-in user connect their Discord account (OAuth2 identify), storing the
Discord user id that a later feature (DM alerts) will deliver to. Standard
authorization-code flow, all server-side:

- backend/discord_link.py: /discord/link/start redirects to Discord's consent
  screen; /discord/link/callback exchanges the code, reads the Discord user id, and
  stores it; /discord/unlink forgets it. The `state` is signed with the app auth
  secret (stdlib hmac, no new dependency) and carries the Thermograph user id, so a
  callback can't be replayed or bound to another account. Every route requires an
  active session, so linking acts on whoever is actually logged in.
- models.py: User.discord_id (unique, nullable). schemas.py exposes it on UserRead
  so the frontend can show link state.
- app.py: the router under /api/v2/discord.
- account.js: a "Link Discord" / "Unlink Discord" control in the account popover.
- deploy/migrations/001-user-discord-id.sql: the manual column add for the existing
  prod accounts DB. This project has no Alembic — create_all only makes missing
  tables, so an added column needs a hand-applied migration (documented in-file).
- env example: THERMOGRAPH_DISCORD_CLIENT_SECRET + the redirect to register.

Claude-Session: https://claude.ai/code/session_013dRZmX9D3JEntfMKWMTWZ8
2026-07-20 02:26:33 +00:00
templates Remove em-dashes from site copy and tighten the prose (#206) 2026-07-20 01:48:33 +00:00
tests Link a Thermograph account to Discord via OAuth2 (#208) 2026-07-20 02:26:33 +00:00
api_accounts.py Push: surface delivery failures (no longer a silent success) (#157) 2026-07-17 00:12:14 +00:00
app.py Link a Thermograph account to Discord via OAuth2 (#208) 2026-07-20 02:26:33 +00:00
audit.py Dashboard: accounts totals only; log client IPs per request (#140) 2026-07-16 21:58:40 +00:00
cities.json SEO: values filter — trim cities in anti-LGBTQ countries, keep notable hubs (#102) 2026-07-16 02:20:41 +00:00
cities.py Lead climate page titles with the city and the payload (#188) 2026-07-19 18:17:13 +00:00
cities_flavor.json SEO: values filter — trim cities in anti-LGBTQ countries, keep notable hubs (#102) 2026-07-16 02:20:41 +00:00
city_events.py Remove em-dashes from site copy and tighten the prose (#206) 2026-07-20 01:48:33 +00:00
climate.py Remove em-dashes from site copy and tighten the prose (#206) 2026-07-20 01:48:33 +00:00
content.py Remove em-dashes from site copy and tighten the prose (#206) 2026-07-20 01:48:33 +00:00
db.py Fix mobile alerts dropdown overflow; add account API tests (#93) 2026-07-15 22:00:47 +00:00
digest.py Remove em-dashes from site copy and tighten the prose (#206) 2026-07-20 01:48:33 +00:00
discord.py Remove em-dashes from site copy and tighten the prose (#206) 2026-07-20 01:48:33 +00:00
discord_interactions.py Serve a /grade Discord slash command over HTTP interactions (#207) 2026-07-20 02:19:29 +00:00
discord_link.py Link a Thermograph account to Discord via OAuth2 (#208) 2026-07-20 02:26:33 +00:00
gen_cities.py SEO: values filter — trim cities in anti-LGBTQ countries, keep notable hubs (#102) 2026-07-16 02:20:41 +00:00
gen_flavor.py SEO: expand city set to 1000 (extended English-speaking / high-proficiency) (#99) 2026-07-16 01:14:30 +00:00
grading.py Render every percentile through one rule (#186) 2026-07-18 09:08:28 +00:00
grid.py Warm neighbor cells server-side (/cell?neighbors=1) (#51) 2026-07-11 20:47:31 +00:00
homepage.py Render every percentile through one rule (#186) 2026-07-18 09:08:28 +00:00
indexnow.py Auto-submit IndexNow on deploy when the URL set changes (#130) 2026-07-16 13:38:59 -07:00
mailer.py Rebuild the homepage as a distribution landing; add an SMTP seam (#178) 2026-07-18 07:39:47 +00:00
metrics.py Rebuild the homepage as a distribution landing; add an SMTP seam (#178) 2026-07-18 07:39:47 +00:00
migrate.py Migrate backend dataframe layer from pandas to polars (#90) 2026-07-15 19:07:38 +00:00
models.py Link a Thermograph account to Discord via OAuth2 (#208) 2026-07-20 02:26:33 +00:00
notify.py Remove em-dashes from site copy and tighten the prose (#206) 2026-07-20 01:48:33 +00:00
places.py Move the suggestion policy into places.py (#45) 2026-07-11 20:00:24 +00:00
push.py Push: surface delivery failures (no longer a silent success) (#157) 2026-07-17 00:12:14 +00:00
requirements-dev.txt Add backend test suite; gate direct pushes; serialize LAN deploys (#41) 2026-07-11 19:37:49 +00:00
requirements.txt Serve a /grade Discord slash command over HTTP interactions (#207) 2026-07-20 02:19:29 +00:00
schemas.py Link a Thermograph account to Discord via OAuth2 (#208) 2026-07-20 02:26:33 +00:00
scoring.py Remove em-dashes from site copy and tighten the prose (#206) 2026-07-20 01:48:33 +00:00
singleton.py Gate the subscription notifier to one worker (#161) 2026-07-17 12:54:55 +00:00
store.py Compare/calendar mobile polish: overflow fix, sheet load button, 6-yr default, country in names (#80) 2026-07-12 06:32:10 +00:00
users.py Account system with weather-notification subscriptions (#89) 2026-07-15 18:46:46 +00:00
views.py Score each metric on the average of its seasonal differentials (#200) 2026-07-19 23:57:55 +00:00
warm_cities.py Rebuild the homepage as a distribution landing; add an SMTP seam (#178) 2026-07-18 07:39:47 +00:00