# vansh06saini/bloodtrack-smartbloodinventory-allocationandrequestmanagementsystem architecture

> Architecture diagram of the GitHub repository vansh06saini/bloodtrack-smartbloodinventory-allocationandrequestmanagementsystem, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/vansh06saini/bloodtrack-smartbloodinventory-allocationandrequestmanagementsystem
- Repository: https://github.com/vansh06saini/bloodtrack-smartbloodinventory-allocationandrequestmanagementsystem

## Overview

BloodTrack is a blood-bank and hospital coordination application. Hospital users register or log in, review inventory, submit and track blood requests, and schedule donations; administrators manage blood-unit stock and audit movement logs. The backend persists operational data in MySQL, runs priority-aware allocation and expiry cleanup workers, and exposes API routes to the frontend. The graph reflects documented routes and sampled calls; several frontend-to-API interactions are not visible in the supplied excerpts, so those links are dashed.

Main entry points: [`frontend/src/App.jsx`](https://github.com/vansh06saini/bloodtrack-smartbloodinventory-allocationandrequestmanagementsystem/blob/main/frontend/src/App.jsx) (Portal routing), [`backend/controllers/hospitalController.js`](https://github.com/vansh06saini/bloodtrack-smartbloodinventory-allocationandrequestmanagementsystem/blob/main/backend/controllers/hospitalController.js) (Hospital requests), [`backend/server.js`](https://github.com/vansh06saini/bloodtrack-smartbloodinventory-allocationandrequestmanagementsystem/blob/main/backend/server.js) (HTTP server and auth), [`backend/controllers/bloodUnitController.js`](https://github.com/vansh06saini/bloodtrack-smartbloodinventory-allocationandrequestmanagementsystem/blob/main/backend/controllers/bloodUnitController.js) (Stock and logs API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_portal["Web portals"]
  node_app["Portal routing<br/>[App.jsx]"]
  node_auth["Login and registration"]
  node_hospitaldash["Hospital dashboard"]
  node_requestcreate["Create request<br/>[CreateRequest.jsx]"]
  node_requestlist["Request tracking<br/>[MyRequests.jsx]"]
  node_requestdetail["Request details<br/>[RequestDetails.jsx]"]
  node_donation["Donation booking<br/>[DonateBlood.jsx]"]
  node_requestservice["Request service<br/>[requestService.js]"]
  node_admindash["Admin dashboard<br/>[AdminDashboard.jsx]"]
  node_stockentry["Add blood units<br/>[AddBloodUnits.jsx]"]
  node_dailylog["Daily blood log<br/>[DailyBloodLog.jsx]"]
end

subgraph group_api["Backend API"]
  node_server["HTTP server and auth<br/>[server.js]"]
  node_hospitalapi["Hospital requests"]
  node_bloodapi["Stock and logs API"]
  node_donationapi["Donation appointments"]
  node_allocationapi["Allocation endpoint"]
end

subgraph group_operations["Inventory operations"]
  node_allocationworker["Allocation worker"]
  node_allocation["Priority allocation"]
  node_expiry["Expiry cleanup<br/>[expiryWorker.js]"]
end

subgraph group_storage["Persistence"]
  node_mysql[("MySQL pool<br/>[db.js]")]
end

node_user(("Hospital user"))
node_admin(("Blood-bank admin"))

node_user -->|"uses"| node_app
node_admin -->|"uses"| node_app
node_app -->|"routes to"| node_auth
node_app -->|"routes to"| node_hospitaldash
node_app -->|"routes to"| node_requestcreate
node_app -->|"routes to"| node_requestlist
node_app -->|"routes to"| node_requestdetail
node_app -->|"routes to"| node_donation
node_app -->|"routes to"| node_admindash
node_app -->|"routes to"| node_stockentry
node_app -->|"routes to"| node_dailylog
node_requestcreate -.->|"uses"| node_requestservice
node_requestcreate -.->|"submits request"| node_hospitalapi
node_hospitaldash -.->|"loads summary"| node_hospitalapi
node_requestlist -.->|"loads requests"| node_hospitalapi
node_requestdetail -.->|"loads details"| node_hospitalapi
node_donation -.->|"books appointment"| node_donationapi
node_stockentry -.->|"adds units"| node_bloodapi
node_admindash -.->|"loads summary"| node_bloodapi
node_dailylog -.->|"loads logs"| node_bloodapi
node_server -->|"routes requests"| node_hospitalapi
node_server -->|"routes requests"| node_bloodapi
node_server -->|"routes requests"| node_donationapi
node_server -->|"routes requests"| node_allocationapi
node_hospitalapi -->|"reads and writes"| node_mysql
node_bloodapi -->|"reads and writes"| node_mysql
node_donationapi -->|"reads and writes"| node_mysql
node_allocationapi -->|"delegates"| node_allocation
node_hospitalapi -->|"triggers emergency run"| node_allocationworker
node_server -->|"starts worker"| node_allocationworker
node_server -->|"starts worker"| node_expiry
node_allocationworker -->|"processes requests"| node_allocation
node_allocation -->|"allocates stock"| node_mysql
node_expiry -->|"expires units"| node_mysql

click node_app "https://github.com/vansh06saini/bloodtrack-smartbloodinventory-allocationandrequestmanagementsystem/blob/main/frontend/src/App.jsx"
click node_auth "https://github.com/vansh06saini/bloodtrack-smartbloodinventory-allocationandrequestmanagementsystem/tree/main/frontend/src/components"
click node_hospitaldash "https://github.com/vansh06saini/bloodtrack-smartbloodinventory-allocationandrequestmanagementsystem/blob/main/frontend/src/pages/hospital/HospitalDashboard.jsx"
click node_requestcreate "https://github.com/vansh06saini/bloodtrack-smartbloodinventory-allocationandrequestmanagementsystem/blob/main/frontend/src/pages/hospital/CreateRequest.jsx"
click node_requestlist "https://github.com/vansh06saini/bloodtrack-smartbloodinventory-allocationandrequestmanagementsystem/blob/main/frontend/src/pages/hospital/MyRequests.jsx"
click node_requestdetail "https://github.com/vansh06saini/bloodtrack-smartbloodinventory-allocationandrequestmanagementsystem/blob/main/frontend/src/pages/hospital/RequestDetails.jsx"
click node_donation "https://github.com/vansh06saini/bloodtrack-smartbloodinventory-allocationandrequestmanagementsystem/blob/main/frontend/src/pages/hospital/DonateBlood.jsx"
click node_requestservice "https://github.com/vansh06saini/bloodtrack-smartbloodinventory-allocationandrequestmanagementsystem/blob/main/frontend/src/pages/hospital/requestService.js"
click node_admindash "https://github.com/vansh06saini/bloodtrack-smartbloodinventory-allocationandrequestmanagementsystem/blob/main/frontend/src/pages/admin/AdminDashboard.jsx"
click node_stockentry "https://github.com/vansh06saini/bloodtrack-smartbloodinventory-allocationandrequestmanagementsystem/blob/main/frontend/src/pages/admin/AddBloodUnits.jsx"
click node_dailylog "https://github.com/vansh06saini/bloodtrack-smartbloodinventory-allocationandrequestmanagementsystem/blob/main/frontend/src/pages/admin/DailyBloodLog.jsx"
click node_server "https://github.com/vansh06saini/bloodtrack-smartbloodinventory-allocationandrequestmanagementsystem/blob/main/backend/server.js"
click node_hospitalapi "https://github.com/vansh06saini/bloodtrack-smartbloodinventory-allocationandrequestmanagementsystem/blob/main/backend/controllers/hospitalController.js"
click node_bloodapi "https://github.com/vansh06saini/bloodtrack-smartbloodinventory-allocationandrequestmanagementsystem/blob/main/backend/controllers/bloodUnitController.js"
click node_donationapi "https://github.com/vansh06saini/bloodtrack-smartbloodinventory-allocationandrequestmanagementsystem/blob/main/backend/controllers/donationController.js"
click node_allocationapi "https://github.com/vansh06saini/bloodtrack-smartbloodinventory-allocationandrequestmanagementsystem/blob/main/backend/controllers/allocationController.js"
click node_allocationworker "https://github.com/vansh06saini/bloodtrack-smartbloodinventory-allocationandrequestmanagementsystem/blob/main/backend/workers/allocationWorker.js"
click node_allocation "https://github.com/vansh06saini/bloodtrack-smartbloodinventory-allocationandrequestmanagementsystem/blob/main/backend/services/allocationService.js"
click node_expiry "https://github.com/vansh06saini/bloodtrack-smartbloodinventory-allocationandrequestmanagementsystem/blob/main/backend/workers/expiryWorker.js"
click node_mysql "https://github.com/vansh06saini/bloodtrack-smartbloodinventory-allocationandrequestmanagementsystem/blob/main/backend/db.js"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_app,node_auth,node_hospitaldash,node_requestcreate,node_requestlist,node_requestdetail,node_donation,node_requestservice,node_admindash,node_stockentry,node_dailylog,node_user toneBlue
class node_server,node_hospitalapi,node_bloodapi,node_donationapi,node_allocationapi toneAmber
class node_allocationworker,node_allocation,node_expiry toneMint
class node_mysql toneRose
class node_admin toneIndigo
```

## Components

### Web portals

- [Portal routing](https://github.com/vansh06saini/bloodtrack-smartbloodinventory-allocationandrequestmanagementsystem/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Login and registration](https://github.com/vansh06saini/bloodtrack-smartbloodinventory-allocationandrequestmanagementsystem/tree/main/frontend/src/components): `frontend/src/components`
- [Hospital dashboard](https://github.com/vansh06saini/bloodtrack-smartbloodinventory-allocationandrequestmanagementsystem/blob/main/frontend/src/pages/hospital/HospitalDashboard.jsx): `frontend/src/pages/hospital/HospitalDashboard.jsx`
- [Create request](https://github.com/vansh06saini/bloodtrack-smartbloodinventory-allocationandrequestmanagementsystem/blob/main/frontend/src/pages/hospital/CreateRequest.jsx): `frontend/src/pages/hospital/CreateRequest.jsx`
- [Request tracking](https://github.com/vansh06saini/bloodtrack-smartbloodinventory-allocationandrequestmanagementsystem/blob/main/frontend/src/pages/hospital/MyRequests.jsx): `frontend/src/pages/hospital/MyRequests.jsx`
- [Request details](https://github.com/vansh06saini/bloodtrack-smartbloodinventory-allocationandrequestmanagementsystem/blob/main/frontend/src/pages/hospital/RequestDetails.jsx): `frontend/src/pages/hospital/RequestDetails.jsx`
- [Donation booking](https://github.com/vansh06saini/bloodtrack-smartbloodinventory-allocationandrequestmanagementsystem/blob/main/frontend/src/pages/hospital/DonateBlood.jsx): `frontend/src/pages/hospital/DonateBlood.jsx`
- [Request service](https://github.com/vansh06saini/bloodtrack-smartbloodinventory-allocationandrequestmanagementsystem/blob/main/frontend/src/pages/hospital/requestService.js): `frontend/src/pages/hospital/requestService.js`
- [Admin dashboard](https://github.com/vansh06saini/bloodtrack-smartbloodinventory-allocationandrequestmanagementsystem/blob/main/frontend/src/pages/admin/AdminDashboard.jsx): `frontend/src/pages/admin/AdminDashboard.jsx`
- [Add blood units](https://github.com/vansh06saini/bloodtrack-smartbloodinventory-allocationandrequestmanagementsystem/blob/main/frontend/src/pages/admin/AddBloodUnits.jsx): `frontend/src/pages/admin/AddBloodUnits.jsx`
- [Daily blood log](https://github.com/vansh06saini/bloodtrack-smartbloodinventory-allocationandrequestmanagementsystem/blob/main/frontend/src/pages/admin/DailyBloodLog.jsx): `frontend/src/pages/admin/DailyBloodLog.jsx`

### Backend API

- [HTTP server and auth](https://github.com/vansh06saini/bloodtrack-smartbloodinventory-allocationandrequestmanagementsystem/blob/main/backend/server.js): `backend/server.js`
- [Hospital requests](https://github.com/vansh06saini/bloodtrack-smartbloodinventory-allocationandrequestmanagementsystem/blob/main/backend/controllers/hospitalController.js): `backend/controllers/hospitalController.js`
- [Stock and logs API](https://github.com/vansh06saini/bloodtrack-smartbloodinventory-allocationandrequestmanagementsystem/blob/main/backend/controllers/bloodUnitController.js): `backend/controllers/bloodUnitController.js`
- [Donation appointments](https://github.com/vansh06saini/bloodtrack-smartbloodinventory-allocationandrequestmanagementsystem/blob/main/backend/controllers/donationController.js): `backend/controllers/donationController.js`
- [Allocation endpoint](https://github.com/vansh06saini/bloodtrack-smartbloodinventory-allocationandrequestmanagementsystem/blob/main/backend/controllers/allocationController.js): `backend/controllers/allocationController.js`

### Inventory operations

- [Allocation worker](https://github.com/vansh06saini/bloodtrack-smartbloodinventory-allocationandrequestmanagementsystem/blob/main/backend/workers/allocationWorker.js): `backend/workers/allocationWorker.js`
- [Priority allocation](https://github.com/vansh06saini/bloodtrack-smartbloodinventory-allocationandrequestmanagementsystem/blob/main/backend/services/allocationService.js): `backend/services/allocationService.js`
- [Expiry cleanup](https://github.com/vansh06saini/bloodtrack-smartbloodinventory-allocationandrequestmanagementsystem/blob/main/backend/workers/expiryWorker.js): `backend/workers/expiryWorker.js`

### Persistence

- [MySQL pool](https://github.com/vansh06saini/bloodtrack-smartbloodinventory-allocationandrequestmanagementsystem/blob/main/backend/db.js): `backend/db.js`

### Other components

- **Hospital user**
- **Blood-bank admin**

## Connections

- Hospital user → Portal routing: uses
- Blood-bank admin → Portal routing: uses
- Portal routing → Login and registration: routes to (evidence: `frontend/src/App.jsx`)
- Portal routing → Hospital dashboard: routes to (evidence: `frontend/src/App.jsx`)
- Portal routing → Create request: routes to (evidence: `frontend/src/App.jsx`)
- Portal routing → Request tracking: routes to (evidence: `frontend/src/App.jsx`)
- Portal routing → Request details: routes to (evidence: `frontend/src/App.jsx`)
- Portal routing → Donation booking: routes to (evidence: `frontend/src/App.jsx`)
- Portal routing → Admin dashboard: routes to (evidence: `frontend/src/App.jsx`)
- Portal routing → Add blood units: routes to (evidence: `frontend/src/App.jsx`)
- Portal routing → Daily blood log: routes to (evidence: `frontend/src/App.jsx`)
- Create request → Request service: uses
- Create request → Hospital requests: submits request
- Hospital dashboard → Hospital requests: loads summary
- Request tracking → Hospital requests: loads requests
- Request details → Hospital requests: loads details
- Donation booking → Donation appointments: books appointment
- Add blood units → Stock and logs API: adds units
- Admin dashboard → Stock and logs API: loads summary
- Daily blood log → Stock and logs API: loads logs
- HTTP server and auth → Hospital requests: routes requests (evidence: `backend/server.js`)
- HTTP server and auth → Stock and logs API: routes requests (evidence: `backend/server.js`)
- HTTP server and auth → Donation appointments: routes requests (evidence: `backend/server.js`)
- HTTP server and auth → Allocation endpoint: routes requests (evidence: `backend/server.js`)
- Hospital requests → MySQL pool: reads and writes (evidence: `backend/controllers/hospitalController.js`)
- Stock and logs API → MySQL pool: reads and writes (evidence: `backend/controllers/bloodUnitController.js`)
- Donation appointments → MySQL pool: reads and writes (evidence: `backend/controllers/donationController.js`)
- Allocation endpoint → Priority allocation: delegates (evidence: `backend/controllers/allocationController.js`)
- Hospital requests → Allocation worker: triggers emergency run (evidence: `backend/controllers/hospitalController.js`)
- HTTP server and auth → Allocation worker: starts worker (evidence: `backend/server.js`)
- HTTP server and auth → Expiry cleanup: starts worker (evidence: `backend/server.js`)
- Allocation worker → Priority allocation: processes requests (evidence: `backend/workers/allocationWorker.js`)
- Priority allocation → MySQL pool: allocates stock (evidence: `backend/services/allocationService.js`)
- Expiry cleanup → MySQL pool: expires units (evidence: `backend/workers/expiryWorker.js`)
