# tabeebai/backend-tabeebai architecture

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

- Interactive diagram: https://gitdiagram.com/tabeebai/backend-tabeebai
- Repository: https://github.com/tabeebai/backend-tabeebai

## Overview

TabebAI is a healthcare management API for patients, doctors, and laboratory technicians. Users register or sign in, maintain profiles, and use QR-linked visits to share treatment and laboratory results; the platform also exposes notifications, wearable vital readings, cardiac-risk predictions, and X-ray prediction. The sampled files show the main routing and several data paths, but not all QR, wearable, or imaging implementation details, so uncertain connections are omitted or marked unverified.

Main entry points: [`TabebAI/urls.py`](https://github.com/tabeebai/backend-tabeebai/blob/main/TabebAI/urls.py) (API Routes), [`QR/views.py`](https://github.com/tabeebai/backend-tabeebai/blob/main/QR/views.py) (QR Visit Workflow), [`Patients/views.py`](https://github.com/tabeebai/backend-tabeebai/blob/main/Patients/views.py) (Patient API), [`Patients/models.py`](https://github.com/tabeebai/backend-tabeebai/blob/main/Patients/models.py) (Patient Records)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_access["Access and Profiles"]
  node_patient_api["Patient API<br/>[views.py]"]
  node_patient_data[("Patient Records<br/>[models.py]")]
  node_patient_serializers["Patient Serializers<br/>[serializers.py]"]
  node_patient_signals["Patient Signals<br/>[signals.py]"]
  node_doctor_api["Doctor API<br/>[views.py]"]
  node_doctor_data[("Doctor Records<br/>[models.py]")]
  node_doctor_serializers["Doctor Serializers<br/>[serializers.py]"]
  node_lab_api["Lab Technician API<br/>[views.py]"]
  node_lab_data[("Lab Records<br/>[models.py]")]
  node_lab_serializers["Lab Serializers<br/>[serializers.py]"]
  node_admin_api["Admin API<br/>[views.py]"]
  node_admin_serializers["Admin Serializers<br/>[serializers.py]"]
end

subgraph group_care["Visits and Lab Work"]
  node_qr_workflow["QR Visit Workflow<br/>[views.py]"]
  node_qr_data[("Visit and Session Records<br/>[models.py]")]
  node_qr_serializers["QR Serializers<br/>[serializers.py]"]
end

subgraph group_health["Patient Health"]
  node_watch_api["Wearable API<br/>[views.py]"]
  node_vitals[("Vital Sign Records<br/>[models.py]")]
  node_ble["BLE Service<br/>[ble_service.py]"]
  node_risk_api["Risk and Charts<br/>[views.py]"]
  node_risk_data[("Risk Results<br/>[models.py]")]
  node_xray_api["X-ray Prediction<br/>[views.py]"]
  node_xray_loader["Model Loader<br/>[model_loader.py]"]
  node_xray_transforms["Image Transforms<br/>[transforms.py]"]
end

subgraph group_realtime["Notifications"]
  node_qr_api["Notification API<br/>[api.py]"]
  node_notification_socket["Notification Consumer<br/>[consumers.py]"]
  node_socket_routes["WebSocket Routes<br/>[routing.py]"]
end

node_client(("API Client"))
node_routes["API Routes<br/>[urls.py]"]
node_n8n["n8n Webhook"]

node_client -->|"sends requests"| node_routes
node_routes -->|"routes to"| node_patient_api
node_routes -->|"routes to"| node_doctor_api
node_routes -->|"routes to"| node_lab_api
node_routes -->|"routes to"| node_admin_api
node_routes -->|"routes to"| node_qr_workflow
node_routes -->|"routes to"| node_qr_api
node_routes -->|"routes to"| node_watch_api
node_routes -->|"routes to"| node_risk_api
node_routes -->|"routes to"| node_xray_api
node_patient_api -->|"validates with"| node_patient_serializers
node_patient_api -->|"reads and writes"| node_patient_data
node_patient_api -->|"searches"| node_doctor_data
node_patient_api -->|"searches"| node_lab_data
node_patient_api -->|"posts question"| node_n8n
node_patient_signals -->|"uses model"| node_patient_data
node_doctor_api -->|"uses"| node_doctor_serializers
node_doctor_serializers -->|"serializes"| node_doctor_data
node_lab_api -->|"uses"| node_lab_serializers
node_lab_serializers -->|"serializes"| node_lab_data
node_admin_api -->|"uses"| node_admin_serializers
node_admin_api -->|"queries"| node_doctor_data
node_admin_api -->|"queries"| node_lab_data
node_qr_workflow -->|"reads and writes"| node_qr_data
node_qr_workflow -->|"uses"| node_qr_serializers
node_qr_workflow -->|"reads patient"| node_patient_data
node_qr_workflow -->|"assigns doctor"| node_doctor_data
node_qr_workflow -->|"assigns technician"| node_lab_data
node_qr_workflow -.->|"creates notifications"| node_qr_api
node_socket_routes -->|"registers"| node_notification_socket
node_watch_api -->|"reads and writes"| node_vitals
node_watch_api -->|"resolves patient"| node_patient_data
node_ble -.->|"feeds readings"| node_watch_api
node_risk_api -->|"loads patient"| node_patient_data
node_risk_api -->|"reads vitals"| node_vitals
node_risk_api -->|"stores and reads results"| node_risk_data
node_xray_api -->|"loads model"| node_xray_loader
node_xray_api -->|"uses transforms"| node_xray_transforms

click node_routes "https://github.com/tabeebai/backend-tabeebai/blob/main/TabebAI/urls.py"
click node_patient_api "https://github.com/tabeebai/backend-tabeebai/blob/main/Patients/views.py"
click node_patient_data "https://github.com/tabeebai/backend-tabeebai/blob/main/Patients/models.py"
click node_patient_serializers "https://github.com/tabeebai/backend-tabeebai/blob/main/Patients/serializers.py"
click node_patient_signals "https://github.com/tabeebai/backend-tabeebai/blob/main/Patients/signals.py"
click node_doctor_api "https://github.com/tabeebai/backend-tabeebai/blob/main/Doctor/views.py"
click node_doctor_data "https://github.com/tabeebai/backend-tabeebai/blob/main/Doctor/models.py"
click node_doctor_serializers "https://github.com/tabeebai/backend-tabeebai/blob/main/Doctor/serializers.py"
click node_lab_api "https://github.com/tabeebai/backend-tabeebai/blob/main/Laptech/views.py"
click node_lab_data "https://github.com/tabeebai/backend-tabeebai/blob/main/Laptech/models.py"
click node_lab_serializers "https://github.com/tabeebai/backend-tabeebai/blob/main/Laptech/serializers.py"
click node_admin_api "https://github.com/tabeebai/backend-tabeebai/blob/main/Admin/views.py"
click node_admin_serializers "https://github.com/tabeebai/backend-tabeebai/blob/main/Admin/serializers.py"
click node_qr_workflow "https://github.com/tabeebai/backend-tabeebai/blob/main/QR/views.py"
click node_qr_data "https://github.com/tabeebai/backend-tabeebai/blob/main/QR/models.py"
click node_qr_serializers "https://github.com/tabeebai/backend-tabeebai/blob/main/QR/serializers.py"
click node_qr_api "https://github.com/tabeebai/backend-tabeebai/blob/main/QR/api.py"
click node_notification_socket "https://github.com/tabeebai/backend-tabeebai/blob/main/QR/consumers.py"
click node_socket_routes "https://github.com/tabeebai/backend-tabeebai/blob/main/QR/routing.py"
click node_watch_api "https://github.com/tabeebai/backend-tabeebai/blob/main/Smart_Watch/views.py"
click node_vitals "https://github.com/tabeebai/backend-tabeebai/blob/main/Smart_Watch/models.py"
click node_ble "https://github.com/tabeebai/backend-tabeebai/blob/main/Smart_Watch/ble_service.py"
click node_risk_api "https://github.com/tabeebai/backend-tabeebai/blob/main/prediction/views.py"
click node_risk_data "https://github.com/tabeebai/backend-tabeebai/blob/main/prediction/models.py"
click node_xray_api "https://github.com/tabeebai/backend-tabeebai/blob/main/X_rays/views.py"
click node_xray_loader "https://github.com/tabeebai/backend-tabeebai/blob/main/X_rays/model_loader.py"
click node_xray_transforms "https://github.com/tabeebai/backend-tabeebai/blob/main/X_rays/transforms.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_patient_api,node_patient_data,node_patient_serializers,node_patient_signals,node_doctor_api,node_doctor_data,node_doctor_serializers,node_lab_api,node_lab_data,node_lab_serializers,node_admin_api,node_admin_serializers,node_client toneBlue
class node_qr_workflow,node_qr_data,node_qr_serializers toneAmber
class node_watch_api,node_vitals,node_ble,node_risk_api,node_risk_data,node_xray_api,node_xray_loader,node_xray_transforms,node_routes,node_n8n toneMint
class node_qr_api,node_notification_socket,node_socket_routes toneRose
```

## Components

### Access and Profiles

- [Patient API](https://github.com/tabeebai/backend-tabeebai/blob/main/Patients/views.py): `Patients/views.py`
- [Patient Records](https://github.com/tabeebai/backend-tabeebai/blob/main/Patients/models.py): `Patients/models.py`
- [Patient Serializers](https://github.com/tabeebai/backend-tabeebai/blob/main/Patients/serializers.py): `Patients/serializers.py`
- [Patient Signals](https://github.com/tabeebai/backend-tabeebai/blob/main/Patients/signals.py): `Patients/signals.py`
- [Doctor API](https://github.com/tabeebai/backend-tabeebai/blob/main/Doctor/views.py): `Doctor/views.py`
- [Doctor Records](https://github.com/tabeebai/backend-tabeebai/blob/main/Doctor/models.py): `Doctor/models.py`
- [Doctor Serializers](https://github.com/tabeebai/backend-tabeebai/blob/main/Doctor/serializers.py): `Doctor/serializers.py`
- [Lab Technician API](https://github.com/tabeebai/backend-tabeebai/blob/main/Laptech/views.py): `Laptech/views.py`
- [Lab Records](https://github.com/tabeebai/backend-tabeebai/blob/main/Laptech/models.py): `Laptech/models.py`
- [Lab Serializers](https://github.com/tabeebai/backend-tabeebai/blob/main/Laptech/serializers.py): `Laptech/serializers.py`
- [Admin API](https://github.com/tabeebai/backend-tabeebai/blob/main/Admin/views.py): `Admin/views.py`
- [Admin Serializers](https://github.com/tabeebai/backend-tabeebai/blob/main/Admin/serializers.py): `Admin/serializers.py`

### Visits and Lab Work

- [QR Visit Workflow](https://github.com/tabeebai/backend-tabeebai/blob/main/QR/views.py): `QR/views.py`
- [Visit and Session Records](https://github.com/tabeebai/backend-tabeebai/blob/main/QR/models.py): `QR/models.py`
- [QR Serializers](https://github.com/tabeebai/backend-tabeebai/blob/main/QR/serializers.py): `QR/serializers.py`

### Patient Health

- [Wearable API](https://github.com/tabeebai/backend-tabeebai/blob/main/Smart_Watch/views.py): `Smart_Watch/views.py`
- [Vital Sign Records](https://github.com/tabeebai/backend-tabeebai/blob/main/Smart_Watch/models.py): `Smart_Watch/models.py`
- [BLE Service](https://github.com/tabeebai/backend-tabeebai/blob/main/Smart_Watch/ble_service.py): `Smart_Watch/ble_service.py`
- [Risk and Charts](https://github.com/tabeebai/backend-tabeebai/blob/main/prediction/views.py): `prediction/views.py`
- [Risk Results](https://github.com/tabeebai/backend-tabeebai/blob/main/prediction/models.py): `prediction/models.py`
- [X-ray Prediction](https://github.com/tabeebai/backend-tabeebai/blob/main/X_rays/views.py): `X_rays/views.py`
- [Model Loader](https://github.com/tabeebai/backend-tabeebai/blob/main/X_rays/model_loader.py): `X_rays/model_loader.py`
- [Image Transforms](https://github.com/tabeebai/backend-tabeebai/blob/main/X_rays/transforms.py): `X_rays/transforms.py`

### Notifications

- [Notification API](https://github.com/tabeebai/backend-tabeebai/blob/main/QR/api.py): `QR/api.py`
- [Notification Consumer](https://github.com/tabeebai/backend-tabeebai/blob/main/QR/consumers.py): `QR/consumers.py`
- [WebSocket Routes](https://github.com/tabeebai/backend-tabeebai/blob/main/QR/routing.py): `QR/routing.py`

### Other components

- **API Client**
- [API Routes](https://github.com/tabeebai/backend-tabeebai/blob/main/TabebAI/urls.py): `TabebAI/urls.py`
- **n8n Webhook**

## Connections

- API Client → API Routes: sends requests (evidence: `TabebAI/urls.py`)
- API Routes → Patient API: routes to (evidence: `TabebAI/urls.py`)
- API Routes → Doctor API: routes to (evidence: `TabebAI/urls.py`)
- API Routes → Lab Technician API: routes to (evidence: `TabebAI/urls.py`)
- API Routes → Admin API: routes to (evidence: `TabebAI/urls.py`)
- API Routes → QR Visit Workflow: routes to (evidence: `TabebAI/urls.py`)
- API Routes → Notification API: routes to (evidence: `TabebAI/urls.py`)
- API Routes → Wearable API: routes to (evidence: `TabebAI/urls.py`)
- API Routes → Risk and Charts: routes to (evidence: `TabebAI/urls.py`)
- API Routes → X-ray Prediction: routes to (evidence: `TabebAI/urls.py`)
- Patient API → Patient Serializers: validates with (evidence: `Patients/views.py`)
- Patient API → Patient Records: reads and writes (evidence: `Patients/views.py`)
- Patient API → Doctor Records: searches (evidence: `Patients/views.py`)
- Patient API → Lab Records: searches (evidence: `Patients/views.py`)
- Patient API → n8n Webhook: posts question (evidence: `Patients/views.py`)
- Patient Signals → Patient Records: uses model (evidence: `Patients/signals.py`)
- Doctor API → Doctor Serializers: uses (evidence: `Doctor/views.py`)
- Doctor Serializers → Doctor Records: serializes (evidence: `Doctor/serializers.py`)
- Lab Technician API → Lab Serializers: uses (evidence: `Laptech/views.py`)
- Lab Serializers → Lab Records: serializes (evidence: `Laptech/serializers.py`)
- Admin API → Admin Serializers: uses (evidence: `Admin/views.py`)
- Admin API → Doctor Records: queries (evidence: `Admin/views.py`)
- Admin API → Lab Records: queries (evidence: `Admin/views.py`)
- QR Visit Workflow → Visit and Session Records: reads and writes (evidence: `QR/views.py`)
- QR Visit Workflow → QR Serializers: uses (evidence: `QR/views.py`)
- QR Visit Workflow → Patient Records: reads patient (evidence: `QR/views.py`)
- QR Visit Workflow → Doctor Records: assigns doctor (evidence: `QR/views.py`)
- QR Visit Workflow → Lab Records: assigns technician (evidence: `QR/views.py`)
- QR Visit Workflow → Notification API: creates notifications
- WebSocket Routes → Notification Consumer: registers (evidence: `QR/routing.py`)
- Wearable API → Vital Sign Records: reads and writes (evidence: `Smart_Watch/views.py`)
- Wearable API → Patient Records: resolves patient (evidence: `Smart_Watch/views.py`)
- BLE Service → Wearable API: feeds readings
- Risk and Charts → Patient Records: loads patient (evidence: `prediction/views.py`)
- Risk and Charts → Vital Sign Records: reads vitals (evidence: `prediction/views.py`)
- Risk and Charts → Risk Results: stores and reads results (evidence: `prediction/views.py`)
- X-ray Prediction → Model Loader: loads model (evidence: `X_rays/views.py`)
- X-ray Prediction → Image Transforms: uses transforms (evidence: `X_rays/views.py`)
