# a-oirgari/fillrouge architecture

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

- Interactive diagram: https://gitdiagram.com/a-oirgari/fillrouge
- Repository: https://github.com/a-oirgari/fillrouge

## Overview

1. **Project type and runtime**
   - This is a **Laravel 11-style monolith** for a medical teleconsultation platform called **MediConnect**.
   - It is a **server-rendered application** using **Blade views**, not a separate SPA or API-first backend.
   - The app persists data in **MySQL** and uses standard Laravel infrastructure for sessions, cache, jobs, and logging.

2. **Top-level architecture**
   - The codebase is organized around three major user roles: **patient**, **doctor**, and **admin**.
   - There is also a shared **authentication** layer and a shared **messaging** subsystem.
   - The main architectural boundary is role-based access: users land in different controllers, dashboards, and data flows depending on their role.

3. **HTTP entry points and routing**
   - All browser traffic enters through `public/index.php` and is routed by `routes/web.php`.
   - The application is mostly form-driven: routes map to controller actions that return Blade templates and handle POST/PUT actions.
   - `routes/channels.php` suggests a broadcast channel layer exists for realtime features, especially messaging/calls.

4. **Presentation layer**
   - UI lives in `resources/views`, grouped by role: `auth`, `patient`, `doctor`, `admin`, and `messages`.
   - `resources/views/layouts/app.blade.php` is the shared shell used across the app.
   - The app uses a small frontend build pipeline (`resources/js`, `resources/css`, `vite.config.js`), but the architecture remains primarily Blade-centric.

5. **Domain model and persistence**
   - The core domain is modeled with Eloquent entities: `User`, `Patient`, `Doctor`, `Speciality`, `Availability`, `Appointment`, `Consultation`, `Prescription`, and `Message`.
   - The database schema is defined by migrations under `database/migrations`, including a many-to-many link between doctors and specialities.
   - This model set shows the main lifecycle: doctor registration and validation, availability setup, appointment booking, consultation completion, and prescription/message history.

6. **Authentication and authorization**
   - `AuthController` handles registration, login, and logout.
   - Validation is enforced through dedicated Form Request classes such as `LoginRequest` and `RegisterRequest`.
   - `app/Http/Middleware/RoleMiddleware.php` is the key access-control boundary, ensuring only the correct role reaches patient/doctor/admin routes.
   - `SetLocale.php` is a cross-cutting middleware that switches the app language, supporting **Arabic and French**.

7. **Patient workflow**
   - `PatientController` serves the patient dashboard, doctor search, doctor profile, appointment listing, and medical history.
   - The patient flow is: browse doctors by speciality/city, inspect a doctor profile, book an appointment, then later view the resulting consultation history.
   - The patient history screen aggregates past consultations and prescriptions, so it is a read-heavy view over multiple domain tables.

8. **Doctor workflow**
   - `DoctorController` manages the doctor dashboard, appointment queue, consultation entry, profile editing, and patient history.
   - Doctors can manage their own availability through validated forms, then accept/refuse appointments and record diagnostics/prescriptions during consultation.
   - The doctor dashboard is operational: it surfaces pending requests and same-day appointments as the main work queue.

9. **Admin workflow**
   - `AdminController` provides governance functions: doctor validation, user management, statistics, and speciality CRUD.
   - The admin boundary is distinct from clinical workflows; it focuses on platform oversight rather than appointments or care delivery.
   - The admin dashboard aggregates global counts and operational lists, including doctors waiting for approval.

10. **Messaging and realtime collaboration**
   - `MessageController` powers one-to-one conversations across connected users.
   - `app/Events/MessageSent.php` and `app/Events/CallInitiated.php`, together with `config/reverb.php`, indicate a realtime broadcasting layer for chat/call signaling.
   - Even though the conversation view mentions polling in the UI, the presence of events and broadcast channels means messaging is architected as an event-driven feature with realtime capability.

