# chokshidhruv/healthconnect---deltahacks11 architecture

> Architecture diagram of the GitHub repository chokshidhruv/healthconnect---deltahacks11, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-19). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/chokshidhruv/healthconnect---deltahacks11
- Repository: https://github.com/chokshidhruv/healthconnect---deltahacks11

## Overview

##### Main System Components

The system appears to be a full-stack web application with real-time capabilities. Here's how to represent the key components:

A. Frontend Layer (Client)
- Authentication Components (Login/Register)
- Main Application Views (Dashboard, Appointments, Chat)
- Real-time Communication Interface
- Context Management (AuthContext)

B. Backend Layer (Server)
- API Routes
- Authentication Middleware
- WebSocket Server
- Cohere AI Integration

C. Database Layer
- Users
- Appointments
- Messages

D. External Services
- Cohere AI Service (for medical assistance)

##### Component Relationships and Data Flow

A. Client-Server Communication:
- Authentication flow

B. Server-Database Interactions:
- CRUD operations for each model
- Real-time data updates

C. External Service Integration:
- Cohere AI API calls for medical assistance

##### Detailed Component Breakdown

For each major component, include:

Frontend:
**┌─ Client Layer ─────────────────┐**
- Public Routes              │
- Hero                    │
- Login                   │
- Register               │

- Protected Routes          │
- Dashboard              │
- Appointments           │
- Chat                   │
- Medical Assistant      │
- Availability           │

- Shared Components         │
- Navbar                 │
- Authentication Context │
- ┘

Backend:
**┌─ Server Layer ────────────────┐**
- API Routes               │
- /auth                 │
- /appointments         │
- /messages            │
- /chat                │

- WebSocket Handler       │
- Real-time Chat       │

- Middleware              │
- Authentication       │

- External Services       │
- Cohere AI            │
- ┘

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        FC[Frontend Client]
        
        subgraph Auth["Authentication Components"]
            Login["Login"]:::frontend
            Register["Register"]:::frontend
        end
        
        subgraph Views["Main Application Views"]
            Dashboard["Dashboard"]:::frontend
            Appointments["Appointments"]:::frontend
            Chat["Chat"]:::frontend
            MedicalAssistant["Medical Assistant"]:::frontend
            Availability["Availability"]:::frontend
        end
        
        subgraph Shared["Shared Components"]
            Navbar["Navbar"]:::frontend
            AuthContext["Authentication Context"]:::frontend
            PrivateRoute["Private Route"]:::frontend
        end
    end
    
    subgraph Server
        BE[Backend Server]
        
        subgraph Routes["API Routes"]
            AuthAPI["Auth API"]:::backend
            AppointmentsAPI["Appointments API"]:::backend
            MessagesAPI["Messages API"]:::backend
            ChatAPI["Chat API"]:::backend
        end
        
        subgraph Middleware["Middleware"]
            AuthMiddleware["Authentication"]:::backend
        end
        
        WebSocket["WebSocket Server"]:::backend
        CohereConfig["Cohere AI Integration"]:::backend
    end
    
    subgraph Database
        MongoDB[(MongoDB)]:::database
        
        subgraph Collections["Collections"]
            Users[(Users)]:::database
            AppointmentsDB[(Appointments)]:::database
            Messages[(Messages)]:::database
        end
    end
    
    subgraph External
        CohereAI["Cohere AI Service"]:::external
    end
    
    %% Relationships
    FC --> AuthAPI
    FC --> AppointmentsAPI
    FC --> MessagesAPI
    FC --> ChatAPI
    
    AuthAPI --> AuthMiddleware
    AppointmentsAPI --> AuthMiddleware
    MessagesAPI --> AuthMiddleware
    ChatAPI --> AuthMiddleware
    
    AuthMiddleware --> Users
    AppointmentsAPI --> AppointmentsDB
    MessagesAPI --> Messages
    ChatAPI --> Messages
    
    WebSocket -.-> Chat
    CohereConfig --> CohereAI
    
    %% Click Events
    click Login "https://github.com/chokshidhruv/HealthConnect---DeltaHacks11/blob/main/client/src/pages/Login.jsx"
    click Register "https://github.com/chokshidhruv/HealthConnect---DeltaHacks11/blob/main/client/src/pages/Register.jsx"
    click Dashboard "https://github.com/chokshidhruv/HealthConnect---DeltaHacks11/blob/main/client/src/pages/Dashboard.jsx"
    click Appointments "https://github.com/chokshidhruv/HealthConnect---DeltaHacks11/blob/main/client/src/pages/Appointments.jsx"
    click Chat "https://github.com/chokshidhruv/HealthConnect---DeltaHacks11/blob/main/client/src/pages/Chat.jsx"
    click MedicalAssistant "https://github.com/chokshidhruv/HealthConnect---DeltaHacks11/blob/main/client/src/pages/MedicalAssistant.jsx"
    click Availability "https://github.com/chokshidhruv/HealthConnect---DeltaHacks11/blob/main/client/src/pages/Availability.jsx"
    click AuthContext "https://github.com/chokshidhruv/HealthConnect---DeltaHacks11/blob/main/client/src/context/AuthContext.jsx"
    click Navbar "https://github.com/chokshidhruv/HealthConnect---DeltaHacks11/blob/main/client/src/components/Navbar.jsx"
    click PrivateRoute "https://github.com/chokshidhruv/HealthConnect---DeltaHacks11/blob/main/client/src/components/PrivateRoute.jsx"
    click AuthAPI "https://github.com/chokshidhruv/HealthConnect---DeltaHacks11/blob/main/server/routes/auth.js"
    click AppointmentsAPI "https://github.com/chokshidhruv/HealthConnect---DeltaHacks11/blob/main/server/routes/appointments.js"
    click MessagesAPI "https://github.com/chokshidhruv/HealthConnect---DeltaHacks11/blob/main/server/routes/messages.js"
    click ChatAPI "https://github.com/chokshidhruv/HealthConnect---DeltaHacks11/blob/main/server/routes/chat.js"
    click AuthMiddleware "https://github.com/chokshidhruv/HealthConnect---DeltaHacks11/blob/main/server/middleware/auth.js"
    click WebSocket "https://github.com/chokshidhruv/HealthConnect---DeltaHacks11/blob/main/server/socket.js"
    click CohereConfig "https://github.com/chokshidhruv/HealthConnect---DeltaHacks11/blob/main/server/config/cohere.js"
    click Users "https://github.com/chokshidhruv/HealthConnect---DeltaHacks11/blob/main/server/models/User.js"
    click AppointmentsDB "https://github.com/chokshidhruv/HealthConnect---DeltaHacks11/blob/main/server/models/Appointment.js"
    click Messages "https://github.com/chokshidhruv/HealthConnect---DeltaHacks11/blob/main/server/models/Message.js"
    
    %% Styles
    classDef frontend fill:#2196F3,stroke:#1565C0,color:white
    classDef backend fill:#4CAF50,stroke:#2E7D32,color:white
    classDef database fill:#FFC107,stroke:#FFA000,color:black
    classDef external fill:#9C27B0,stroke:#7B1FA2,color:white
    
    %% Legend
    subgraph Legend
        Frontend["Frontend Component"]:::frontend
        Backend["Backend Component"]:::backend
        DB["Database"]:::database
        Ext["External Service"]:::external
    end
```
