# jhaabhay7667-cyber/medibridge architecture

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

- Interactive diagram: https://gitdiagram.com/jhaabhay7667-cyber/medibridge
- Repository: https://github.com/jhaabhay7667-cyber/medibridge

## Overview

MediBridge is an emergency coordination and information platform, not an emergency-services dispatch system. The main workflow is a user signing in, recording an emergency, coordinating contacts and facilities, and reviewing its status and timeline. The graph includes documented frontend capabilities and the sampled backend ownership paths. Frontend-to-API links reflect README documentation; unsampled frontend internals are not inferred.

Main entry points: [`backend/app/main.py`](https://github.com/jhaabhay7667-cyber/medibridge/blob/main/backend/app/main.py) (FastAPI Application), [`backend/app/database.py`](https://github.com/jhaabhay7667-cyber/medibridge/blob/main/backend/app/database.py) (Database Sessions), [`backend/app/routers/emergencies.py`](https://github.com/jhaabhay7667-cyber/medibridge/blob/main/backend/app/routers/emergencies.py) (Emergency Lifecycle), [`backend/app/auth.py`](https://github.com/jhaabhay7667-cyber/medibridge/blob/main/backend/app/auth.py) (Token and Password Auth)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["User Interface"]
  node_dashboard["SOS Dashboard<br/>[dashboard.js]"]
  node_emergency_view["Emergency View<br/>[emergency.js]"]
  node_history["History Search<br/>[history.js]"]
  node_contacts_view["Contacts UI<br/>[contacts.js]"]
  node_facilities_view["Facility Search UI<br/>[facilities.js]"]
  node_shared_ui["Shared UI<br/>[app.js]"]
end

subgraph group_api["API and Identity"]
  node_api_app["FastAPI Application<br/>[main.py]"]
  node_auth_routes["Authentication Routes<br/>[auth.py]"]
  node_identity["Token and Password Auth<br/>[auth.py]"]
  node_schemas["Request and Response Types<br/>[schemas.py]"]
end

subgraph group_coordination["Emergency Coordination"]
  node_contact_routes["Contact Management<br/>[contacts.py]"]
  node_emergency_routes["Emergency Lifecycle<br/>[emergencies.py]"]
  node_facility_routes["Facility Search<br/>[facilities.py]"]
end

subgraph group_records["Persistent Data"]
  node_models["Domain Records<br/>[models.py]"]
  node_db_session["Database Sessions<br/>[database.py]"]
  node_database[("SQL Database")]
  node_facility_seed["Demo Facility Seed<br/>[seed_facilities.py]"]
end

subgraph group_messaging["Notifications"]
  node_email_service["Email Delivery<br/>[notify.py]"]
  node_mail_provider["Brevo or SMTP"]
end

node_user(("User"))

node_user -->|"starts SOS"| node_dashboard
node_user -->|"manages incident"| node_emergency_view
node_user -->|"filters history"| node_history
node_user -->|"manages contacts"| node_contacts_view
node_user -->|"searches facilities"| node_facilities_view
node_dashboard -->|"calls API"| node_api_app
node_emergency_view -->|"calls API"| node_api_app
node_history -->|"calls API"| node_api_app
node_contacts_view -->|"calls API"| node_api_app
node_facilities_view -->|"calls API"| node_api_app
node_shared_ui -.->|"configures API base"| node_api_app
node_api_app -->|"registers router"| node_auth_routes
node_api_app -->|"registers router"| node_contact_routes
node_api_app -->|"registers router"| node_emergency_routes
node_api_app -->|"registers router"| node_facility_routes
node_auth_routes -->|"uses auth functions"| node_identity
node_auth_routes -->|"opens sessions"| node_db_session
node_contact_routes -->|"requires user"| node_identity
node_contact_routes -->|"opens sessions"| node_db_session
node_emergency_routes -->|"requires user"| node_identity
node_emergency_routes -->|"opens sessions"| node_db_session
node_facility_routes -->|"requires user"| node_identity
node_facility_routes -->|"opens sessions"| node_db_session
node_auth_routes -->|"validates and shapes"| node_schemas
node_contact_routes -->|"validates and shapes"| node_schemas
node_emergency_routes -->|"validates and shapes"| node_schemas
node_facility_routes -->|"shapes results"| node_schemas
node_identity -->|"loads user"| node_db_session
node_identity -->|"checks user record"| node_models
node_auth_routes -->|"reads and writes users"| node_models
node_contact_routes -->|"reads and writes contacts"| node_models
node_emergency_routes -->|"records incident state"| node_models
node_facility_routes -->|"queries facilities"| node_models
node_db_session -->|"connects"| node_database
node_api_app -->|"runs seed"| node_facility_seed
node_facility_seed -->|"writes demo facilities"| node_db_session
node_emergency_routes -->|"sends contact alerts"| node_email_service
node_email_service -->|"delivers email"| node_mail_provider

click node_dashboard "https://github.com/jhaabhay7667-cyber/medibridge/blob/main/frontend/dashboard.js"
click node_emergency_view "https://github.com/jhaabhay7667-cyber/medibridge/blob/main/frontend/emergency.js"
click node_history "https://github.com/jhaabhay7667-cyber/medibridge/blob/main/frontend/history.js"
click node_contacts_view "https://github.com/jhaabhay7667-cyber/medibridge/blob/main/frontend/contacts.js"
click node_facilities_view "https://github.com/jhaabhay7667-cyber/medibridge/blob/main/frontend/facilities.js"
click node_shared_ui "https://github.com/jhaabhay7667-cyber/medibridge/blob/main/frontend/app.js"
click node_api_app "https://github.com/jhaabhay7667-cyber/medibridge/blob/main/backend/app/main.py"
click node_auth_routes "https://github.com/jhaabhay7667-cyber/medibridge/blob/main/backend/app/routers/auth.py"
click node_identity "https://github.com/jhaabhay7667-cyber/medibridge/blob/main/backend/app/auth.py"
click node_contact_routes "https://github.com/jhaabhay7667-cyber/medibridge/blob/main/backend/app/routers/contacts.py"
click node_emergency_routes "https://github.com/jhaabhay7667-cyber/medibridge/blob/main/backend/app/routers/emergencies.py"
click node_facility_routes "https://github.com/jhaabhay7667-cyber/medibridge/blob/main/backend/app/routers/facilities.py"
click node_email_service "https://github.com/jhaabhay7667-cyber/medibridge/blob/main/backend/app/services/notify.py"
click node_schemas "https://github.com/jhaabhay7667-cyber/medibridge/blob/main/backend/app/schemas.py"
click node_models "https://github.com/jhaabhay7667-cyber/medibridge/blob/main/backend/app/models.py"
click node_db_session "https://github.com/jhaabhay7667-cyber/medibridge/blob/main/backend/app/database.py"
click node_facility_seed "https://github.com/jhaabhay7667-cyber/medibridge/blob/main/backend/app/seed_facilities.py"

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_dashboard,node_emergency_view,node_history,node_contacts_view,node_facilities_view,node_shared_ui,node_user toneBlue
class node_api_app,node_auth_routes,node_identity,node_schemas toneAmber
class node_contact_routes,node_emergency_routes,node_facility_routes toneMint
class node_models,node_db_session,node_database,node_facility_seed toneRose
class node_email_service,node_mail_provider toneIndigo
```

## Components

### User Interface

- [SOS Dashboard](https://github.com/jhaabhay7667-cyber/medibridge/blob/main/frontend/dashboard.js): `frontend/dashboard.js`
- [Emergency View](https://github.com/jhaabhay7667-cyber/medibridge/blob/main/frontend/emergency.js): `frontend/emergency.js`
- [History Search](https://github.com/jhaabhay7667-cyber/medibridge/blob/main/frontend/history.js): `frontend/history.js`
- [Contacts UI](https://github.com/jhaabhay7667-cyber/medibridge/blob/main/frontend/contacts.js): `frontend/contacts.js`
- [Facility Search UI](https://github.com/jhaabhay7667-cyber/medibridge/blob/main/frontend/facilities.js): `frontend/facilities.js`
- [Shared UI](https://github.com/jhaabhay7667-cyber/medibridge/blob/main/frontend/app.js): `frontend/app.js`

### API and Identity

- [FastAPI Application](https://github.com/jhaabhay7667-cyber/medibridge/blob/main/backend/app/main.py): `backend/app/main.py`
- [Authentication Routes](https://github.com/jhaabhay7667-cyber/medibridge/blob/main/backend/app/routers/auth.py): `backend/app/routers/auth.py`
- [Token and Password Auth](https://github.com/jhaabhay7667-cyber/medibridge/blob/main/backend/app/auth.py): `backend/app/auth.py`
- [Request and Response Types](https://github.com/jhaabhay7667-cyber/medibridge/blob/main/backend/app/schemas.py): `backend/app/schemas.py`

### Emergency Coordination

- [Contact Management](https://github.com/jhaabhay7667-cyber/medibridge/blob/main/backend/app/routers/contacts.py): `backend/app/routers/contacts.py`
- [Emergency Lifecycle](https://github.com/jhaabhay7667-cyber/medibridge/blob/main/backend/app/routers/emergencies.py): `backend/app/routers/emergencies.py`
- [Facility Search](https://github.com/jhaabhay7667-cyber/medibridge/blob/main/backend/app/routers/facilities.py): `backend/app/routers/facilities.py`

### Persistent Data

- [Domain Records](https://github.com/jhaabhay7667-cyber/medibridge/blob/main/backend/app/models.py): `backend/app/models.py`
- [Database Sessions](https://github.com/jhaabhay7667-cyber/medibridge/blob/main/backend/app/database.py): `backend/app/database.py`
- **SQL Database**
- [Demo Facility Seed](https://github.com/jhaabhay7667-cyber/medibridge/blob/main/backend/app/seed_facilities.py): `backend/app/seed_facilities.py`

### Notifications

- [Email Delivery](https://github.com/jhaabhay7667-cyber/medibridge/blob/main/backend/app/services/notify.py): `backend/app/services/notify.py`
- **Brevo or SMTP**

### Other components

- **User**

## Connections

- User → SOS Dashboard: starts SOS (evidence: `README.md`)
- User → Emergency View: manages incident (evidence: `README.md`)
- User → History Search: filters history (evidence: `README.md`)
- User → Contacts UI: manages contacts (evidence: `README.md`)
- User → Facility Search UI: searches facilities (evidence: `README.md`)
- SOS Dashboard → FastAPI Application: calls API (evidence: `README.md`)
- Emergency View → FastAPI Application: calls API (evidence: `README.md`)
- History Search → FastAPI Application: calls API (evidence: `README.md`)
- Contacts UI → FastAPI Application: calls API (evidence: `README.md`)
- Facility Search UI → FastAPI Application: calls API (evidence: `README.md`)
- Shared UI → FastAPI Application: configures API base (evidence: `README.md`)
- FastAPI Application → Authentication Routes: registers router (evidence: `backend/app/main.py`)
- FastAPI Application → Contact Management: registers router (evidence: `backend/app/main.py`)
- FastAPI Application → Emergency Lifecycle: registers router (evidence: `backend/app/main.py`)
- FastAPI Application → Facility Search: registers router (evidence: `backend/app/main.py`)
- Authentication Routes → Token and Password Auth: uses auth functions (evidence: `backend/app/routers/auth.py`)
- Authentication Routes → Database Sessions: opens sessions (evidence: `backend/app/routers/auth.py`)
- Contact Management → Token and Password Auth: requires user (evidence: `backend/app/routers/contacts.py`)
- Contact Management → Database Sessions: opens sessions (evidence: `backend/app/routers/contacts.py`)
- Emergency Lifecycle → Token and Password Auth: requires user (evidence: `backend/app/routers/emergencies.py`)
- Emergency Lifecycle → Database Sessions: opens sessions (evidence: `backend/app/routers/emergencies.py`)
- Facility Search → Token and Password Auth: requires user (evidence: `backend/app/routers/facilities.py`)
- Facility Search → Database Sessions: opens sessions (evidence: `backend/app/routers/facilities.py`)
- Authentication Routes → Request and Response Types: validates and shapes (evidence: `backend/app/routers/auth.py`)
- Contact Management → Request and Response Types: validates and shapes (evidence: `backend/app/routers/contacts.py`)
- Emergency Lifecycle → Request and Response Types: validates and shapes (evidence: `backend/app/routers/emergencies.py`)
- Facility Search → Request and Response Types: shapes results (evidence: `backend/app/routers/facilities.py`)
- Token and Password Auth → Database Sessions: loads user (evidence: `backend/app/auth.py`)
- Token and Password Auth → Domain Records: checks user record (evidence: `backend/app/auth.py`)
- Authentication Routes → Domain Records: reads and writes users (evidence: `backend/app/routers/auth.py`)
- Contact Management → Domain Records: reads and writes contacts (evidence: `backend/app/routers/contacts.py`)
- Emergency Lifecycle → Domain Records: records incident state (evidence: `backend/app/routers/emergencies.py`)
- Facility Search → Domain Records: queries facilities (evidence: `backend/app/routers/facilities.py`)
- Database Sessions → SQL Database: connects (evidence: `backend/app/database.py`)
- FastAPI Application → Demo Facility Seed: runs seed (evidence: `backend/app/main.py`)
- Demo Facility Seed → Database Sessions: writes demo facilities (evidence: `backend/app/seed_facilities.py`)
- Emergency Lifecycle → Email Delivery: sends contact alerts (evidence: `backend/app/routers/emergencies.py`)
- Email Delivery → Brevo or SMTP: delivers email (evidence: `backend/app/services/notify.py`)
