# mgp07/bloodbridge architecture

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

- Interactive diagram: https://gitdiagram.com/mgp07/bloodbridge
- Repository: https://github.com/mgp07/bloodbridge

## Overview

BloodBridge is a blood-donation portal with donor, patient, and hospital registration and role-based login, plus role-specific dashboards and donor discovery. The visible backend workflow routes authentication requests to controllers, which validate credentials or registration data and use role-specific models; the server connects to MongoDB. The frontend source files indicate additional dashboard and donor-search capabilities, but their request wiring was not excerpted, so those links are omitted. A separate MySQL helper is present, but its relationship to the main server is not shown.

Main entry points: [`backend/controllers/authController.js`](https://github.com/mgp07/bloodbridge/blob/main/backend/controllers/authController.js) (Auth controller), [`backend/server.js`](https://github.com/mgp07/bloodbridge/blob/main/backend/server.js) (API server), [`backend/routes/authRoutes.js`](https://github.com/mgp07/bloodbridge/blob/main/backend/routes/authRoutes.js) (Auth routes), [`backend/config/db.js`](https://github.com/mgp07/bloodbridge/blob/main/backend/config/db.js) (MySQL pool)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Portal interface"]
  node_registration["Registration UI<br/>[register.js]"]
  node_login["Login UI<br/>[login.js]"]
  node_donor_dashboard["Donor dashboard<br/>[donor-dashboard.js]"]
  node_patient_dashboard["Patient dashboard"]
  node_hospital_dashboard["Hospital dashboard"]
  node_admin_dashboard["Admin dashboard<br/>[admin-dashboard.js]"]
  node_donor_search["Donor search<br/>[find-donors.js]"]
end

subgraph group_auth["Authentication API"]
  node_api_server["API server<br/>[server.js]"]
  node_auth_routes["Auth routes<br/>[authRoutes.js]"]
  node_auth_controller["Auth controller<br/>[authController.js]"]
end

subgraph group_records["Domain records"]
  node_admin_record["Admin record<br/>[Admin.js]"]
  node_donor_record["Donor record<br/>[Donor.js]"]
  node_patient_record["Patient record<br/>[Patient.js]"]
  node_hospital_record["Hospital record<br/>[Hospital.js]"]
  node_blood_request["Blood request<br/>[BloodRequest.js]"]
  node_donation["Donation record<br/>[Donation.js]"]
end

subgraph group_persistence["Data connections"]
  node_mongo[("MongoDB")]
  node_mysql_config[("MySQL pool<br/>[db.js]")]
end

node_donor(("Donor"))
node_patient(("Patient"))
node_hospital(("Hospital"))

node_api_server -->|"mounts routes"| node_auth_routes
node_auth_routes -->|"dispatches auth"| node_auth_controller
node_auth_controller -->|"queries"| node_admin_record
node_auth_controller -->|"queries"| node_donor_record
node_auth_controller -->|"queries"| node_patient_record
node_auth_controller -->|"queries"| node_hospital_record
node_api_server -->|"connects"| node_mongo
node_mysql_config -.-> node_mysql_config

click node_registration "https://github.com/mgp07/bloodbridge/blob/main/register.js"
click node_login "https://github.com/mgp07/bloodbridge/blob/main/login.js"
click node_donor_dashboard "https://github.com/mgp07/bloodbridge/blob/main/donor-dashboard.js"
click node_patient_dashboard "https://github.com/mgp07/bloodbridge/blob/main/patient-dashboard.js"
click node_hospital_dashboard "https://github.com/mgp07/bloodbridge/blob/main/hospital-dashboard.js"
click node_admin_dashboard "https://github.com/mgp07/bloodbridge/blob/main/admin-dashboard.js"
click node_donor_search "https://github.com/mgp07/bloodbridge/blob/main/find-donors.js"
click node_api_server "https://github.com/mgp07/bloodbridge/blob/main/backend/server.js"
click node_auth_routes "https://github.com/mgp07/bloodbridge/blob/main/backend/routes/authRoutes.js"
click node_auth_controller "https://github.com/mgp07/bloodbridge/blob/main/backend/controllers/authController.js"
click node_admin_record "https://github.com/mgp07/bloodbridge/blob/main/backend/models/Admin.js"
click node_donor_record "https://github.com/mgp07/bloodbridge/blob/main/backend/models/Donor.js"
click node_patient_record "https://github.com/mgp07/bloodbridge/blob/main/backend/models/Patient.js"
click node_hospital_record "https://github.com/mgp07/bloodbridge/blob/main/backend/models/Hospital.js"
click node_blood_request "https://github.com/mgp07/bloodbridge/blob/main/backend/models/BloodRequest.js"
click node_donation "https://github.com/mgp07/bloodbridge/blob/main/backend/models/Donation.js"
click node_mysql_config "https://github.com/mgp07/bloodbridge/blob/main/backend/config/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_registration,node_login,node_donor_dashboard,node_patient_dashboard,node_hospital_dashboard,node_admin_dashboard,node_donor_search toneBlue
class node_api_server,node_auth_routes,node_auth_controller toneAmber
class node_admin_record,node_donor_record,node_patient_record,node_hospital_record,node_blood_request,node_donation toneMint
class node_mongo,node_mysql_config toneRose
class node_donor,node_patient,node_hospital toneIndigo
```

## Components

### Portal interface

- [Registration UI](https://github.com/mgp07/bloodbridge/blob/main/register.js): `register.js`
- [Login UI](https://github.com/mgp07/bloodbridge/blob/main/login.js): `login.js`
- [Donor dashboard](https://github.com/mgp07/bloodbridge/blob/main/donor-dashboard.js): `donor-dashboard.js`
- [Patient dashboard](https://github.com/mgp07/bloodbridge/blob/main/patient-dashboard.js): `patient-dashboard.js`
- [Hospital dashboard](https://github.com/mgp07/bloodbridge/blob/main/hospital-dashboard.js): `hospital-dashboard.js`
- [Admin dashboard](https://github.com/mgp07/bloodbridge/blob/main/admin-dashboard.js): `admin-dashboard.js`
- [Donor search](https://github.com/mgp07/bloodbridge/blob/main/find-donors.js): `find-donors.js`

### Authentication API

- [API server](https://github.com/mgp07/bloodbridge/blob/main/backend/server.js): `backend/server.js`
- [Auth routes](https://github.com/mgp07/bloodbridge/blob/main/backend/routes/authRoutes.js): `backend/routes/authRoutes.js`
- [Auth controller](https://github.com/mgp07/bloodbridge/blob/main/backend/controllers/authController.js): `backend/controllers/authController.js`

### Domain records

- [Admin record](https://github.com/mgp07/bloodbridge/blob/main/backend/models/Admin.js): `backend/models/Admin.js`
- [Donor record](https://github.com/mgp07/bloodbridge/blob/main/backend/models/Donor.js): `backend/models/Donor.js`
- [Patient record](https://github.com/mgp07/bloodbridge/blob/main/backend/models/Patient.js): `backend/models/Patient.js`
- [Hospital record](https://github.com/mgp07/bloodbridge/blob/main/backend/models/Hospital.js): `backend/models/Hospital.js`
- [Blood request](https://github.com/mgp07/bloodbridge/blob/main/backend/models/BloodRequest.js): `backend/models/BloodRequest.js`
- [Donation record](https://github.com/mgp07/bloodbridge/blob/main/backend/models/Donation.js): `backend/models/Donation.js`

### Data connections

- **MongoDB**
- [MySQL pool](https://github.com/mgp07/bloodbridge/blob/main/backend/config/db.js): `backend/config/db.js`

### Other components

- **Donor**
- **Patient**
- **Hospital**

## Connections

- API server → Auth routes: mounts routes (evidence: `backend/server.js`)
- Auth routes → Auth controller: dispatches auth (evidence: `backend/routes/authRoutes.js`)
- Auth controller → Admin record: queries (evidence: `backend/controllers/authController.js`)
- Auth controller → Donor record: queries (evidence: `backend/controllers/authController.js`)
- Auth controller → Patient record: queries (evidence: `backend/controllers/authController.js`)
- Auth controller → Hospital record: queries (evidence: `backend/controllers/authController.js`)
- API server → MongoDB: connects (evidence: `backend/server.js`)
- MySQL pool → MySQL pool (evidence: `backend/config/db.js`)
