How prajvalrasik/healthos-web works
Project Type and Purpose
• HealthOS is a full-stack web application (Next.js v15 + TypeScript) for health data management.
• Frontend delivers UI and routing via the Next.js App Router.
• Backend relies on Supabase (PostgreSQL + Auth + Storage + Edge Functions) and several Third-Party APIs (Google Fit, OpenAI).
File Structure Analysis
• src/app/api: Next.js API routes (chat, google-fit, health, lab-reports, etc.).
• src/app/dashboard & src/app/settings: React pages and UI components for end-user flows.
• src/components/ui: Reusable UI primitives (buttons, cards, inputs).
• src/lib: Utilities (Supabase client, encryption, OpenAI LLM wrapper).
• supabase/functions: Edge Functions for heavy tasks (hardDelete, parseLabReport).
• supabase/migrations: SQL migrations for the database schema.
README Insights
• Authentication & Security (Supabase Auth + RLS + GDPR flows).
• Google Fit Integration (OAuth + real-time sync).
• Lab Report Processing (PDF upload → AI extraction → storage).
• AI Health Assistant (RAG chat using OpenAI + user data).
• Deployment targets (Vercel for frontend, Supabase CLI for Edge Functions).
Main Components
a. Client (Browser / Next.js Frontend)
b. Next.js Server (App Router + API Routes on Vercel)
c. Supabase Backend
• Auth
• PostgreSQL Database
• Storage (PDFs, images)
• Edge Functions (hardDelete, parseLabReport)
d. External Services
• Google Fit API (OAuth exchange, data fetch)
• OpenAI API (chat completions, document processing)
e. CI/CD / Deployment Platforms
• Vercel (Front + API routes)
• Supabase CLI (Edge Functions)
Relationships & Data Flow
• Browser ↔ Next.js (SSR/SSR, client-side routing).
• Next.js API Routes ↔ Supabase services (via supabase-js client).
• Edge Functions ↔ Supabase Database & Storage (server-side tasks).
• Next.js & Edge Functions ↔ Google Fit & OpenAI over HTTPS.
• Database tables with RLS policies protect user data.
Architectural Patterns & Principles
• Jamstack style: Pre-rendered UI with dynamic API routes.
• Microservices-style separation: Next.js API vs. Supabase Edge Functions.
• Client-server separation: UI components vs. business logic in API.
• Security by design: Row-Level Security, GDPR soft deletes.
• Eventual consistency: Deferred cleanup via edge functions.
Technologies & Frameworks
• Frontend: Next.js (App Router), React, Tailwind CSS, VisX charts.
• Backend: Supabase (Auth, Postgres, Storage), supabase-js, Edge Functions.
• AI: OpenAI GPT-4, RAG patterns.
• OAuth: Google Fit via Google Cloud Console.
• Deployment: Vercel, Supabase CLI.
Essential Elements
• Labels: Clear names (e.g., “Next.js API Route: /api/process-lab-report”)
• Security Notes: Mark RLS boundary at database, note GDPR grace period step.