# vineeth0502/medicarepro architecture

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

- Interactive diagram: https://gitdiagram.com/vineeth0502/medicarepro
- Repository: https://github.com/vineeth0502/medicarepro

## Overview

##### Project Type and Purpose
- This is a full-stack healthcare management platform (“MediCare Pro”) with:
- Frontend: Next.js 16 + React 19
- Backend: Node.js/Express.js API
- Database: MongoDB Atlas
- Purpose: Provide real-time health monitoring, alerting, messaging, appointment scheduling, and analytics for patients and providers.

a. Next.js Frontend
– All UI pages and components under `app/`, `components/`, `lib/`, and `hooks/`
– Handles routing, rendering, forms, charts, and communicates with the API
b. Express API Server
– `backend/src/server.js`, routes (`auth`, `users`, `healthMetrics`, `alerts`, `appointments`, `messages`), middleware, and device simulator service
– Implements JWT auth, validation, file uploads, and business logic
c. MongoDB Atlas
– Stores Users, HealthMetrics, Alerts, Appointments, Messages
– Accessed via Mongoose models
d. Deployment & External Services
– Vercel (Frontend)
– Railway/Heroku (Backend)
– Git (version control)
– Device Simulator (generates health metrics)

##### Relationships & Data Flow
- User ↔ Frontend
- Frontend → API Server (REST calls over HTTP with JWT in headers)
- API Server → MongoDB Atlas (via Mongoose)
- API Server → Device Simulator (internal service generating metric data)
- Deployment platforms host Frontend and Backend

##### Architectural Patterns & Design Principles
- Monolithic backend with modular route-service-model layering
- Next.js App Router for colocation of data‐fetching and UI
- JWT-based stateless authentication
- Separation of concerns: UI vs API vs Data Layer
- Device Simulator for decoupled data generation

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Layers
    subgraph "Frontend Layer"
        direction TB
        FE["Next.js Frontend"]:::frontend
    end

    subgraph "Backend Layer"
        direction TB
        BE["Express API Server"]:::backend
    end

    subgraph "Database Layer"
        direction TB
        DB["MongoDB Atlas"]:::database
    end

    subgraph "External Services"
        direction TB
        EX1["Vercel (Frontend)"]:::external
        EX2["Railway/Heroku (Backend)"]:::external
        EX3["Git (Version Control)"]:::external
        EX4["Device Simulator"]:::external
    end

    %% User
    User(["Users"]):::user

    %% Connections
    User -->|"Interacts via UI"| FE
    FE -->|"HTTP/HTTPS + JWT"| BE
    BE -->|"Mongoose Queries"| DB
    BE -->|"Generates Metrics"| EX4
    EX1 -->|"Deploys Frontend"| FE
    EX2 -->|"Deploys Backend"| BE
    EX3 -->|"Repo Sync"| FE
    EX3 -->|"Repo Sync"| BE

    %% Click Events
    click FE "https://github.com/vineeth0502/medicarepro/tree/main/app/"
    click BE "https://github.com/vineeth0502/medicarepro/blob/main/backend/src/server.js"
    click BE "https://github.com/vineeth0502/medicarepro/tree/main/backend/src/routes/"
    click BE "https://github.com/vineeth0502/medicarepro/blob/main/backend/src/middleware/auth.js"
    click BE "https://github.com/vineeth0502/medicarepro/blob/main/backend/src/models/User.js"
    click BE "https://github.com/vineeth0502/medicarepro/blob/main/backend/src/services/deviceSimulator.js"
    click EX4 "https://github.com/vineeth0502/medicarepro/blob/main/backend/src/services/deviceSimulator.js"

    %% Styles
    classDef frontend fill:#e0f7ff,stroke:#0288d1,stroke-width:2px;
    classDef backend fill:#e8f5e9,stroke:#43a047,stroke-width:2px;
    classDef database fill:#fff3e0,stroke:#fb8c00,stroke-width:2px;
    classDef external fill:#eceff1,stroke:#78909c,stroke-width:2px;
    classDef user fill:#f3e5f5,stroke:#8e24aa,stroke-width:2px,stroke-dasharray: 5 5;
```
