# adityash2006/curifix-all-in-one-health-management architecture

> Architecture diagram of the GitHub repository adityash2006/curifix-all-in-one-health-management, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-11-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/adityash2006/curifix-all-in-one-health-management
- Repository: https://github.com/adityash2006/curifix-all-in-one-health-management

## Overview

##### Project type and purpose
- Type: Full-stack web application (React frontend + Node.js/Express backend).
- Purpose: AI-powered health assistant (“CuriFix”) that provides symptom checking, report storage, medicine reminders, doctor locator, video consults, emergency calls, and user health profiles.

##### File structure
- Top-level split:
- frontend/ – React (Vite) SPA with pages (Home, Chat, Login, Signup), components (AI chat, dashboard, features), context, styling.
- backend/ – Express REST + WebSocket server with:
– middleware/auth.js
– routes (auth, chat, docs, clerk, wardRoutes, saveUserClerk)
– utils (ai.js, medicalsummary.js, textExtracter.js, socketManager.js)
– models (User, Document, Thread, Meetings)
– uploads/ – stored medical reports
– server.js
- Config/build files: package.json in each tier, Vite config, ESLint.
- CI: .github/workflows/cicd.yml

##### Extract key tech from README
- Frontend: React, Vite, TailwindCSS, ShadCN UI
- Backend: Node.js, Express
- Database: MongoDB (URI in .env), possibly PostgreSQL in future
- AI/NLP: OpenAI API (ClinicalBERT/BlueBERT), custom summarizer
- External services: Google Maps API, Twilio, Video SDK
- Cloud deployment: AWS / GCP

##### Main components & their interactions
a. User clients (Browser / Mobile SPA)
→ HTTP/HTTPS: REST calls to Express API (auth, docs, chat, reminders)
→ WebSocket: real-time chat (socketManager)
b. Express API server
– Routing layer (auth.js, docs.js, chat.js, clerk.js, wardRoutes.js)
– Business logic / controllers in utils (AI analysis, summarization, text extraction)
– Middleware (JWT auth)
– File uploads saved to uploads/ directory (could be abstracted to cloud storage)
c. Database (MongoDB)
– Persists Users, Documents, Threads, Meetings collections
d. AI/NLP services
– OpenAI API calls via ai.js
– Medical summary generation via medicalsummary.js
– Text extraction from uploaded reports via textExtracter.js
e. Real-time chat subsystem
– socketManager.js orchestrates WebSocket rooms, events
f. External integrations
– Google Maps API for doctor locator
– Twilio (SMS/call) for emergency reminders
– Video SDK for consultations
g. Cloud infrastructure
– Hosted on AWS/GCP with CI/CD (GitHub Actions)

##### Important architectural patterns
- Layered (Controller → Service/Utils → Data)
- MVC-inspired routing in Express
- Real-time event-driven chat via WebSockets
- Modular separation: AI utilities, auth, file uploads
- Clear frontend/back separation, context management in React

## Diagram (Mermaid)

