# thewebustaad/medicalproject architecture

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

- Interactive diagram: https://gitdiagram.com/thewebustaad/medicalproject
- Repository: https://github.com/thewebustaad/medicalproject

## Overview

##### Project type and purpose
- This is a full-stack Laravel (PHP) web application implementing an appointment management system.
- Key use cases: user authentication (customers, doctors, admins), role-based access, appointment booking and management.

##### File structure
- Top-level folders:
- app/ — contains MVC backend (Http/Controllers, Models, Middleware, Providers).
- routes/ — web and console routing definitions.
- resources/ — Blade view templates, front-end JS/CSS scaffolding.
- public/ — publicly served assets: index.php, static CSS/JS, two sets of assets (public/assets for customer site, public/admin for admin panel).
- database/ — migrations, seeders, factories.
- config/, bootstrap/, storage/, tests/, etc.
- MVC pattern:
- Models under app/Models (User, Doctor, Appointment, AppointmentModel).
- Controllers under app/Http/Controllers (segmented by role: Doctors/admin, Doctors/main, general).
- Views under resources/views (layouts, pages for admin panel vs public site).
- Middleware enforces authentication/role checks.
- Composer manages PHP dependencies; Vite or Laravel Mix handles front-end builds (vite.config.js).
- Database migrations define schema for users, roles, doctors, appointments.

##### Extract additional insights from the README
- Roles: customer, admin, doctor.
- Appointment booking flow: user books → controller logic → persisting to DB → notifications (mail.php).
- No external microservices; typical monolith with front-end assets and back-end.

