Skip to content

Techdude01/Verdia---Hack-Princeton-Spring-26

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Verdia

Healthcare-fintech dashboards that turn food purchases into real-time metabolic risk and premium adjustments.

Overview

Verdia is built for two audiences:

  • Patients who need clear, event-level score explanations.
  • Insurers who need cohort-level signal before claims lag catches up.

Why it exists: static wellness discounts are blunt. Verdia links verified purchase behavior to dynamic scoring and pricing so intervention can happen earlier.

Demo / Screenshots

  • Live app (local): http://localhost:3000
  • API docs: http://localhost:8000/docs

Features

  • Real-time patient score updates (Socket.IO)
  • Food-event reasoning with K2 Think + Tavily lookup
  • Image-based food capture via local Ollama (Gemma 4B) that feeds the same scoring pipeline
  • 7-day rolling risk score + ADA risk banding
  • Premium adjustment logic + mock EDI 835 remittance output
  • Role-based dashboards (patient, insurer)

Installation

cp .env.example .env
docker compose up --build

For fully local infra (Postgres + Redis included):

docker compose --profile local up --build

Usage

Start and seed demo data:

docker compose up --build
docker compose exec api python -m scripts.seed_demo

Then open http://localhost:3000, sign in, and use:

  • Patient view: score, food timeline, trends
  • Insurer view: cohort heatmap, claims impact, remittance log

Configuration

Required/important env vars:

Variable Required Notes
DATABASE_URL Yes Use postgresql+psycopg://... (Supabase: keep sslmode=require)
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY Yes (auth) Clerk frontend key
CLERK_SECRET_KEY Yes (auth) Clerk backend key
CLERK_JWKS_URL Yes (auth) JWT verification
K2THINK_API_KEY No If empty, heuristic scorer is used
K2THINK_MAX_OUTPUT_TOKENS No Caps K2 completion size for faster responses (default 120)
K2THINK_MAX_CONCURRENT_REQUESTS No Throttles concurrent K2 calls to reduce burst failures (default 3)
OLLAMA_API_URL No Local Ollama chat endpoint for vision parsing (http://localhost:11434/api/chat, Docker-to-host often http://host.docker.internal:11434/api/chat)
OLLAMA_VISION_MODEL No Local vision model (default gemma4:e4b)
OLLAMA_VISION_TIMEOUT_SECONDS No Per-attempt timeout budget for local vision calls (default 120)
OLLAMA_VISION_MAX_RETRIES No Retry count with backoff for local vision calls (default 3)
VISION_MAX_CONCURRENT_REQUESTS No Throttles concurrent vision calls for better multi-user stability (default 2)
VISION_CONFIDENCE_THRESHOLD No Below this, image flow requires user confirmation before scoring (default 0.50)
VISION_BACKEND No Toggle for the vision model: ollama (local, default), lmstudio (local OpenAI-compatible), or gemini (cloud Gemma via Gemini API, 1500 free RPD on Gemma 4)
GEMINI_API_KEY No Required when VISION_BACKEND=gemini. Get one at https://aistudio.google.com/apikey
GEMINI_VISION_MODEL No Cloud Gemma model name (default gemma-4-31b-it)
TAVILY_API_KEY No Improves branded/ambiguous product lookup
REDIS_URL No Enables realtime pub/sub fanout
KNOT_CLIENT_ID / KNOT_SECRET / KNOT_WEBHOOK_SECRET No Knot sandbox integration. Without them, POST /patient/knot/session returns a stub.
NEXT_PUBLIC_API_URL / NEXT_PUBLIC_WS_URL Yes (frontend) Where the browser hits the API + Socket.IO. Use http://localhost:8000 locally, or your ngrok HTTPS URL when demoing.

ngrok for mobile/demo

ngrok http 3000
ngrok http 8000

Use the 3000 URL in your phone browser. Set NEXT_PUBLIC_API_URL and NEXT_PUBLIC_WS_URL to the 8000 URL.

API Reference

Core routes:

  • GET /health — API health check
  • POST /patient/food — create food event and trigger scoring pipeline
  • POST /patient/food/image — upload/take photo, extract schema {is_food, confidence, items[], serving_unit, notes} with local Ollama vision; low-confidence detections return requires_confirmation before scoring
  • POST /patient/knot/session — create Knot session (stub if creds missing)
  • GET /insurer/cohort — cohort metrics
  • GET /insurer/claims — claims/remittance history
  • POST /webhook/knot — Knot webhook ingestion

Socket events:

  • score_update
  • cohort_member_update

Architecture Diagram

%%{init: {"flowchart": {"curve": "linear", "nodeSpacing": 40, "rankSpacing": 55}} }%%
flowchart TB
  U[Users: Patient / Insurer] --> W[Frontend: Next.js 15 + Clerk]
  W -->|REST API + Socket.IO| A[Backend: FastAPI + python-socketio]
  A -->|score_update, cohort_member_update| W

  subgraph Providers["Providers & Integrations"]
    C[Clerk Auth]
    K[Knot API]
    AI[K2 Think + Tavily]
  end

  subgraph Data["Data Layer"]
    P[(PostgreSQL)]
    R[(Redis pub/sub)]
  end

  W -->|Auth session| C
  C -->|JWT / JWKS| A
  K -->|Transaction webhook| A
  A -->|Food scoring requests| AI
  A --> P
  A --> R
  R -->|Realtime fanout| A
Loading

Project Structure

api/
  app/
    routers/
    scoring/
    insurance/
    realtime/
  scripts/
web/
  app/
  components/
  lib/
docker-compose.yml
README.md

Contributing

Pull requests are welcome. For major changes, open an issue first so scope and direction stay aligned.

Testing

docker compose exec api pytest

Future Changes

  • Edge CV verification of consumption (smart-bin)
  • ZK proof of healthy compliance
  • Nutrition-embedding generalization
  • React Native mobile app
  • Real EDI 835 transmission to clearinghouses

License

License not specified yet.

Acknowledgments

  • Clerk (auth)
  • Knot (transaction linking)
  • K2 Think + Tavily (AI reasoning and lookup)
  • FastAPI + Next.js ecosystem

About

Verdia turns healthy eating into a better deal for all: diabetic patients eat better while paying less, and insurers face lower risk + make smarter pricing decisions. Healthier lives, lower costs.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors