How cubestar1/health-monitor-next works
Project Type and Purpose
• HealthHub is a full-stack, AI-powered health data management platform.
• Frontend: Next.js 13 App Router (TypeScript/React)
• Backend: Next.js serverless API routes + external FastAPI (Python) service
• Data store: Supabase (PostgreSQL + pgvector)
• AI/ML: Langchain, OpenAI, Cohere embeddings, Gemini, HeyGen video
File Structure
• app/ → Next.js pages & server components (app-router layout)
• app/api/.../route.ts → Next.js serverless endpoints
• app/(auth), (chat), (health), (marketing) → route groups for major UX flows
• components/, hooks/, lib/ → UI pieces, custom React hooks, configuration & Supabase clients
• public/ → static assets (images for landing, dashboards)
• actions/ → NextAuth/Supabase auth handlers
• No direct Python code here; the README points to a separate FastAPI repo
README Insights
• Real-time sensor data from Arduino/ESP8266 → streams into Supabase
• Medical-record ingestion pipeline (PyPDF2, Tesseract OCR) → Cohere embeddings → vector DB
• RAG pipeline via Langchain for chat assistant
• External integrations: Strava, Nutritionix, Tavily, Resend, HeyGen
Main System Components
a. Client Layer
• Web browser (React UI)
• Mobile Web / PWA
• Edge devices: Arduino/ESP8266 (sensor data producer)
b. Frontend Layer
• Next.js App (UI pages, layouts, global providers)
• React hooks and context for state, real-time subscriptions (Supabase JS)
c. API Layer (Next.js Serverless)
• app/api routes for chat, nutrition, health-reports, Strava, signup, RAG queries
• Auth middleware (Supabase)
• Proxy to Python FastAPI for heavy AI tasks
d. Backend Layer
• External FastAPI service
– Chat operations & RAG orchestration (Langchain)
– Medical record processing, embedding generation
e. Data Layer
• Supabase PostgreSQL + pgvector (vector DB extension)
• Supabase Auth
f. External Services
• AI: OpenAI, Cohere, Gemini, HeyGen
• Health APIs: Nutritionix, Strava, Tavily
• Email: Resend
Component Interactions
• Browser ↔ Next.js UI (React Server/Client components)
• UI ↔ Next.js API routes (REST/Route handlers)
• API routes ↔ Supabase (via server/client SDK) for real-time reads & writes
• API routes ↔ FastAPI backend (HTTP calls) for AI pipelines
• FastAPI ↔ External AI services (OpenAI, Cohere, Tavily, HeyGen)
• Arduino/ESP8266 → Supabase (direct PostgreSQL inserts or via an ingestion endpoint)
• UI ↔ External APIs (Strava OAuth & data) via dedicated API routes
Architectural Patterns & Principles
• Layered separation: UI / API / Backend / Data
• Serverless micro-endpoints (Next.js Route handlers)
• RAG microservice for AI tasks (FastAPI)
• Real-time event-driven flows via Supabase subscriptions
• Componentization in Next.js App Router (route groups & folders)
Technologies & Frameworks to Highlight
• Next.js 13 App Router, React Server Components
• Supabase JS & server SDK, Supabase Auth
• FastAPI (Python), Uvicorn
• Langchain RAG pipeline
• Vector DB (pgvector), Cohere embeddings
• OpenAI, Gemini, Tesseract, PyPDF2, Nutritionix, Tavily, HeyGen, Resend