a. Main components:
1. Client browsers/mobile apps
2. Web Server (Nginx/Apache)
3. Laravel Application
– Routing Layer (routes/web.php)
– Middleware (Auth, AdminAuthenticate, Redirects)
– Controllers (AppointmentController, DoctorController, etc.)
– Service Providers (AppServiceProvider)
– Models & ORM (Eloquent)
4. Database (MySQL)
5. File Storage (local disk for uploads)
6. External Mail Service (SMTP, Mailgun, etc.)
b. Relationships & data flows:
- Client → Web Server → index.php → bootstrap/app.php → route resolve
- Route → Middleware → Controller → Model → Database
- Controller → returns Blade view + data
- Blade → front-end assets → rendered in browser
- Appointment booking triggers mail via Mail facade → external SMTP
c. Architectural patterns:
- MVC (Models, Views, Controllers)
- Service Provider pattern for bootstrapping
- Eloquent ORM for data access
- Role-based middleware for authorization
d. Key technologies/frameworks:
- Laravel 9.x (PHP 8.x)
- MySQL (or equivalent)
- Blade templating
- Composer (dependency management)
- Vite (front-end asset bundling)
- Bootstrap, jQuery, and custom JS/CSS in public/assets & public/admin

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Presentation Layer
    subgraph "Presentation Layer"
        direction TB
        Client["Client Browser/Mobile"]:::external
        FSMainLayout["Main Site Layout"]:::ui
        FSAdminLayout["Admin Panel Layout"]:::ui
        CustomerPages["Customer Pages"]:::ui
        AuthPages["Auth Pages"]:::ui
        AppointmentViews["Appointment Views"]:::ui
        DoctorViews["Doctor Views"]:::ui
        CustomerAssets["Customer Assets"]:::ui
        AdminAssets["Admin Panel Assets"]:::ui
    end

    %% Application Logic
    subgraph "Application / Business Logic"
        direction TB
        WebServer["Web Server\n(Nginx/Apache)"]:::service
        Router["Routing Layer"]:::logic
        MiddlewareGroup["Middleware"]:::logic
        Controllers["Controllers"]:::logic
        ServiceProv["AppServiceProvider"]:::logic
    end

    subgraph "Controllers"
        direction TB
        AppointmentCtrl["AppointmentController"]:::logic
        AppointmentModelCtrl["AppointmentModelController"]:::logic
        DoctorCtrlPub["DoctorController (Public)"]:::logic
        DoctorCtrlAdmin["Doctors Admin Controller"]:::logic
        DoctorCtrlMain["Doctors Main Controller"]:::logic
        LoginCtrl["LoginController"]:::logic
        RegisterCtrl["RegisterController"]:::logic
        AppointmentNewCtrl["appointmentNewController"]:::logic
    end

    subgraph "Middleware"
        direction TB
        AuthRedirect["RedirectIfAuthenticated"]:::logic
        GuestRedirect["RedirectIfGuest"]:::logic
        AdminAuth["AdminAuthenticate"]:::logic
        AdminRedirect["AdminRedirect"]:::logic
    end

    %% Data Layer
    subgraph "Data Layer"
        direction TB
        Models["Eloquent Models"]:::data
        Database["MySQL Database"]:::data
        FileStorage["File Storage (Local)"]:::data
        Migrations["Database Migrations"]:::data
    end

    subgraph "Models"
        direction TB
        UserModel["User"]:::data
        DoctorModel["Doctor"]:::data
        AppointmentModel["Appointment"]:::data
        ApptModelModel["AppointmentModel"]:::data
    end

    %% External Services
    subgraph "External Services"
        direction TB
        MailService["SMTP / Mailgun"]:::external
    end

    %% Storage & Assets
    Storage["Storage (uploads, logs)"]:::data

    %% Connections
    Client -->|HTTP Request| WebServer
    WebServer -->|index.php → bootstrap/app.php| Router
    Router -->|route resolve| MiddlewareGroup
    MiddlewareGroup -->|auth & role checks| Controllers
    ServiceProv -->|bootstraps| Router
    Controllers -->|uses| Models
    Controllers -->|render| FSMainLayout
    Controllers -->|render| FSAdminLayout
    FSMainLayout -->|includes| CustomerPages
    FSMainLayout -->|includes| AuthPages
    FSMainLayout -->|includes| DoctorViews
    FSAdminLayout -->|includes| AppointmentViews
    FSMainLayout -->|assets| CustomerAssets
    FSAdminLayout -->|assets| AdminAssets
    Models -->|ORM queries| Database
    Controllers -->|file upload| FileStorage
    Controllers -->|on booking| MailService
    Database -->|migrations| Migrations
    FileStorage -->|stores| Storage
    Client -->|fetch assets| CustomerAssets
    Client -->|fetch assets| AdminAssets

    %% Click Events
    click Router "https://github.com/thewebustaad/medicalproject/blob/main/routes/web.php"
    click AuthRedirect "https://github.com/thewebustaad/medicalproject/blob/main/app/Http/Middleware/RedirectIfAuthenticated.php"
    click GuestRedirect "https://github.com/thewebustaad/medicalproject/blob/main/app/Http/Middleware/RedirectIfGuest.php"
    click AdminAuth "https://github.com/thewebustaad/medicalproject/blob/main/app/Http/Middleware/AdminAuthenticate.php"
    click AdminRedirect "https://github.com/thewebustaad/medicalproject/blob/main/app/Http/Middleware/AdminRedirect.php"
    click AppointmentCtrl "https://github.com/thewebustaad/medicalproject/blob/main/app/Http/Controllers/AppointmentController.php"
    click AppointmentModelCtrl "https://github.com/thewebustaad/medicalproject/blob/main/app/Http/Controllers/AppointmentModelController.php"
    click DoctorCtrlPub "https://github.com/thewebustaad/medicalproject/blob/main/app/Http/Controllers/DoctorController.php"
    click DoctorCtrlAdmin "https://github.com/thewebustaad/medicalproject/blob/main/app/Http/Controllers/Doctors/admin/DoctorController.php"
    click DoctorCtrlMain "https://github.com/thewebustaad/medicalproject/blob/main/app/Http/Controllers/Doctors/main/MainDoctorController.php"
    click LoginCtrl "https://github.com/thewebustaad/medicalproject/blob/main/app/Http/Controllers/LoginController.php"
    click RegisterCtrl "https://github.com/thewebustaad/medicalproject/blob/main/app/Http/Controllers/RegisterController.php"
    click AppointmentNewCtrl "https://github.com/thewebustaad/medicalproject/blob/main/app/Http/Controllers/appointmentNewController.php"
    click UserModel "https://github.com/thewebustaad/medicalproject/blob/main/app/Models/User.php"
    click DoctorModel "https://github.com/thewebustaad/medicalproject/blob/main/app/Models/Doctor.php"
    click AppointmentModel "https://github.com/thewebustaad/medicalproject/blob/main/app/Models/Appointment.php"
    click ApptModelModel "https://github.com/thewebustaad/medicalproject/blob/main/app/Models/AppointmentModel.php"
    click ServiceProv "https://github.com/thewebustaad/medicalproject/blob/main/app/Providers/AppServiceProvider.php"
    click FSMainLayout "https://github.com/thewebustaad/medicalproject/blob/main/resources/views/layouts/mainlayout.blade.php"
    click FSAdminLayout "https://github.com/thewebustaad/medicalproject/blob/main/resources/views/layouts/adminpanellayout.blade.php"
    click CustomerPages "https://github.com/thewebustaad/medicalproject/blob/main/resources/views/welcome.blade.php"
    click AppointmentViews "https://github.com/thewebustaad/medicalproject/blob/main/resources/views/viewappointment.blade.php"

    %% Styles
    classDef ui fill:#D0E6FF,stroke:#0366d6,color:#0366d6
    classDef service fill:#E8F8E8,stroke:#28a745,color:#28a745
    classDef logic fill:#E8F4FF,stroke:#1e7e34,color:#0056b3
    classDef data fill:#FFF4E5,stroke:#e69500,color:#e69500
    classDef external fill:#F0F0F0,stroke:#6c757d,color:#6c757d
```
