Repository navigation
Integrate full GoldenHour app into main (backend + frontend) - #1
Merged
Merged
Conversation
Build out the GoldenHour backend per the backend PRD, replacing the stub endpoints and empty service files with a working, tested service. Core: - Thin FastAPI routes (main.py) -> services/ -> store.py data layer - schemas.py mirrors API_CONTRACT.md exactly (incl. SMS "from" alias) - Three algorithms: hospital ranking (prox/dept/rel score), blood matching (ABO table + 5km radius + 90-day cooldown), confirmation race resolution (first-to-accept wins, already_confirmed) - Emergency orchestration + live status with simulated donor responses Data layer (two interchangeable stores behind get_store()): - InMemoryStore seeded with 25 Jaipur hospitals + 180 donors (demo/CI) - SupabaseStore using PostGIS donors_nearby RPC; auto-fallback on init failure so boot never breaks - sql/schema.sql: PostGIS tables, GiST indexes, donors_nearby() RPC - seed_supabase.py to load the same dataset into a real DB Infra & docs: - Dockerfile, docker-compose.yml, .env.example, .gitignore - CI wired to actually run pytest (3.11/3.12); pr-guard checks for conflict markers - README (root/backend/frontend), index.html meta/description/OG tags - 24 pytest tests (algorithms + endpoint contract + live flow + SupabaseStore via fake client), all passing offline Co-Authored-By: Claude Opus 4.8 <[email protected]>
Declare SUPABASE_URL (required alongside SUPABASE_ANON_KEY to enable the real database), plus FRONTEND_URL and CORS_ORIGINS, so a production deploy uses Supabase instead of silently falling back to demo mode. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Production-readiness improvements to the backend/database path: - Prefer SUPABASE_SERVICE_KEY for the backend connection (bypasses RLS), falling back to the anon key; wire into config + store + render.yaml + .env.example - Add sql/seed.sql (generated by build_seed_sql.py) so the DB can be seeded from the Supabase SQL editor as table owner — avoids anon-key RLS friction - Add GET /ready: pings the data layer (503 if unreachable) so a deploy can be verified as truly DB-connected vs silently in demo mode - Document RLS model in schema.sql (default-off + production hardening) - Add DEPLOY.md: full Render + Supabase runbook (demo vs database mode) - Tests now 26 (add /ready + ping coverage); docs updated Co-Authored-By: Claude Opus 4.8 <[email protected]>
- Gate hospital rel(h) on >=20 logged confirmations and renormalize the ranking to proximity + department until then, so a fresh deployment ranks on prox+dept only instead of trusting seeded reliability it hasn't earned. - Dispatch blood-needed alerts to the nearest top-K matched donors with an explicit "licensed blood bank, not the emergency ward" directive; expose recently sent alerts at GET /dev/alerts. - Make the donation cooldown sex-aware (90 days men / 120 days women) via an optional `sex` field on donor registration; absent it, defaults to 90 days. - Add rare_group (Rh-negative) to the /emergency response and unconfirmed_fallback to the /status response. - Update API_CONTRACT, backend README, .env.example, and the SQL schema/seed to match; add 4 tests (30 total, all offline).
Reject lat outside -90..90 and lng outside -180..180 with 422 instead of computing distances from a failed or spoofed browser geolocation. Applies to POST /emergency and POST /donor/register; documented in API_CONTRACT.
- Add docs/ with banner, request-flow, and architecture SVGs; embed them in the root README (banner + badges, diagrams replacing the ASCII art) and the architecture diagram in the backend README. - Enrich FastAPI/OpenAPI: summary, contact, MIT license, per-tag-group descriptions, and a summary on every route so /docs is fully described. - Refresh the root README API table with the current endpoints and flags.
…nd build shared component library
…orting and status animation
…erage geolocation lock
…conditional header and already_routed simulation
# Conflicts: # frontend/index.html
…s, and route transition animations
…upabase Realtime channel updates
…fix Supabase realtime table subscriptions
…nd compile preloader
…pdate frontend package-lock
The frontend confirmation page needs the real emergency details (hospital name, type, blood group, this hospital's ETA) on load. Without a GET it always fell back to placeholder data. Adds the endpoint, documents it in API_CONTRACT.md, and covers it with tests.
donors_alerted was hardcoded to 5; now driven by the API response on every status poll. Adds a web app manifest, branded maskable icons, and a production-only service worker for offline app-shell support, fulfilling the PWA claim in the deck and README.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Brings the complete GoldenHour application from
integrationintomain.mainis a strict ancestor ofintegration, so this is a clean catch-up of the whole app.What's included
Backend (FastAPI, Python 3.12)
API_CONTRACT.md:POST /emergency,GET /emergency/{id}/status,GET /confirm/{token},POST /confirm/{token},POST /donor/register,POST /sms/inbound, plus/health,/ready, and the/dev/links·/dev/alertsdemo helpers.get_store():InMemoryStore(zero-dependency demo/CI) andSupabaseStore(PostgreSQL + PostGIS).P(h) = 0.5·prox + 0.3·dept + 0.2·relwith a cold-start reliability gate.donors_nearbyRPC + GiST index), sex-aware donation cooldown (90/120 days).Frontend (React 19, Vite, Tailwind)
Infra
docker-compose.yml), Render (render.yaml), Vercel (vercel.json), GitHub Actions CI.Audit-driven additions (this PR)
A gap analysis against both PRDs and the pitch deck closed three real gaps:
GET /confirm/{token}— the confirmation page now shows the real emergency details on load instead of placeholder data.donors_alertedon the results screen is now driven by the API (was hardcoded to 5).Testing