# nikhil-coder390/hernest architecture

> Architecture diagram of the GitHub repository nikhil-coder390/hernest, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-10-05). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/nikhil-coder390/hernest
- Repository: https://github.com/nikhil-coder390/hernest

## Overview

##### Project type and purpose
- HerNest is a full-stack, single-page web application for menstrual cycle tracking, AI health guidance, and online doctor consultations.
- Frontend: React + TypeScript (Vite, Tailwind CSS).
- “Backend”: Supabase (Auth, Database, Edge Functions) with migrations in the repo. The README also references a Node.js + Express layer (not shown in this tree), plus external services: OpenAI API for chatbot, payment gateway, video‐consultation links.

##### File structure
- Top‐level: configuration files (tsconfig, eslint, tailwind, Vite).
- src/
- App.tsx + main.tsx: entrypoints.
- components/: shared UI (DashboardLayout, Navbar, NotificationBell).
- pages/: route components (Auth, Home, BookAppointment, Chat, DoctorDashboard, PatientDashboard, HealthRecords, Prescriptions, Profile, Payment).
- lib/: client abstractions (supabase client, global store).
- types/: TypeScript types for database schema.
- supabase/migrations/: SQL files pushing schema changes.
- No visible Express server code in this tree—likely separate or in Supabase Edge Functions.

##### Key insights from README
- Core flows:
- User registration & login (Supabase Auth).
- Period logging (Supabase DB).
- AI chatbot queries (OpenAI).
- Appointment booking & payment (Payment API).
- Video consultation link generation (external video service).
- Security & compliance: HIPAA/GDPR.

##### Detail
- Break the client into sub-components if needed (e.g., Auth module, Chat module, Appointment module).
- Global store as a connector between UI components and API calls.
- Migrations folder to indicate continuous schema evolution.
- Security: annotate the Auth flows, JWT tokens, and compliance boundary (HIPAA/GDPR).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Side
    subgraph "Client Side"
        direction TB
        Main["main.tsx"]:::frontend
        App["App.tsx"]:::frontend
        subgraph "Shared UI Components"
            direction TB
            DashboardLayout["DashboardLayout"]:::frontend
            Navbar["Navbar"]:::frontend
            NotificationBell["NotificationBell"]:::frontend
        end
        subgraph "Pages"
            direction TB
            AuthPage["Auth"]:::frontend
            HomePage["Home"]:::frontend
            PatientDashboardPage["PatientDashboard"]:::frontend
            DoctorDashboardPage["DoctorDashboard"]:::frontend
            HealthRecordsPage["HealthRecords"]:::frontend
            ChatPage["Chat"]:::frontend
            BookAppointmentPage["BookAppointment"]:::frontend
            PaymentPage["Payment"]:::frontend
            PrescriptionsPage["Prescriptions"]:::frontend
            ProfilePage["Profile"]:::frontend
        end
        Store["Global State Store"]:::frontend
        SupaClient["Supabase Client"]:::frontend
        Types["DB Schema Types"]:::frontend
    end

    %% Server Side
    subgraph "Server Side"
        direction TB
        SupabaseAuth["Supabase Auth"]:::backend
        SupabaseDB["Supabase Database"]:::backend
        Migrations["Supabase Migrations"]:::backend
        EdgeFuncs["Edge Functions / Express"]:::backend
    end

    %% External Services
    subgraph "External Services"
        direction TB
        OpenAI["OpenAI API"]:::external
        PaymentGateway["Payment Gateway"]:::external
        VideoService["Video Consultation"]:::external
    end

    %% Connections
    Main -->|imports| App
    App -->|renders| DashboardLayout
    App -->|renders| Navbar
    App -->|renders| NotificationBell
    App -->|routes to| AuthPage
    App -->|routes to| HomePage
    App -->|routes to| PatientDashboardPage
    App -->|routes to| DoctorDashboardPage
    App -->|routes to| HealthRecordsPage
    App -->|routes to| ChatPage
    App -->|routes to| BookAppointmentPage
    App -->|routes to| PaymentPage
    App -->|routes to| PrescriptionsPage
    App -->|routes to| ProfilePage

    AuthPage -->|uses| SupaClient
    HomePage -->|uses| SupaClient
    PatientDashboardPage -->|uses| SupaClient
    DoctorDashboardPage -->|uses| SupaClient
    HealthRecordsPage -->|uses| SupaClient
    ChatPage -->|calls| OpenAI
    BookAppointmentPage -->|invokes| EdgeFuncs
    PaymentPage -->|invokes| EdgeFuncs
    ProfilePage -->|uses| SupaClient

    Store -->|provides state to| AuthPage
    Store -->|provides state to| HomePage
    SupaClient -->|auth & CRUD| SupabaseAuth
    SupaClient -->|CRUD| SupabaseDB
    SupabaseAuth -->|JWT| App
    SupabaseDB -->|data| App

    EdgeFuncs -->|POST /book-appointment| PaymentGateway
    EdgeFuncs -->|GET video-link| VideoService

    Migrations -->|schema updates| SupabaseDB

    %% Click Events
    click Main "https://github.com/nikhil-coder390/hernest/blob/master/src/main.tsx"
    click App "https://github.com/nikhil-coder390/hernest/blob/master/src/App.tsx"
    click DashboardLayout "https://github.com/nikhil-coder390/hernest/blob/master/src/components/DashboardLayout.tsx"
    click Navbar "https://github.com/nikhil-coder390/hernest/blob/master/src/components/Navbar.tsx"
    click NotificationBell "https://github.com/nikhil-coder390/hernest/blob/master/src/components/NotificationBell.tsx"
    click AuthPage "https://github.com/nikhil-coder390/hernest/blob/master/src/pages/Auth.tsx"
    click HomePage "https://github.com/nikhil-coder390/hernest/blob/master/src/pages/Home.tsx"
    click PatientDashboardPage "https://github.com/nikhil-coder390/hernest/blob/master/src/pages/PatientDashboard.tsx"
    click DoctorDashboardPage "https://github.com/nikhil-coder390/hernest/blob/master/src/pages/DoctorDashboard.tsx"
    click HealthRecordsPage "https://github.com/nikhil-coder390/hernest/blob/master/src/pages/HealthRecords.tsx"
    click ChatPage "https://github.com/nikhil-coder390/hernest/blob/master/src/pages/Chat.tsx"
    click BookAppointmentPage "https://github.com/nikhil-coder390/hernest/blob/master/src/pages/BookAppointment.tsx"
    click PaymentPage "https://github.com/nikhil-coder390/hernest/blob/master/src/pages/Payment.tsx"
    click PrescriptionsPage "https://github.com/nikhil-coder390/hernest/blob/master/src/pages/Prescriptions.tsx"
    click ProfilePage "https://github.com/nikhil-coder390/hernest/blob/master/src/pages/Profile.tsx"
    click Store "https://github.com/nikhil-coder390/hernest/blob/master/src/lib/store.ts"
    click SupaClient "https://github.com/nikhil-coder390/hernest/blob/master/src/lib/supabase.ts"
    click Types "https://github.com/nikhil-coder390/hernest/blob/master/src/types/database.ts"
    click Migrations "https://github.com/nikhil-coder390/hernest/tree/master/supabase/migrations/"

    %% Styles
    classDef frontend fill:#E3F2FD,stroke:#1E88E5,color:#1E88E5;
    classDef backend fill:#E8F5E9,stroke:#43A047,color:#43A047;
    classDef external fill:#FFF3E0,stroke:#FB8C00,color:#FB8C00;
```
