# josephgmkonda/medicalaidsystem architecture

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

- Interactive diagram: https://gitdiagram.com/josephgmkonda/medicalaidsystem
- Repository: https://github.com/josephgmkonda/medicalaidsystem

## Overview

##### Project Type and Purpose
- This is a full-stack web application called “Medical Aid System” that streamlines medical supply logistics.
- The frontend is built in React (Vite, Tailwind, Redux Toolkit), and the backend is a Node.js/Express API using Sequelize ORM with a MySQL database.
- It supports three user roles (Admin, Inventory Manager, Client), secure JWT authentication, inventory tracking, order processing with approval workflow, and dashboard analytics.

##### File Structure Analysis
- Top-level directories:
- API/ – the Express server and business logic
- Frontend/MedicalAid/ – the React application
- API/ substructure reveals an MVC pattern:
- config/database.js for Sequelize setup
- models/ (Inventory, Order, OrderItem, User)
- controllers/ (AdminDashboard, Auth, Inventory, Order, User)
- routes/ mapping endpoints to controllers
- middleware/AunthUser.js for JWT-based auth
- Frontend/MedicalAid/ structure:
- public/ + index.html
- src/
– components/ (reusable UI, e.g., Navbar, Sidebar, ProtectedRoute)
– pages/ (feature pages, dashboard, charts, sign-in, user/inventory management)
– features/ (Redux slices for Admin, Auth, Inventory, etc.)
– store.js for Redux store configuration
- Config files: .env at API/, package.json, Vite config, Tailwind config, ESLint, PostCSS.

##### Key Insights from README
- Technology stack (React, Node.js, Express, Sequelize, MySQL, JWT)
- Functional overview and user roles
- Screenshots illustrating dashboards and workflows

