# muthuvelr100-jpg/bloodlink architecture

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

- Interactive diagram: https://gitdiagram.com/muthuvelr100-jpg/bloodlink
- Repository: https://github.com/muthuvelr100-jpg/bloodlink

## Overview

BloodLink is a role-based blood donation and request-management application. A patient submits a blood request, finds and invites matching donors, and tracks responses; an accepting donor reveals contact details, and a blood bank can record the donation to complete the request. Donors also manage availability and history, while banks and admins handle inventory, verification, complaints, emergency requests, rewards, and certificates. The graph follows the documented workflow and indexed frontend/backend modules; unsampled implementation details are represented at subsystem level.

Main entry points: [`server/src/config/supabase.js`](https://github.com/muthuvelr100-jpg/bloodlink/blob/main/server/src/config/supabase.js) (Supabase database and auth), [`server/src/index.js`](https://github.com/muthuvelr100-jpg/bloodlink/blob/main/server/src/index.js) (Express API), [`server/src/routes/donor.js`](https://github.com/muthuvelr100-jpg/bloodlink/blob/main/server/src/routes/donor.js) (Donor endpoints), [`server/src/routes/bloodbank.js`](https://github.com/muthuvelr100-jpg/bloodlink/blob/main/server/src/routes/bloodbank.js) (Bank endpoints)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Web application"]
  node_web_app["Role-based app<br/>[App.jsx]"]
  node_auth_state["Session and profile<br/>[AuthContext.jsx]"]
  node_patient_requests["Request workflow<br/>[RequestStatus.jsx]"]
  node_request_form["Request submission"]
  node_donor_matching["Donor matching"]
  node_donor_profile["Donor profile<br/>[DonorProfile.jsx]"]
  node_bank_admin_ui["Bank and admin tools<br/>[RecordDonation.jsx]"]
  node_api_client["Authenticated API client<br/>[api.js]"]
  node_request_service["Request service<br/>[requestService.js]"]
  node_donor_service["Donor service<br/>[donorService.js]"]
  node_bank_service["Bank service"]
end

subgraph group_api["API and access"]
  node_api_entry["Express API<br/>[index.js]"]
  node_auth_guard["Identity and role checks<br/>[auth.js]"]
  node_patient_routes["Patient endpoints<br/>[patient.js]"]
  node_donor_routes["Donor endpoints<br/>[donor.js]"]
  node_bank_routes["Bank endpoints<br/>[bloodbank.js]"]
  node_admin_routes["Admin endpoints<br/>[admin.js]"]
  node_shared_routes["Common endpoints<br/>[common.js]"]
end

subgraph group_operations["Donation operations"]
  node_request_logic["Request coordination<br/>[requests.js]"]
  node_notifications["Notifications<br/>[notify.js]"]
  node_rewards["Rewards and certificates<br/>[rewards.js]"]
end

subgraph group_platform["Data and integrations"]
  node_supabase[("Supabase database and auth<br/>[supabase.js]")]
  node_resend["Resend email"]
end

node_patient(("Patient"))
node_donor(("Donor"))
node_bank_staff(("Blood bank staff"))
node_administrator(("Administrator"))

node_patient -->|"uses"| node_web_app
node_donor -->|"uses"| node_web_app
node_bank_staff -->|"uses"| node_web_app
node_administrator -->|"uses"| node_web_app
node_web_app -->|"provides session"| node_auth_state
node_auth_state -->|"loads profile"| node_api_client
node_auth_state -->|"checks session"| node_supabase
node_patient -->|"submits request"| node_request_form
node_request_form -->|"calls"| node_request_service
node_patient_requests -->|"loads status"| node_request_service
node_donor_matching -->|"loads matches"| node_donor_service
node_donor -->|"responds"| node_donor_matching
node_donor_profile -->|"updates profile"| node_donor_service
node_bank_admin_ui -->|"records donation"| node_bank_service
node_request_service -->|"calls"| node_api_client
node_donor_service -->|"calls"| node_api_client
node_bank_service -->|"calls"| node_api_client
node_api_client -->|"sends HTTP"| node_api_entry
node_api_entry -->|"routes"| node_patient_routes
node_api_entry -->|"routes"| node_donor_routes
node_api_entry -->|"routes"| node_bank_routes
node_api_entry -->|"routes"| node_admin_routes
node_api_entry -->|"routes"| node_shared_routes
node_patient_routes -->|"checks access"| node_auth_guard
node_donor_routes -->|"checks access"| node_auth_guard
node_bank_routes -->|"checks access"| node_auth_guard
node_admin_routes -->|"checks access"| node_auth_guard
node_shared_routes -->|"checks access"| node_auth_guard
node_auth_guard -->|"verifies token"| node_supabase
node_patient_routes -->|"reads and writes"| node_supabase
node_donor_routes -->|"reads and writes"| node_supabase
node_bank_routes -->|"reads and writes"| node_supabase
node_admin_routes -->|"reads and writes"| node_supabase
node_shared_routes -->|"reads and writes"| node_supabase
node_patient_routes -->|"delegates"| node_request_logic
node_donor_routes -->|"delegates"| node_request_logic
node_bank_routes -->|"delegates"| node_request_logic
node_patient_routes -->|"notifies"| node_notifications
node_donor_routes -->|"notifies"| node_notifications
node_bank_routes -->|"notifies"| node_notifications
node_admin_routes -->|"notifies"| node_notifications
node_donor_routes -->|"uses rewards"| node_rewards
node_bank_routes -->|"issues rewards"| node_rewards
node_notifications -->|"stores alerts"| node_supabase
node_notifications -.->|"sends optional email"| node_resend
node_bank_staff -->|"records donation"| node_bank_admin_ui
node_administrator -->|"manages operations"| node_bank_admin_ui

click node_web_app "https://github.com/muthuvelr100-jpg/bloodlink/blob/main/src/App.jsx"
click node_auth_state "https://github.com/muthuvelr100-jpg/bloodlink/blob/main/src/context/AuthContext.jsx"
click node_patient_requests "https://github.com/muthuvelr100-jpg/bloodlink/blob/main/src/pages/patient/RequestStatus.jsx"
click node_request_form "https://github.com/muthuvelr100-jpg/bloodlink/blob/main/src/components/patient/BloodRequestForm.jsx"
click node_donor_matching "https://github.com/muthuvelr100-jpg/bloodlink/blob/main/src/pages/donor/MatchingRequests.jsx"
click node_donor_profile "https://github.com/muthuvelr100-jpg/bloodlink/blob/main/src/pages/donor/DonorProfile.jsx"
click node_bank_admin_ui "https://github.com/muthuvelr100-jpg/bloodlink/blob/main/src/pages/admin/RecordDonation.jsx"
click node_api_client "https://github.com/muthuvelr100-jpg/bloodlink/blob/main/src/lib/api.js"
click node_request_service "https://github.com/muthuvelr100-jpg/bloodlink/blob/main/src/services/requestService.js"
click node_donor_service "https://github.com/muthuvelr100-jpg/bloodlink/blob/main/src/services/donorService.js"
click node_bank_service "https://github.com/muthuvelr100-jpg/bloodlink/blob/main/src/services/bloodBankService.js"
click node_api_entry "https://github.com/muthuvelr100-jpg/bloodlink/blob/main/server/src/index.js"
click node_auth_guard "https://github.com/muthuvelr100-jpg/bloodlink/blob/main/server/src/middleware/auth.js"
click node_patient_routes "https://github.com/muthuvelr100-jpg/bloodlink/blob/main/server/src/routes/patient.js"
click node_donor_routes "https://github.com/muthuvelr100-jpg/bloodlink/blob/main/server/src/routes/donor.js"
click node_bank_routes "https://github.com/muthuvelr100-jpg/bloodlink/blob/main/server/src/routes/bloodbank.js"
click node_admin_routes "https://github.com/muthuvelr100-jpg/bloodlink/blob/main/server/src/routes/admin.js"
click node_shared_routes "https://github.com/muthuvelr100-jpg/bloodlink/blob/main/server/src/routes/common.js"
click node_request_logic "https://github.com/muthuvelr100-jpg/bloodlink/blob/main/server/src/services/requests.js"
click node_notifications "https://github.com/muthuvelr100-jpg/bloodlink/blob/main/server/src/services/notify.js"
click node_rewards "https://github.com/muthuvelr100-jpg/bloodlink/blob/main/server/src/services/rewards.js"
click node_supabase "https://github.com/muthuvelr100-jpg/bloodlink/blob/main/server/src/config/supabase.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_web_app,node_auth_state,node_patient_requests,node_request_form,node_donor_matching,node_donor_profile,node_bank_admin_ui,node_api_client,node_request_service,node_donor_service,node_bank_service toneBlue
class node_api_entry,node_auth_guard,node_patient_routes,node_donor_routes,node_bank_routes,node_admin_routes,node_shared_routes toneAmber
class node_request_logic,node_notifications,node_rewards toneMint
class node_supabase,node_resend toneRose
class node_patient,node_donor,node_bank_staff,node_administrator toneIndigo
```

## Components

### Web application

- [Role-based app](https://github.com/muthuvelr100-jpg/bloodlink/blob/main/src/App.jsx): `src/App.jsx`
- [Session and profile](https://github.com/muthuvelr100-jpg/bloodlink/blob/main/src/context/AuthContext.jsx): `src/context/AuthContext.jsx`
- [Request workflow](https://github.com/muthuvelr100-jpg/bloodlink/blob/main/src/pages/patient/RequestStatus.jsx): `src/pages/patient/RequestStatus.jsx`
- [Request submission](https://github.com/muthuvelr100-jpg/bloodlink/blob/main/src/components/patient/BloodRequestForm.jsx): `src/components/patient/BloodRequestForm.jsx`
- [Donor matching](https://github.com/muthuvelr100-jpg/bloodlink/blob/main/src/pages/donor/MatchingRequests.jsx): `src/pages/donor/MatchingRequests.jsx`
- [Donor profile](https://github.com/muthuvelr100-jpg/bloodlink/blob/main/src/pages/donor/DonorProfile.jsx): `src/pages/donor/DonorProfile.jsx`
- [Bank and admin tools](https://github.com/muthuvelr100-jpg/bloodlink/blob/main/src/pages/admin/RecordDonation.jsx): `src/pages/admin/RecordDonation.jsx`
- [Authenticated API client](https://github.com/muthuvelr100-jpg/bloodlink/blob/main/src/lib/api.js): `src/lib/api.js`
- [Request service](https://github.com/muthuvelr100-jpg/bloodlink/blob/main/src/services/requestService.js): `src/services/requestService.js`
- [Donor service](https://github.com/muthuvelr100-jpg/bloodlink/blob/main/src/services/donorService.js): `src/services/donorService.js`
- [Bank service](https://github.com/muthuvelr100-jpg/bloodlink/blob/main/src/services/bloodBankService.js): `src/services/bloodBankService.js`

### API and access

- [Express API](https://github.com/muthuvelr100-jpg/bloodlink/blob/main/server/src/index.js): `server/src/index.js`
- [Identity and role checks](https://github.com/muthuvelr100-jpg/bloodlink/blob/main/server/src/middleware/auth.js): `server/src/middleware/auth.js`
- [Patient endpoints](https://github.com/muthuvelr100-jpg/bloodlink/blob/main/server/src/routes/patient.js): `server/src/routes/patient.js`
- [Donor endpoints](https://github.com/muthuvelr100-jpg/bloodlink/blob/main/server/src/routes/donor.js): `server/src/routes/donor.js`
- [Bank endpoints](https://github.com/muthuvelr100-jpg/bloodlink/blob/main/server/src/routes/bloodbank.js): `server/src/routes/bloodbank.js`
- [Admin endpoints](https://github.com/muthuvelr100-jpg/bloodlink/blob/main/server/src/routes/admin.js): `server/src/routes/admin.js`
- [Common endpoints](https://github.com/muthuvelr100-jpg/bloodlink/blob/main/server/src/routes/common.js): `server/src/routes/common.js`

### Donation operations

- [Request coordination](https://github.com/muthuvelr100-jpg/bloodlink/blob/main/server/src/services/requests.js): `server/src/services/requests.js`
- [Notifications](https://github.com/muthuvelr100-jpg/bloodlink/blob/main/server/src/services/notify.js): `server/src/services/notify.js`
- [Rewards and certificates](https://github.com/muthuvelr100-jpg/bloodlink/blob/main/server/src/services/rewards.js): `server/src/services/rewards.js`

### Data and integrations

- [Supabase database and auth](https://github.com/muthuvelr100-jpg/bloodlink/blob/main/server/src/config/supabase.js): `server/src/config/supabase.js`
- **Resend email**

### Other components

- **Patient**
- **Donor**
- **Blood bank staff**
- **Administrator**

## Connections

- Patient → Role-based app: uses (evidence: `src/App.jsx`)
- Donor → Role-based app: uses (evidence: `src/App.jsx`)
- Blood bank staff → Role-based app: uses (evidence: `src/App.jsx`)
- Administrator → Role-based app: uses (evidence: `src/App.jsx`)
- Role-based app → Session and profile: provides session (evidence: `src/main.jsx`)
- Session and profile → Authenticated API client: loads profile (evidence: `src/context/AuthContext.jsx`)
- Session and profile → Supabase database and auth: checks session (evidence: `src/context/AuthContext.jsx`)
- Patient → Request submission: submits request (evidence: `README.md`)
- Request submission → Request service: calls (evidence: `src/components/patient/BloodRequestForm.jsx`)
- Request workflow → Request service: loads status (evidence: `src/pages/patient/RequestStatus.jsx`)
- Donor matching → Donor service: loads matches (evidence: `src/pages/donor/MatchingRequests.jsx`)
- Donor → Donor matching: responds (evidence: `README.md`)
- Donor profile → Donor service: updates profile (evidence: `src/pages/donor/DonorProfile.jsx`)
- Bank and admin tools → Bank service: records donation (evidence: `src/pages/admin/RecordDonation.jsx`)
- Request service → Authenticated API client: calls (evidence: `src/services/requestService.js`)
- Donor service → Authenticated API client: calls (evidence: `src/services/donorService.js`)
- Bank service → Authenticated API client: calls (evidence: `src/services/bloodBankService.js`)
- Authenticated API client → Express API: sends HTTP (evidence: `src/lib/api.js`)
- Express API → Patient endpoints: routes (evidence: `server/src/index.js`)
- Express API → Donor endpoints: routes (evidence: `server/src/index.js`)
- Express API → Bank endpoints: routes (evidence: `server/src/index.js`)
- Express API → Admin endpoints: routes (evidence: `server/src/index.js`)
- Express API → Common endpoints: routes (evidence: `server/src/index.js`)
- Patient endpoints → Identity and role checks: checks access (evidence: `server/src/routes/patient.js`)
- Donor endpoints → Identity and role checks: checks access (evidence: `server/src/routes/donor.js`)
- Bank endpoints → Identity and role checks: checks access (evidence: `server/src/routes/bloodbank.js`)
- Admin endpoints → Identity and role checks: checks access (evidence: `server/src/routes/admin.js`)
- Common endpoints → Identity and role checks: checks access (evidence: `server/src/routes/common.js`)
- Identity and role checks → Supabase database and auth: verifies token (evidence: `server/src/middleware/auth.js`)
- Patient endpoints → Supabase database and auth: reads and writes (evidence: `server/src/routes/patient.js`)
- Donor endpoints → Supabase database and auth: reads and writes (evidence: `server/src/routes/donor.js`)
- Bank endpoints → Supabase database and auth: reads and writes (evidence: `server/src/routes/bloodbank.js`)
- Admin endpoints → Supabase database and auth: reads and writes (evidence: `server/src/routes/admin.js`)
- Common endpoints → Supabase database and auth: reads and writes (evidence: `server/src/routes/common.js`)
- Patient endpoints → Request coordination: delegates (evidence: `server/src/routes/patient.js`)
- Donor endpoints → Request coordination: delegates (evidence: `server/src/routes/donor.js`)
- Bank endpoints → Request coordination: delegates (evidence: `server/src/routes/bloodbank.js`)
- Patient endpoints → Notifications: notifies (evidence: `server/src/routes/patient.js`)
- Donor endpoints → Notifications: notifies (evidence: `server/src/routes/donor.js`)
- Bank endpoints → Notifications: notifies (evidence: `server/src/routes/bloodbank.js`)
- Admin endpoints → Notifications: notifies (evidence: `server/src/routes/admin.js`)
- Donor endpoints → Rewards and certificates: uses rewards (evidence: `server/src/routes/donor.js`)
- Bank endpoints → Rewards and certificates: issues rewards (evidence: `server/src/routes/bloodbank.js`)
- Notifications → Supabase database and auth: stores alerts (evidence: `server/src/services/notify.js`)
- Notifications → Resend email: sends optional email (evidence: `server/src/services/notify.js`)
- Blood bank staff → Bank and admin tools: records donation (evidence: `README.md`)
- Administrator → Bank and admin tools: manages operations (evidence: `README.md`)