11. **Validation and request boundaries**
   - Most state-changing actions are guarded by dedicated Form Requests: appointment booking, availability saving, diagnostics, doctor profile updates, messaging, and speciality creation.
   - This keeps validation out of controllers and makes each business action explicit at the boundary between HTTP and domain logic.
   - The controllers therefore orchestrate workflows, while requests enforce input correctness.

12. **Data flow summary**
   - Typical flow is: browser form/view → route → middleware (auth/role/locale) → Form Request validation → controller action → Eloquent models / database → Blade response.
   - The shared database is the integration point for all role-specific features.
   - Messages and calls are the only parts that extend beyond simple request/response, introducing broadcast/event behavior.

13. **Internationalization and UX**
   - The presence of `lang/ar` and `lang/fr` shows the platform is built for bilingual use.
   - Locale switching is a first-class concern, not an afterthought, because it is enforced in middleware and backed by translation files.

14. **Architecture diagram takeaway**
   - If you draw this system, model it as a **single Laravel web application** with:
     - a public/auth boundary,
     - three role-based UI/workflow zones,
     - a shared domain/database layer,
     - and a realtime messaging/call side channel.
   - The most important relationships are between **roles → controllers → request validation → Eloquent models → Blade views**, with **broadcast events** overlaying the messaging subsystem.