- Client Browser (React SPA)
- Frontend Application (Vite bundle + Tailwind CSS + Redux state)
- API Server (Node.js + Express)
- Authentication Layer (JWT issuance & validation middleware)
- Database (MySQL via Sequelize)
- Browser → Frontend SPA (HTTP/HTTPS)
- SPA → API Server (REST calls: /auth, /inventory, /orders, /users, /admin-dashboard)
- API Server → Auth Middleware → Issue/Validate JWT
- API Server → Database (Sequelize ORM queries)
- API Server → Controllers/Services → Models → Database
- API Server ↔ External env (config/.env)
c. Architectural Patterns & Principles:
- Separation of concerns: UI, business logic, data persistence
- MVC in backend (routes → controllers → models)
- State management in frontend via Redux slices
- Role-based access control enforced at API middleware
- RESTful design for API endpoints
d. Key Technologies & Libraries:
- React.js + Vite + Tailwind CSS (frontend)
- Redux Toolkit (AdminSlice, AuthSlice, InventorySlice, etc.)
- Express.js + Node.js (API entry point index.js)
- Sequelize ORM + MySQL (config/database.js)
- JWT (middleware/AunthUser.js)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    A["Client Browser"]:::external
    A -->|"HTTP/HTTPS"| B["Frontend Application (React SPA)"]:::frontend

    subgraph "Frontend Application" 
        direction TB
        subgraph "Components"
            C1["Navbar"]:::frontend
            C2["Sidebar"]:::frontend
            C3["ProtectedRoute"]:::frontend
        end
        subgraph "Pages"
            P1["Dashboard"]:::frontend
            P2["SignIn"]:::frontend
            P3["Inventory Management"]:::frontend
            P4["Orders"]:::frontend
            P5["Users"]:::frontend
            P6["Charts"]:::frontend
        end
        subgraph "Client Pages"
            CP1["Client Orders"]:::frontend
            CP2["Products"]:::frontend
        end
        subgraph "Inventory Manager Pages"
            IP1["Inventory Dashboard"]:::frontend
            IP2["Order Update"]:::frontend
        end
        subgraph "State Management"
            direction TB
            S1["Redux Store"]:::state
            S2["AdminSlice"]:::state
            S3["AuthSlice"]:::state
            S4["InventorySlice"]:::state
            S5["InventoryManagerSlice"]:::state
            S6["ClientProductSlice"]:::state
            S7["LowStockSlice"]:::state
            S8["UserSlice"]:::state
        end
        C1 --> S1
        C2 --> S1
        C3 --> S1
        P1 --> S1
        P2 --> S1
        P3 --> S1
        P4 --> S1
        P5 --> S1
        P6 --> S1
        CP1 --> S1
        CP2 --> S1
        IP1 --> S1
        IP2 --> S1
    end

    B -->|"REST API calls (/auth,/inventory,/orders,/users,/admin-dashboard)"| D["API Server (Node.js + Express)"]:::api

    subgraph "API Server"
        direction TB
        subgraph "Routes"
            R1["Auth Routes"]:::api
            R2["Inventory Routes"]:::api
            R3["Order Routes"]:::api
            R4["User Routes"]:::api
            R5["AdminDashboard Routes"]:::api
        end
        subgraph "Controllers"
            Ctl1["Auth Controller"]:::api
            Ctl2["Inventory Controller"]:::api
            Ctl3["Order Controller"]:::api
            Ctl4["User Controller"]:::api
            Ctl5["AdminDashboard Controller"]:::api
        end
        subgraph "Middleware"
            M1["Auth Middleware"]:::middleware
        end
        subgraph "Models"
            MD1["User Model"]:::model
            MD2["Inventory Model"]:::model
            MD3["Order Model"]:::model
            MD4["OrderItem Model"]:::model
        end
        R1 --> Ctl1
        R2 --> Ctl2
        R3 --> Ctl3
        R4 --> Ctl4
        R5 --> Ctl5
        Ctl1 --> M1
        Ctl2 --> MD2
        Ctl3 --> MD3
        Ctl3 --> MD4
        Ctl4 --> MD1
        Ctl5 --> MD1
        M1 -->|"Validate/Issue JWT"| Ctl1
        Ctl1 -->|"JWT Response"| B
    end

    D -->|"ORM Queries"| E["Database (MySQL)"]:::database
    D --> F["Environment (.env)"]:::env
    subgraph "Database Config"
        DBConf["Sequelize Config"]:::config
    end
    D --> DBConf
    DBConf --> E

    %% Click Events
    click B "https://github.com/josephgmkonda/medicalaidsystem/tree/master/Frontend/MedicalAid"
    click C1 "https://github.com/josephgmkonda/medicalaidsystem/blob/master/Frontend/MedicalAid/src/components/Navbar.jsx"
    click C2 "https://github.com/josephgmkonda/medicalaidsystem/blob/master/Frontend/MedicalAid/src/components/Sidebar.jsx"
    click C3 "https://github.com/josephgmkonda/medicalaidsystem/blob/master/Frontend/MedicalAid/src/components/ProtectedRoute.jsx"
    click P1 "https://github.com/josephgmkonda/medicalaidsystem/blob/master/Frontend/MedicalAid/src/pages/Dashboard.jsx"
    click P2 "https://github.com/josephgmkonda/medicalaidsystem/blob/master/Frontend/MedicalAid/src/pages/SignIn.jsx"
    click P3 "https://github.com/josephgmkonda/medicalaidsystem/blob/master/Frontend/MedicalAid/src/pages/Inventory.jsx"
    click P4 "https://github.com/josephgmkonda/medicalaidsystem/blob/master/Frontend/MedicalAid/src/pages/Orders.jsx"
    click P5 "https://github.com/josephgmkonda/medicalaidsystem/blob/master/Frontend/MedicalAid/src/pages/Users.jsx"
    click P6 "https://github.com/josephgmkonda/medicalaidsystem/tree/master/Frontend/MedicalAid/src/pages/Charts"
    click CP1 "https://github.com/josephgmkonda/medicalaidsystem/blob/master/Frontend/MedicalAid/src/pages/Client/ClientOrders.jsx"
    click CP2 "https://github.com/josephgmkonda/medicalaidsystem/blob/master/Frontend/MedicalAid/src/pages/Client/Products.jsx"
    click IP1 "https://github.com/josephgmkonda/medicalaidsystem/blob/master/Frontend/MedicalAid/src/pages/InventoryManager/InventoryDashboard.jsx"
    click IP2 "https://github.com/josephgmkonda/medicalaidsystem/blob/master/Frontend/MedicalAid/src/pages/InventoryManager/OrderUpdate.jsx"
    click S1 "https://github.com/josephgmkonda/medicalaidsystem/blob/master/Frontend/MedicalAid/src/store.js"
    click S2 "https://github.com/josephgmkonda/medicalaidsystem/blob/master/Frontend/MedicalAid/src/features/AdminSlice.js"
    click S3 "https://github.com/josephgmkonda/medicalaidsystem/blob/master/Frontend/MedicalAid/src/features/AunthSlice.js"
    click S4 "https://github.com/josephgmkonda/medicalaidsystem/blob/master/Frontend/MedicalAid/src/features/Inventory.js"
    click S5 "https://github.com/josephgmkonda/medicalaidsystem/blob/master/Frontend/MedicalAid/src/features/InventoryManagerSlice.js"
    click S6 "https://github.com/josephgmkonda/medicalaidsystem/blob/master/Frontend/MedicalAid/src/features/ClientProductSlice.js"
    click S7 "https://github.com/josephgmkonda/medicalaidsystem/blob/master/Frontend/MedicalAid/src/features/LowStockSlice.js"
    click S8 "https://github.com/josephgmkonda/medicalaidsystem/blob/master/Frontend/MedicalAid/src/features/UserSlice.js"
    click D "https://github.com/josephgmkonda/medicalaidsystem/blob/master/API/index.js"
    click DBConf "https://github.com/josephgmkonda/medicalaidsystem/blob/master/API/config/database.js"
    click Ctl1 "https://github.com/josephgmkonda/medicalaidsystem/blob/master/API/controllers/AunthController.js"
    click M1 "https://github.com/josephgmkonda/medicalaidsystem/blob/master/API/middleware/AunthUser.js"
    click R1 "https://github.com/josephgmkonda/medicalaidsystem/blob/master/API/routes/AunthRoutes.js"
    click Ctl2 "https://github.com/josephgmkonda/medicalaidsystem/blob/master/API/controllers/InventoryController.js"
    click R2 "https://github.com/josephgmkonda/medicalaidsystem/blob/master/API/routes/InventoryRoute.js"
    click MD2 "https://github.com/josephgmkonda/medicalaidsystem/blob/master/API/models/Inventory.js"
    click Ctl3 "https://github.com/josephgmkonda/medicalaidsystem/blob/master/API/controllers/OrderController.js"
    click R3 "https://github.com/josephgmkonda/medicalaidsystem/blob/master/API/routes/OrderRoute.js"
    click MD3 "https://github.com/josephgmkonda/medicalaidsystem/blob/master/API/models/Order.js"
    click MD4 "https://github.com/josephgmkonda/medicalaidsystem/blob/master/API/models/OrderItem.js"
    click Ctl4 "https://github.com/josephgmkonda/medicalaidsystem/blob/master/API/controllers/UserController.js"
    click R4 "https://github.com/josephgmkonda/medicalaidsystem/blob/master/API/routes/UserRoute.js"
    click MD1 "https://github.com/josephgmkonda/medicalaidsystem/blob/master/API/models/Usermodel.js"
    click Ctl5 "https://github.com/josephgmkonda/medicalaidsystem/blob/master/API/controllers/AdminDashboard.js"
    click R5 "https://github.com/josephgmkonda/medicalaidsystem/blob/master/API/routes/AdminDashboard.js"
    click F "https://github.com/josephgmkonda/medicalaidsystem/blob/master/.env"

    %% Styles
    classDef frontend fill:#cce5ff,stroke:#3399ff,stroke-width:1px
    classDef api fill:#d4edda,stroke:#28a745,stroke-width:1px
    classDef database fill:#ffe5b4,stroke:#ff9933,stroke-width:1px
    classDef middleware fill:#f0e6f7,stroke:#9b59b6,stroke-width:1px
    classDef model fill:#fff3cd,stroke:#f0ad4e,stroke-width:1px
    classDef config fill:#e2e3e5,stroke:#6c757d,stroke-width:1px
    classDef state fill:#e8f0fe,stroke:#4285f4,stroke-width:1px
    classDef external fill:#f5f5f5,stroke:#999999,stroke-width:1px
```
