# orfanel-0205/promain-be architecture

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

- Interactive diagram: https://gitdiagram.com/orfanel-0205/promain-be
- Repository: https://github.com/orfanel-0205/promain-be

## Overview

Ka Agapay is a Laravel backend for community and rural health services, serving residents and RHU staff through an API. Its core workflow covers account access and resident requests, appointment and queue handling, staff consultations and prescriptions, with telemedicine as an alternate care path. Separate capabilities include AI assistance, health analytics, notifications, and administration. The tree and source index establish these product areas; several subsystems are unsampled, so their internal links are omitted rather than inferred.

Main entry points: [`ka-agapay-backend/routes/api.php`](https://github.com/orfanel-0205/promain-be/blob/main/ka-agapay-backend/routes/api.php) (API routes), [`ka-agapay-backend/app/Http/Controllers/Api/AppointmentController.php`](https://github.com/orfanel-0205/promain-be/blob/main/ka-agapay-backend/app/Http/Controllers/Api/AppointmentController.php) (Appointments), [`ka-agapay-backend/app/Http/Controllers/Api/Queue/QueueController.php`](https://github.com/orfanel-0205/promain-be/blob/main/ka-agapay-backend/app/Http/Controllers/Api/Queue/QueueController.php) (Queue management), [`ka-agapay-backend/app/Http/Controllers/Api/Telemedicine/TelemedicineController.php`](https://github.com/orfanel-0205/promain-be/blob/main/ka-agapay-backend/app/Http/Controllers/Api/Telemedicine/TelemedicineController.php) (Telemedicine requests)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_access["Access and profiles"]
  node_api["API routes<br/>[api.php]"]
  node_auth["Authentication<br/>[AuthController.php]"]
  node_profile[("Resident profiles")]
end

subgraph group_care["Care delivery"]
  node_appointments["Appointments"]
  node_appointmentdata[("Appointment records<br/>[Appointment.php]")]
  node_queue["Queue management"]
  node_queueservice["Queue service<br/>[QueueService.php]"]
  node_queueticket[("Queue tickets<br/>[QueueTicket.php]")]
  node_consultation[("Consultations<br/>[Consultation.php]")]
  node_prescriptions["Prescriptions"]
end

subgraph group_telehealth["Telemedicine"]
  node_telecontroller["Telemedicine requests"]
  node_teleservice["Telemedicine service"]
  node_telerequest[("Telemedicine request data")]
  node_telesession[("Session records")]
end

subgraph group_insights["Intelligence"]
  node_ai["AI assistance<br/>[AiController.php]"]
  node_triage["AI triage"]
  node_analytics["Health analytics"]
  node_outbreak["Outbreak detection"]
  node_chat["Chat assistant<br/>[ChatController.php]"]
end

subgraph group_operations["Operations"]
  node_notifications["Notifications"]
  node_admin["Administration"]
end

node_resident(("Resident"))
node_staff(("RHU staff"))

node_resident -->|"sends requests"| node_api
node_staff -->|"sends requests"| node_api
node_api -->|"routes to"| node_auth
node_api -->|"routes to"| node_appointments
node_api -->|"routes to"| node_queue
node_api -->|"routes to"| node_prescriptions
node_api -->|"routes to"| node_telecontroller
node_api -->|"routes to"| node_ai
node_api -->|"routes to"| node_analytics
node_api -.->|"routes to"| node_chat
node_api -->|"routes to"| node_admin
node_appointments -->|"reads and writes"| node_appointmentdata
node_appointments -->|"calls"| node_queueservice
node_appointments -->|"notifies through"| node_notifications
node_appointmentdata -->|"has one"| node_consultation
node_queue -->|"calls"| node_queueservice
node_queue -->|"reads and writes"| node_queueticket
node_queueticket -->|"references"| node_consultation
node_profile -->|"has many"| node_queueticket
node_telecontroller -->|"calls"| node_teleservice
node_telecontroller -->|"reads and writes"| node_telerequest
node_telerequest -->|"has one"| node_telesession
node_telesession -->|"references"| node_consultation
node_ai -->|"calls"| node_triage
node_analytics -.->|"uses"| node_outbreak
node_chat -.->|"uses assistant services"| node_ai

click node_api "https://github.com/orfanel-0205/promain-be/blob/main/ka-agapay-backend/routes/api.php"
click node_auth "https://github.com/orfanel-0205/promain-be/blob/main/ka-agapay-backend/app/Http/Controllers/Api/AuthController.php"
click node_profile "https://github.com/orfanel-0205/promain-be/blob/main/ka-agapay-backend/app/Models/ResidentProfile.php"
click node_appointments "https://github.com/orfanel-0205/promain-be/blob/main/ka-agapay-backend/app/Http/Controllers/Api/AppointmentController.php"
click node_appointmentdata "https://github.com/orfanel-0205/promain-be/blob/main/ka-agapay-backend/app/Models/Appointment.php"
click node_queue "https://github.com/orfanel-0205/promain-be/blob/main/ka-agapay-backend/app/Http/Controllers/Api/Queue/QueueController.php"
click node_queueservice "https://github.com/orfanel-0205/promain-be/blob/main/ka-agapay-backend/app/Services/Queue/QueueService.php"
click node_queueticket "https://github.com/orfanel-0205/promain-be/blob/main/ka-agapay-backend/app/Models/QueueTicket.php"
click node_consultation "https://github.com/orfanel-0205/promain-be/blob/main/ka-agapay-backend/app/Models/Consultation.php"
click node_prescriptions "https://github.com/orfanel-0205/promain-be/blob/main/ka-agapay-backend/app/Http/Controllers/Api/PrescriptionController.php"
click node_telecontroller "https://github.com/orfanel-0205/promain-be/blob/main/ka-agapay-backend/app/Http/Controllers/Api/Telemedicine/TelemedicineController.php"
click node_teleservice "https://github.com/orfanel-0205/promain-be/blob/main/ka-agapay-backend/app/Services/Telemedicine/TelemedicineService.php"
click node_telerequest "https://github.com/orfanel-0205/promain-be/blob/main/ka-agapay-backend/app/Models/TelemedicineRequest.php"
click node_telesession "https://github.com/orfanel-0205/promain-be/blob/main/ka-agapay-backend/app/Models/TelemedicineSession.php"
click node_ai "https://github.com/orfanel-0205/promain-be/blob/main/ka-agapay-backend/app/Http/Controllers/Api/Ai/AiController.php"
click node_triage "https://github.com/orfanel-0205/promain-be/blob/main/ka-agapay-backend/app/Services/Ai/AiTriageService.php"
click node_analytics "https://github.com/orfanel-0205/promain-be/blob/main/ka-agapay-backend/app/Http/Controllers/Api/Analytics/AnalyticsController.php"
click node_outbreak "https://github.com/orfanel-0205/promain-be/blob/main/ka-agapay-backend/app/Services/Analytics/OutbreakDetector.php"
click node_chat "https://github.com/orfanel-0205/promain-be/blob/main/ka-agapay-backend/app/Http/Controllers/Api/ChatController.php"
click node_notifications "https://github.com/orfanel-0205/promain-be/blob/main/ka-agapay-backend/app/Services/Notification/NotificationService.php"
click node_admin "https://github.com/orfanel-0205/promain-be/blob/main/ka-agapay-backend/app/Http/Controllers/Api/AdminController.php"

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_api,node_auth,node_profile toneBlue
class node_appointments,node_appointmentdata,node_queue,node_queueservice,node_queueticket,node_consultation,node_prescriptions toneAmber
class node_telecontroller,node_teleservice,node_telerequest,node_telesession toneMint
class node_ai,node_triage,node_analytics,node_outbreak,node_chat toneRose
class node_notifications,node_admin,node_resident,node_staff toneIndigo
```

## Components

### Access and profiles

- [API routes](https://github.com/orfanel-0205/promain-be/blob/main/ka-agapay-backend/routes/api.php): `ka-agapay-backend/routes/api.php`
- [Authentication](https://github.com/orfanel-0205/promain-be/blob/main/ka-agapay-backend/app/Http/Controllers/Api/AuthController.php): `ka-agapay-backend/app/Http/Controllers/Api/AuthController.php`
- [Resident profiles](https://github.com/orfanel-0205/promain-be/blob/main/ka-agapay-backend/app/Models/ResidentProfile.php): `ka-agapay-backend/app/Models/ResidentProfile.php`

### Care delivery

- [Appointments](https://github.com/orfanel-0205/promain-be/blob/main/ka-agapay-backend/app/Http/Controllers/Api/AppointmentController.php): `ka-agapay-backend/app/Http/Controllers/Api/AppointmentController.php`
- [Appointment records](https://github.com/orfanel-0205/promain-be/blob/main/ka-agapay-backend/app/Models/Appointment.php): `ka-agapay-backend/app/Models/Appointment.php`
- [Queue management](https://github.com/orfanel-0205/promain-be/blob/main/ka-agapay-backend/app/Http/Controllers/Api/Queue/QueueController.php): `ka-agapay-backend/app/Http/Controllers/Api/Queue/QueueController.php`
- [Queue service](https://github.com/orfanel-0205/promain-be/blob/main/ka-agapay-backend/app/Services/Queue/QueueService.php): `ka-agapay-backend/app/Services/Queue/QueueService.php`
- [Queue tickets](https://github.com/orfanel-0205/promain-be/blob/main/ka-agapay-backend/app/Models/QueueTicket.php): `ka-agapay-backend/app/Models/QueueTicket.php`
- [Consultations](https://github.com/orfanel-0205/promain-be/blob/main/ka-agapay-backend/app/Models/Consultation.php): `ka-agapay-backend/app/Models/Consultation.php`
- [Prescriptions](https://github.com/orfanel-0205/promain-be/blob/main/ka-agapay-backend/app/Http/Controllers/Api/PrescriptionController.php): `ka-agapay-backend/app/Http/Controllers/Api/PrescriptionController.php`

### Telemedicine

- [Telemedicine requests](https://github.com/orfanel-0205/promain-be/blob/main/ka-agapay-backend/app/Http/Controllers/Api/Telemedicine/TelemedicineController.php): `ka-agapay-backend/app/Http/Controllers/Api/Telemedicine/TelemedicineController.php`
- [Telemedicine service](https://github.com/orfanel-0205/promain-be/blob/main/ka-agapay-backend/app/Services/Telemedicine/TelemedicineService.php): `ka-agapay-backend/app/Services/Telemedicine/TelemedicineService.php`
- [Telemedicine request data](https://github.com/orfanel-0205/promain-be/blob/main/ka-agapay-backend/app/Models/TelemedicineRequest.php): `ka-agapay-backend/app/Models/TelemedicineRequest.php`
- [Session records](https://github.com/orfanel-0205/promain-be/blob/main/ka-agapay-backend/app/Models/TelemedicineSession.php): `ka-agapay-backend/app/Models/TelemedicineSession.php`

### Intelligence

- [AI assistance](https://github.com/orfanel-0205/promain-be/blob/main/ka-agapay-backend/app/Http/Controllers/Api/Ai/AiController.php): `ka-agapay-backend/app/Http/Controllers/Api/Ai/AiController.php`
- [AI triage](https://github.com/orfanel-0205/promain-be/blob/main/ka-agapay-backend/app/Services/Ai/AiTriageService.php): `ka-agapay-backend/app/Services/Ai/AiTriageService.php`
- [Health analytics](https://github.com/orfanel-0205/promain-be/blob/main/ka-agapay-backend/app/Http/Controllers/Api/Analytics/AnalyticsController.php): `ka-agapay-backend/app/Http/Controllers/Api/Analytics/AnalyticsController.php`
- [Outbreak detection](https://github.com/orfanel-0205/promain-be/blob/main/ka-agapay-backend/app/Services/Analytics/OutbreakDetector.php): `ka-agapay-backend/app/Services/Analytics/OutbreakDetector.php`
- [Chat assistant](https://github.com/orfanel-0205/promain-be/blob/main/ka-agapay-backend/app/Http/Controllers/Api/ChatController.php): `ka-agapay-backend/app/Http/Controllers/Api/ChatController.php`

### Operations

- [Notifications](https://github.com/orfanel-0205/promain-be/blob/main/ka-agapay-backend/app/Services/Notification/NotificationService.php): `ka-agapay-backend/app/Services/Notification/NotificationService.php`
- [Administration](https://github.com/orfanel-0205/promain-be/blob/main/ka-agapay-backend/app/Http/Controllers/Api/AdminController.php): `ka-agapay-backend/app/Http/Controllers/Api/AdminController.php`

### Other components

- **Resident**
- **RHU staff**

## Connections

- Resident → API routes: sends requests (evidence: `ka-agapay-backend/routes/api.php`)
- RHU staff → API routes: sends requests (evidence: `ka-agapay-backend/routes/api.php`)
- API routes → Authentication: routes to (evidence: `ka-agapay-backend/routes/api.php`)
- API routes → Appointments: routes to (evidence: `ka-agapay-backend/routes/api.php`)
- API routes → Queue management: routes to (evidence: `ka-agapay-backend/routes/api.php`)
- API routes → Prescriptions: routes to (evidence: `ka-agapay-backend/routes/api.php`)
- API routes → Telemedicine requests: routes to (evidence: `ka-agapay-backend/routes/api.php`)
- API routes → AI assistance: routes to (evidence: `ka-agapay-backend/routes/api.php`)
- API routes → Health analytics: routes to (evidence: `ka-agapay-backend/routes/api.php`)
- API routes → Chat assistant: routes to (evidence: `ka-agapay-backend/app/Http/Controllers/Api/ChatController.php`)
- API routes → Administration: routes to (evidence: `ka-agapay-backend/routes/api.php`)
- Appointments → Appointment records: reads and writes (evidence: `ka-agapay-backend/app/Http/Controllers/Api/AppointmentController.php`)
- Appointments → Queue service: calls (evidence: `ka-agapay-backend/app/Http/Controllers/Api/AppointmentController.php`)
- Appointments → Notifications: notifies through (evidence: `ka-agapay-backend/app/Http/Controllers/Api/AppointmentController.php`)
- Appointment records → Consultations: has one (evidence: `ka-agapay-backend/app/Models/Appointment.php`)
- Queue management → Queue service: calls (evidence: `ka-agapay-backend/app/Http/Controllers/Api/Queue/QueueController.php`)
- Queue management → Queue tickets: reads and writes (evidence: `ka-agapay-backend/app/Http/Controllers/Api/Queue/QueueController.php`)
- Queue tickets → Consultations: references (evidence: `ka-agapay-backend/app/Models/QueueTicket.php`)
- Resident profiles → Queue tickets: has many (evidence: `ka-agapay-backend/app/Models/ResidentProfile.php`)
- Telemedicine requests → Telemedicine service: calls (evidence: `ka-agapay-backend/app/Http/Controllers/Api/Telemedicine/TelemedicineController.php`)
- Telemedicine requests → Telemedicine request data: reads and writes (evidence: `ka-agapay-backend/app/Http/Controllers/Api/Telemedicine/TelemedicineController.php`)
- Telemedicine request data → Session records: has one (evidence: `ka-agapay-backend/app/Models/TelemedicineRequest.php`)
- Session records → Consultations: references (evidence: `ka-agapay-backend/app/Models/TelemedicineSession.php`)
- AI assistance → AI triage: calls (evidence: `ka-agapay-backend/app/Http/Controllers/Api/Ai/AiController.php`)
- Health analytics → Outbreak detection: uses
- Chat assistant → AI assistance: uses assistant services