Main entry points: [`fillRouge/routes/web.php`](https://github.com/a-oirgari/fillrouge/blob/main/fillRouge/routes/web.php) (Web routes), [`fillRouge/app/Http/Controllers/DoctorController.php`](https://github.com/a-oirgari/fillrouge/blob/main/fillRouge/app/Http/Controllers/DoctorController.php) (Doctor), [`fillRouge/app/Http/Controllers/PatientController.php`](https://github.com/a-oirgari/fillrouge/blob/main/fillRouge/app/Http/Controllers/PatientController.php) (Patient), [`fillRouge/app/Http/Controllers/AdminController.php`](https://github.com/a-oirgari/fillrouge/blob/main/fillRouge/app/Http/Controllers/AdminController.php) (Admin)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_g_platform["Platform"]
  node_n_public_index["Public entry<br/>HTTP front controller<br/>[index.php]"]
  node_n_routes_web["Web routes<br/>Route map<br/>[web.php]"]
  node_n_routes_channels["Broadcast channels<br/>Realtime routes<br/>[channels.php]"]
end

subgraph group_g_auth["Access"]
  node_n_auth_ctrl["Auth<br/>Controller<br/>[AuthController.php]"]
  node_n_role_mw{{"Role guard<br/>Middleware<br/>[RoleMiddleware.php]"}}
  node_n_locale_mw{{"Locale switch<br/>Middleware<br/>[SetLocale.php]"}}
end

subgraph group_g_workflows["Workflows"]
  node_n_layout_app["App shell<br/>Blade layout<br/>[app.blade.php]"]
  node_n_patient_ctrl["Patient<br/>Controller"]
  node_n_doctor_ctrl["Doctor<br/>Controller"]
  node_n_admin_ctrl["Admin<br/>Controller"]
  node_n_message_ctrl["Messages<br/>Controller"]
  node_n_patient_views["Patient views<br/>Blade views"]
  node_n_doctor_views["Doctor views<br/>Blade views"]
  node_n_admin_views["Admin views<br/>Blade views"]
  node_n_message_views["Chat views<br/>Blade views"]
end

subgraph group_g_domain["Domain"]
  node_n_user_model[("User<br/>Eloquent model<br/>[User.php]")]
  node_n_patient_model[("Patient<br/>Eloquent model<br/>[Patient.php]")]
  node_n_doctor_model[("Doctor<br/>Eloquent model<br/>[Doctor.php]")]
  node_n_speciality_model[("Speciality<br/>Eloquent model<br/>[Speciality.php]")]
  node_n_appointment_model[("Appointment<br/>Eloquent model<br/>[Appointment.php]")]
  node_n_consultation_model[("Consultation<br/>Eloquent model<br/>[Consultation.php]")]
  node_n_prescription_model[("Prescription<br/>Eloquent model<br/>[Prescription.php]")]
  node_n_message_model[("Message<br/>Eloquent model<br/>[Message.php]")]
  node_n_message_sent(("MessageSent<br/>Broadcast event<br/>[MessageSent.php]"))
  node_n_call_initiated(("CallInitiated<br/>Broadcast event<br/>[CallInitiated.php]"))
  node_n_reverb_config["Reverb<br/>Broadcast config<br/>[reverb.php]"]
end

node_n_public_index -->|"dispatches to"| node_n_routes_web
node_n_routes_web -->|"applies"| node_n_locale_mw
node_n_routes_web -->|"protects"| node_n_role_mw
node_n_routes_web -->|"auth routes"| node_n_auth_ctrl
node_n_routes_web -->|"patient flow"| node_n_patient_ctrl
node_n_routes_web -->|"doctor flow"| node_n_doctor_ctrl
node_n_routes_web -->|"admin flow"| node_n_admin_ctrl
node_n_routes_web -->|"messaging"| node_n_message_ctrl
node_n_routes_channels -->|"broadcasts"| node_n_message_sent
node_n_routes_channels -->|"broadcasts"| node_n_call_initiated
node_n_auth_ctrl -->|"creates accounts"| node_n_user_model
node_n_auth_ctrl -->|"creates patient"| node_n_patient_model
node_n_auth_ctrl -->|"creates doctor"| node_n_doctor_model
node_n_patient_ctrl -->|"renders"| node_n_patient_views
node_n_patient_ctrl -->|"books"| node_n_appointment_model
node_n_patient_ctrl -->|"reads history"| node_n_consultation_model
node_n_patient_ctrl -->|"reads history"| node_n_prescription_model
node_n_doctor_ctrl -->|"renders"| node_n_doctor_views
node_n_doctor_ctrl -->|"updates profile"| node_n_doctor_model
node_n_doctor_ctrl -->|"manages queue"| node_n_appointment_model
node_n_doctor_ctrl -->|"records care"| node_n_consultation_model
node_n_doctor_ctrl -->|"writes prescriptions"| node_n_prescription_model
node_n_admin_ctrl -->|"renders"| node_n_admin_views
node_n_admin_ctrl -->|"manages users"| node_n_user_model
node_n_admin_ctrl -->|"validates doctors"| node_n_doctor_model
node_n_admin_ctrl -->|"crud"| node_n_speciality_model
node_n_message_ctrl -->|"renders"| node_n_message_views
node_n_message_ctrl -->|"stores"| node_n_message_model
node_n_message_ctrl -->|"emits"| node_n_message_sent
node_n_message_ctrl -->|"emits"| node_n_call_initiated
node_n_message_sent -->|"broadcast via"| node_n_reverb_config
node_n_call_initiated -->|"broadcast via"| node_n_reverb_config
node_n_patient_views -->|"extends"| node_n_layout_app
node_n_doctor_views -->|"extends"| node_n_layout_app
node_n_admin_views -->|"extends"| node_n_layout_app
node_n_message_views -->|"extends"| node_n_layout_app

click node_n_public_index "https://github.com/a-oirgari/fillrouge/blob/main/fillRouge/public/index.php"
click node_n_routes_web "https://github.com/a-oirgari/fillrouge/blob/main/fillRouge/routes/web.php"
click node_n_routes_channels "https://github.com/a-oirgari/fillrouge/blob/main/fillRouge/routes/channels.php"
click node_n_layout_app "https://github.com/a-oirgari/fillrouge/blob/main/fillRouge/resources/views/layouts/app.blade.php"
click node_n_auth_ctrl "https://github.com/a-oirgari/fillrouge/blob/main/fillRouge/app/Http/Controllers/AuthController.php"
click node_n_role_mw "https://github.com/a-oirgari/fillrouge/blob/main/fillRouge/app/Http/Middleware/RoleMiddleware.php"
click node_n_locale_mw "https://github.com/a-oirgari/fillrouge/blob/main/fillRouge/app/Http/Middleware/SetLocale.php"
click node_n_patient_ctrl "https://github.com/a-oirgari/fillrouge/blob/main/fillRouge/app/Http/Controllers/PatientController.php"
click node_n_doctor_ctrl "https://github.com/a-oirgari/fillrouge/blob/main/fillRouge/app/Http/Controllers/DoctorController.php"
click node_n_admin_ctrl "https://github.com/a-oirgari/fillrouge/blob/main/fillRouge/app/Http/Controllers/AdminController.php"
click node_n_message_ctrl "https://github.com/a-oirgari/fillrouge/blob/main/fillRouge/app/Http/Controllers/MessageController.php"
click node_n_patient_views "https://github.com/a-oirgari/fillrouge/tree/main/fillRouge/resources/views/patient"
click node_n_doctor_views "https://github.com/a-oirgari/fillrouge/tree/main/fillRouge/resources/views/doctor"
click node_n_admin_views "https://github.com/a-oirgari/fillrouge/tree/main/fillRouge/resources/views/admin"
click node_n_message_views "https://github.com/a-oirgari/fillrouge/tree/main/fillRouge/resources/views/messages"
click node_n_user_model "https://github.com/a-oirgari/fillrouge/blob/main/fillRouge/app/Models/User.php"
click node_n_patient_model "https://github.com/a-oirgari/fillrouge/blob/main/fillRouge/app/Models/Patient.php"
click node_n_doctor_model "https://github.com/a-oirgari/fillrouge/blob/main/fillRouge/app/Models/Doctor.php"
click node_n_speciality_model "https://github.com/a-oirgari/fillrouge/blob/main/fillRouge/app/Models/Speciality.php"
click node_n_appointment_model "https://github.com/a-oirgari/fillrouge/blob/main/fillRouge/app/Models/Appointment.php"
click node_n_consultation_model "https://github.com/a-oirgari/fillrouge/blob/main/fillRouge/app/Models/Consultation.php"
click node_n_prescription_model "https://github.com/a-oirgari/fillrouge/blob/main/fillRouge/app/Models/Prescription.php"
click node_n_message_model "https://github.com/a-oirgari/fillrouge/blob/main/fillRouge/app/Models/Message.php"
click node_n_message_sent "https://github.com/a-oirgari/fillrouge/blob/main/fillRouge/app/Events/MessageSent.php"
click node_n_call_initiated "https://github.com/a-oirgari/fillrouge/blob/main/fillRouge/app/Events/CallInitiated.php"
click node_n_reverb_config "https://github.com/a-oirgari/fillrouge/blob/main/fillRouge/config/reverb.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_n_public_index,node_n_routes_web,node_n_routes_channels toneBlue
class node_n_auth_ctrl,node_n_role_mw,node_n_locale_mw toneAmber
class node_n_layout_app,node_n_patient_ctrl,node_n_doctor_ctrl,node_n_admin_ctrl,node_n_message_ctrl,node_n_patient_views,node_n_doctor_views,node_n_admin_views,node_n_message_views toneMint
class node_n_user_model,node_n_patient_model,node_n_doctor_model,node_n_speciality_model,node_n_appointment_model,node_n_consultation_model,node_n_prescription_model,node_n_message_model,node_n_message_sent,node_n_call_initiated,node_n_reverb_config toneRose
```

## Components

### Platform

Laravel runtime, entrypoints, and cross-cutting app configuration.

- [Public entry](https://github.com/a-oirgari/fillrouge/blob/main/fillRouge/public/index.php): HTTP front controller · Browser entrypoint for the Laravel app. · `fillRouge/public/index.php`
- [Web routes](https://github.com/a-oirgari/fillrouge/blob/main/fillRouge/routes/web.php): Route map · Main browser routing table. · `fillRouge/routes/web.php`
- [Broadcast channels](https://github.com/a-oirgari/fillrouge/blob/main/fillRouge/routes/channels.php): Realtime routes · Channel definitions for broadcast features. · `fillRouge/routes/channels.php`

### Access

Authentication, authorization, and locale boundaries.

- [Auth](https://github.com/a-oirgari/fillrouge/blob/main/fillRouge/app/Http/Controllers/AuthController.php): Controller · Login, registration, and logout. · `fillRouge/app/Http/Controllers/AuthController.php`
- [Role guard](https://github.com/a-oirgari/fillrouge/blob/main/fillRouge/app/Http/Middleware/RoleMiddleware.php): Middleware · Restricts access by user role. · `fillRouge/app/Http/Middleware/RoleMiddleware.php`
- [Locale switch](https://github.com/a-oirgari/fillrouge/blob/main/fillRouge/app/Http/Middleware/SetLocale.php): Middleware · Sets Arabic/French locale context. · `fillRouge/app/Http/Middleware/SetLocale.php`

### Workflows

Role-based controllers and Blade UI flows.

- [App shell](https://github.com/a-oirgari/fillrouge/blob/main/fillRouge/resources/views/layouts/app.blade.php): Blade layout · Shared layout used across views. · `fillRouge/resources/views/layouts/app.blade.php`
- [Patient](https://github.com/a-oirgari/fillrouge/blob/main/fillRouge/app/Http/Controllers/PatientController.php): Controller · Patient dashboard, search, booking, and history. · `fillRouge/app/Http/Controllers/PatientController.php`
- [Doctor](https://github.com/a-oirgari/fillrouge/blob/main/fillRouge/app/Http/Controllers/DoctorController.php): Controller · Doctor dashboard, queue, availability, and consultation. · `fillRouge/app/Http/Controllers/DoctorController.php`
- [Admin](https://github.com/a-oirgari/fillrouge/blob/main/fillRouge/app/Http/Controllers/AdminController.php): Controller · Governance, validation, users, and specialities. · `fillRouge/app/Http/Controllers/AdminController.php`
- [Messages](https://github.com/a-oirgari/fillrouge/blob/main/fillRouge/app/Http/Controllers/MessageController.php): Controller · One-to-one conversations and call actions. · `fillRouge/app/Http/Controllers/MessageController.php`
- [Patient views](https://github.com/a-oirgari/fillrouge/tree/main/fillRouge/resources/views/patient): Blade views · Patient screens for search, booking, and history. · `fillRouge/resources/views/patient`
- [Doctor views](https://github.com/a-oirgari/fillrouge/tree/main/fillRouge/resources/views/doctor): Blade views · Doctor screens for workflow and consultation. · `fillRouge/resources/views/doctor`
- [Admin views](https://github.com/a-oirgari/fillrouge/tree/main/fillRouge/resources/views/admin): Blade views · Admin dashboards and management screens. · `fillRouge/resources/views/admin`
- [Chat views](https://github.com/a-oirgari/fillrouge/tree/main/fillRouge/resources/views/messages): Blade views · Conversation and call UI. · `fillRouge/resources/views/messages`

### Domain

Core persistence models and realtime messaging.

- [User](https://github.com/a-oirgari/fillrouge/blob/main/fillRouge/app/Models/User.php): Eloquent model · Shared authenticated account record. · `fillRouge/app/Models/User.php`
- [Patient](https://github.com/a-oirgari/fillrouge/blob/main/fillRouge/app/Models/Patient.php): Eloquent model · Patient profile and history anchor. · `fillRouge/app/Models/Patient.php`
- [Doctor](https://github.com/a-oirgari/fillrouge/blob/main/fillRouge/app/Models/Doctor.php): Eloquent model · Doctor profile, validation, and availability. · `fillRouge/app/Models/Doctor.php`
- [Speciality](https://github.com/a-oirgari/fillrouge/blob/main/fillRouge/app/Models/Speciality.php): Eloquent model · Doctor classification and search dimension. · `fillRouge/app/Models/Speciality.php`
- [Appointment](https://github.com/a-oirgari/fillrouge/blob/main/fillRouge/app/Models/Appointment.php): Eloquent model · Booking and scheduling record. · `fillRouge/app/Models/Appointment.php`
- [Consultation](https://github.com/a-oirgari/fillrouge/blob/main/fillRouge/app/Models/Consultation.php): Eloquent model · Clinical encounter and diagnostics. · `fillRouge/app/Models/Consultation.php`
- [Prescription](https://github.com/a-oirgari/fillrouge/blob/main/fillRouge/app/Models/Prescription.php): Eloquent model · Medication and treatment output. · `fillRouge/app/Models/Prescription.php`
- [Message](https://github.com/a-oirgari/fillrouge/blob/main/fillRouge/app/Models/Message.php): Eloquent model · Conversation message record. · `fillRouge/app/Models/Message.php`
- [MessageSent](https://github.com/a-oirgari/fillrouge/blob/main/fillRouge/app/Events/MessageSent.php): Broadcast event · Broadcasts chat message delivery. · `fillRouge/app/Events/MessageSent.php`
- [CallInitiated](https://github.com/a-oirgari/fillrouge/blob/main/fillRouge/app/Events/CallInitiated.php): Broadcast event · Broadcasts call signaling. · `fillRouge/app/Events/CallInitiated.php`
- [Reverb](https://github.com/a-oirgari/fillrouge/blob/main/fillRouge/config/reverb.php): Broadcast config · Realtime broadcasting configuration. · `fillRouge/config/reverb.php`

## Connections

- Public entry → Web routes: dispatches to · HTTP requests are routed through the web router.
- Web routes → Locale switch: applies · Locale handling is applied at the web boundary.
- Web routes → Role guard: protects · Role-based access controls role routes.
- Web routes → Auth: auth routes · Login and registration enter the auth controller.
- Web routes → Patient: patient flow · Patient actions are routed to patient workflows.
- Web routes → Doctor: doctor flow · Doctor actions are routed to doctor workflows.
- Web routes → Admin: admin flow · Admin actions are routed to governance workflows.
- Web routes → Messages: messaging · Conversation and call actions are routed here.
- Broadcast channels → MessageSent: broadcasts · Channel layer supports message events.
- Broadcast channels → CallInitiated: broadcasts · Channel layer supports call signaling.
- Auth → User: creates accounts · Authentication works through the shared user record.
- Auth → Patient: creates patient · Registration can provision patient profile data.
- Auth → Doctor: creates doctor · Registration can provision doctor profile data.
- Patient → Patient views: renders · Patient screens are Blade-rendered.
- Patient → Appointment: books · Patient booking centers on appointments.
- Patient → Consultation: reads history · Patient history aggregates consultations.
- Patient → Prescription: reads history · Patient history includes prescriptions.
- Doctor → Doctor views: renders · Doctor screens are Blade-rendered.
- Doctor → Doctor: updates profile · Doctor workflows maintain doctor data.
- Doctor → Appointment: manages queue · Doctor work queue is appointment-driven.
- Doctor → Consultation: records care · Consultations store diagnostics and outcomes.
- Doctor → Prescription: writes prescriptions · Clinical completion produces prescriptions.
- Admin → Admin views: renders · Admin screens are Blade-rendered.
- Admin → User: manages users · Administration covers platform user oversight.
- Admin → Doctor: validates doctors · Admin approves or rejects doctors.
- Admin → Speciality: crud · Admin manages specialities.
- Messages → Chat views: renders · Messaging UI is Blade-rendered.
- Messages → Message: stores · Conversation data persists as messages.
- Messages → MessageSent: emits · New messages trigger broadcast events.
- Messages → CallInitiated: emits · Call actions trigger signaling events.
- MessageSent → Reverb: broadcast via · Realtime delivery uses Reverb config.
- CallInitiated → Reverb: broadcast via · Call signaling uses Reverb config.
- Patient views → App shell: extends · Patient views share the common shell.
- Doctor views → App shell: extends · Doctor views share the common shell.
- Admin views → App shell: extends · Admin views share the common shell.
- Chat views → App shell: extends · Messaging views share the common shell.