```mermaid
graph TB
  %% User Devices
  subgraph "User Devices"
    User["Browser / Mobile"]:::external
  end

  %% Frontend Container
  subgraph "Frontend SPA (React/Vite)" 
    direction TB
    Entry["main.jsx"]:::frontend
    App["App.jsx"]:::frontend
    subgraph Pages
      direction TB
      Home["Home.jsx"]:::frontend
      ChatPage["Chat.jsx"]:::frontend
      LoginPage["Login.jsx"]:::frontend
      SignupPage["Signup.jsx"]:::frontend
    end
    subgraph Components
      direction TB
      AiChat["AiChat.jsx"]:::frontend
      ChatWindow["ChatWindow.jsx"]:::frontend
      Dashboard["Dashboard.jsx"]:::frontend
      Navbar["Navbar.jsx"]:::frontend
      Sidebar["Sidebar.jsx"]:::frontend
      Loader["Loader.jsx"]:::frontend
      Cards["cards.jsx / cards2.jsx"]:::frontend
      subgraph Features
        direction TB
        Dose["Dose.jsx"]:::frontend
        Emergency["Emergency.jsx"]:::frontend
        Hospital["Hospital.jsx"]:::frontend
        NearbyDoc["Nearbydoc.jsx"]:::frontend
        Store["Store.jsx"]:::frontend
        VideoCall["VideoCall.jsx"]:::frontend
        DashFeat["Dash.jsx"]:::frontend
      end
    end
    subgraph AuthContext
      direction TB
      MyContext["MyContext.jsx"]:::frontend
      subgraph ClerkAuth
        direction TB
        ClerkLogin["Loginuser.jsx"]:::frontend
        ClerkSignup["SignUp.jsx"]:::frontend
        Protected["Protected.jsx"]:::frontend
      end
    end
    ConfigVite["vite.config.js"]:::frontend
    ConfigESLint["eslint.config.js"]:::frontend
  end

  %% Backend Container
  subgraph "Backend API Server (Express)" 
    direction TB
    Server["server.js"]:::backend

    subgraph Routes
      direction TB
      AuthRoute["auth.js"]:::backend
      ChatRoute["chat.js"]:::backend
      DocsRoute["docs.js"]:::backend
      SaveClerk["saveUserClerk.js"]:::backend
      WardRoutes["wardRoutes.js"]:::backend
      ClerkRoute["clerk.js"]:::backend
    end

    Middleware["auth.js"]:::backend

    subgraph Utils
      direction TB
      AIUtil["ai.js"]:::backend
      Summary["medicalsummary.js"]:::backend
      TextExtract["textExtracter.js"]:::backend
      SocketMgr["socketManager.js"]:::backend
    end

    subgraph Models
      direction TB
      UserModel["User.js"]:::backend
      DocModel["Document.js"]:::backend
      ThreadModel["Thread.js"]:::backend
      MeetingModel["Meetings.js"]:::backend
    end

    Uploads["uploads/"]:::storage
  end

  %% Services and Integrations
  DB["MongoDB"]:::db
  AIService["OpenAI API"]:::external
  GoogleMaps["Google Maps API"]:::external
  Twilio["Twilio SMS/Call"]:::external
  VideoSDK["Video SDK"]:::external
  CICD["GitHub Actions CI/CD"]:::ci

  %% Flows
  User -->|"HTTP/HTTPS REST"| Entry
  Entry --> App
  App --> Pages
  App --> Components
  Pages --> AuthContext
  Components --> Features
  App --> ConfigVite
  App --> ConfigESLint

  App -->|"REST API"| AuthRoute
  App -->|"REST API"| ChatRoute
  App -->|"REST API"| DocsRoute
  App -->|"REST API"| SaveClerk
  App -->|"REST API"| WardRoutes
  App -->|"REST API"| ClerkRoute
  App -->|"WebSocket WS"| SocketMgr

  AuthRoute --> Middleware
  ChatRoute --> Utils
  DocsRoute --> TextExtract
  SaveClerk --> Middleware
  WardRoutes --> Utils
  ClerkRoute --> Utils
  SocketMgr --> Server
  Server --> Models
  Server --> Uploads
  Server --> DB

  Server -->|"API Calls"| AIUtil
  AIUtil --> AIService
  Server -->|"API Calls"| Summary
  Server -->|"API Calls"| TextExtract
  Server -->|"API Calls"| GoogleMaps
  Server -->|"SMS/Call"| Twilio
  Server -->|"Video"| VideoSDK

  CICD --> Server
  CICD --> Entry

  %% Click Events
  click Entry "https://github.com/adityash2006/curifix-all-in-one-health-management/blob/main/frontend/src/main.jsx"
  click App "https://github.com/adityash2006/curifix-all-in-one-health-management/blob/main/frontend/src/App.jsx"
  click Home "https://github.com/adityash2006/curifix-all-in-one-health-management/blob/main/frontend/src/pages/Home.jsx"
  click ChatPage "https://github.com/adityash2006/curifix-all-in-one-health-management/blob/main/frontend/src/pages/Chat.jsx"
  click LoginPage "https://github.com/adityash2006/curifix-all-in-one-health-management/blob/main/frontend/src/pages/Login.jsx"
  click SignupPage "https://github.com/adityash2006/curifix-all-in-one-health-management/blob/main/frontend/src/pages/Signup.jsx"
  click AiChat "https://github.com/adityash2006/curifix-all-in-one-health-management/blob/main/frontend/src/components/AiChat.jsx"
  click ChatWindow "https://github.com/adityash2006/curifix-all-in-one-health-management/blob/main/frontend/src/components/ChatWindow.jsx"
  click Dashboard "https://github.com/adityash2006/curifix-all-in-one-health-management/blob/main/frontend/src/components/Dashboard.jsx"
  click Navbar "https://github.com/adityash2006/curifix-all-in-one-health-management/blob/main/frontend/src/components/Navbar.jsx"
  click Sidebar "https://github.com/adityash2006/curifix-all-in-one-health-management/blob/main/frontend/src/components/Sidebar.jsx"
  click Loader "https://github.com/adityash2006/curifix-all-in-one-health-management/blob/main/frontend/src/components/Loader.jsx"
  click Cards "https://github.com/adityash2006/curifix-all-in-one-health-management/blob/main/frontend/src/components/cards.jsx"
  click Dose "https://github.com/adityash2006/curifix-all-in-one-health-management/blob/main/frontend/src/components/features/Dose.jsx"
  click Emergency "https://github.com/adityash2006/curifix-all-in-one-health-management/blob/main/frontend/src/components/features/Emergency.jsx"
  click Hospital "https://github.com/adityash2006/curifix-all-in-one-health-management/blob/main/frontend/src/components/features/Hospital.jsx"
  click NearbyDoc "https://github.com/adityash2006/curifix-all-in-one-health-management/blob/main/frontend/src/components/features/Nearbydoc.jsx"
  click Store "https://github.com/adityash2006/curifix-all-in-one-health-management/blob/main/frontend/src/components/features/Store.jsx"
  click VideoCall "https://github.com/adityash2006/curifix-all-in-one-health-management/blob/main/frontend/src/components/features/VideoCall.jsx"
  click DashFeat "https://github.com/adityash2006/curifix-all-in-one-health-management/blob/main/frontend/src/components/features/Dash.jsx"
  click MyContext "https://github.com/adityash2006/curifix-all-in-one-health-management/blob/main/frontend/src/components/MyContext.jsx"
  click ClerkLogin "https://github.com/adityash2006/curifix-all-in-one-health-management/blob/main/frontend/src/clerkauth/Loginuser.jsx"
  click ClerkSignup "https://github.com/adityash2006/curifix-all-in-one-health-management/blob/main/frontend/src/clerkauth/SignUp.jsx"
  click Protected "https://github.com/adityash2006/curifix-all-in-one-health-management/blob/main/frontend/src/clerkauth/Protected.jsx"
  click ConfigVite "https://github.com/adityash2006/curifix-all-in-one-health-management/blob/main/frontend/vite.config.js"
  click ConfigESLint "https://github.com/adityash2006/curifix-all-in-one-health-management/blob/main/frontend/eslint.config.js"
  click Server "https://github.com/adityash2006/curifix-all-in-one-health-management/blob/main/backend/server.js"
  click AuthRoute "https://github.com/adityash2006/curifix-all-in-one-health-management/blob/main/backend/routes/auth.js"
  click ChatRoute "https://github.com/adityash2006/curifix-all-in-one-health-management/blob/main/backend/routes/chat.js"
  click DocsRoute "https://github.com/adityash2006/curifix-all-in-one-health-management/blob/main/backend/routes/docs.js"
  click SaveClerk "https://github.com/adityash2006/curifix-all-in-one-health-management/blob/main/backend/routes/saveUserClerk.js"
  click WardRoutes "https://github.com/adityash2006/curifix-all-in-one-health-management/blob/main/backend/routes/wardRoutes.js"
  click ClerkRoute "https://github.com/adityash2006/curifix-all-in-one-health-management/blob/main/backend/routes/clerk.js"
  click Middleware "https://github.com/adityash2006/curifix-all-in-one-health-management/blob/main/backend/middleware/auth.js"
  click AIUtil "https://github.com/adityash2006/curifix-all-in-one-health-management/blob/main/backend/utils/ai.js"
  click Summary "https://github.com/adityash2006/curifix-all-in-one-health-management/blob/main/backend/utils/medicalsummary.js"
  click TextExtract "https://github.com/adityash2006/curifix-all-in-one-health-management/blob/main/backend/utils/textExtracter.js"
  click SocketMgr "https://github.com/adityash2006/curifix-all-in-one-health-management/blob/main/backend/utils/socketManager.js"
  click UserModel "https://github.com/adityash2006/curifix-all-in-one-health-management/blob/main/backend/models/User.js"
  click DocModel "https://github.com/adityash2006/curifix-all-in-one-health-management/blob/main/backend/models/Document.js"
  click ThreadModel "https://github.com/adityash2006/curifix-all-in-one-health-management/blob/main/backend/models/Thread.js"
  click MeetingModel "https://github.com/adityash2006/curifix-all-in-one-health-management/blob/main/backend/models/Meetings.js"
  click Uploads "https://github.com/adityash2006/curifix-all-in-one-health-management/tree/main/backend/uploads/"
  click CICD "https://github.com/adityash2006/curifix-all-in-one-health-management/blob/main/.github/workflows/cicd.yml"

  %% Styles
  classDef frontend fill:#D0E8FF,stroke:#2B6CB0
  classDef backend fill:#CCE5FF,stroke:#2C5282
  classDef db fill:#D5F5E3,stroke:#2F855A
  classDef storage fill:#ABEBC6,stroke:#2F855A
  classDef external fill:#FDEBD0,stroke:#D35400
  classDef ci fill:#F2F3F4,stroke:#4A5568
```
