# aredo97/clearance_system architecture

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

- Interactive diagram: https://gitdiagram.com/aredo97/clearance_system
- Repository: https://github.com/aredo97/clearance_system

## Overview

#### Purpose and Entry Points
This is a Laravel/PHP university clearance-management application, with student requests routed through offices, finance, notifications, certificates, and an AI-assisted interface. The README is the stock Laravel README; scope is inferred from application code layout.

HTTP enters through `public/index.php`, boots via `bootstrap/app.php`, and is dispatched by `routes/web.php` plus authentication routes in `routes/auth.php`. Browser UI is server-rendered Blade with Vite-built assets from `resources/js/app.js` and `resources/css/app.css`.

#### Identity, Roles, and Access Boundary
Laravel authentication supports registration, login, password recovery, email verification, and profile management. Application authorization adds role checks and associates users with offices; user data also includes registration-number and dean/officer extensions.

Key paths:
- `app/Models/User.php`
- `app/Http/Middleware/RoleMiddleware.php`
- `app/Http/Controllers/Auth/AuthenticatedSessionController.php`

Role middleware is the primary boundary separating student, office/department, finance, and administrative workflows.

#### Clearance Domain and Workflow
The central domain is a clearance request. Students submit and inspect requests; assigned offices/department users act on them, with status/detail views representing the workflow state. Requests and offices are persisted through Eloquent models and migrations.

Key paths:
- `app/Models/ClearanceRequest.php`
- `app/Models/Office.php`
- `app/Http/Controllers/ClearanceRequestController.php`

Primary flow: authenticated student → clearance form → `ClearanceRequest` persistence → office/department review → approval or rejection outcomes → student-facing status/details and downstream notification/certificate behavior.

#### Finance and Certificate Stages
Finance is represented as a distinct controller/view area, implying a specialized clearance checkpoint rather than a generic office screen. A certificate controller and printable certificate view form the terminal artifact path after clearance completion.

Key paths:
- `app/Http/Controllers/financeController.php`
- `resources/views/finance/index.blade.php`
- `app/Http/Controllers/CertificateController.php`

The certificate boundary should enforce completed/approved clearance state before rendering or issuing the result.

#### Notifications and Email
Workflow events are surfaced through database notifications and email. Separate notification classes cover request creation, reminders, approvals, and rejections; mail classes/templates support clearance approvals and reminders.

Key paths:
- `app/Http/Controllers/NotificationController.php`
- `app/Notifications/requestApprovedNotification.php`
- `app/Mail/clearanceApprovalMail.php`

This introduces external mail transport configured through `config/mail.php`; database notification storage is created by `database/migrations/2026_07_13_141151_create_notifications_table.php`.

#### AI-Assisted Clearance Interface
An AI endpoint/controller renders prompt and response views, backed by a university-focused agent and a tool explicitly named to submit clearance. This is a controlled integration boundary: conversational handling should delegate actual mutations through the tool/domain workflow rather than bypassing authorization or request-state rules.

Key paths:
- `app/Http/Controllers/AIController.php`
- `app/Ai/Agents/UniversityAgent.php`
- `app/Ai/Tools/SubmitClearanceTool.php`

AI provider/runtime settings are centralized in `config/ai.php`.

#### Runtime, Persistence, and Operations
The application runs on PHP/Laravel (Artisan entry point `artisan`) and is containerizable with `Dockerfile`. It uses Laravel’s configurable database, cache, session, queue, broadcasting, filesystem, and logging subsystems. Migrations establish users, offices, clearance requests, cache, jobs, and notifications.

Key paths:
- `config/database.php`
- `config/queue.php`
- `database/migrations/2026_07_11_073818_create_clearance_requests_table.php`

Real-time infrastructure is provisioned/configurable through `config/broadcasting.php` and `config/reverb.php`, though active event usage is not established beyond `app/Events/HelloWorld.php`.

Main entry points: [`routes/web.php`](https://github.com/aredo97/clearance_system/blob/main/routes/web.php) (Web routes), [`app/Http/Controllers/ClearanceRequestController.php`](https://github.com/aredo97/clearance_system/blob/main/app/Http/Controllers/ClearanceRequestController.php) (Clearance requests), [`app/Models/ClearanceRequest.php`](https://github.com/aredo97/clearance_system/blob/main/app/Models/ClearanceRequest.php) (Clearance request), [`app/Notifications/requestApprovedNotification.php`](https://github.com/aredo97/clearance_system/blob/main/app/Notifications/requestApprovedNotification.php) (Approval notification)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_http["HTTP &amp; UI"]
  node_public_index["Web entry point<br/>PHP entry<br/>[index.php]"]
  node_laravel_bootstrap["Laravel bootstrap<br/>application bootstrap<br/>[app.php]"]
  node_web_routes["Web routes<br/>route definitions<br/>[web.php]"]
  node_auth_session["Authentication<br/>auth controller"]
  node_role_middleware{{"Role boundary<br/>HTTP middleware<br/>[RoleMiddleware.php]"}}
  node_blade_assets["Server UI assets<br/>Blade + Vite assets<br/>[app.js]"]
end

subgraph group_domain["Clearance workflow"]
  node_clearance_controller["Clearance requests<br/>domain controller"]
  node_clearance_request["Clearance request<br/>Eloquent model"]
  node_office["Offices<br/>Eloquent model<br/>[Office.php]"]
  node_finance["Finance checkpoint<br/>finance controller"]
  node_certificate["Certificate issuance<br/>certificate controller"]
end

subgraph group_automation["Notifications &amp; AI"]
  node_notification_controller["Notification center<br/>notification controller"]
  node_approval_notification["Approval notification<br/>Laravel notification"]
  node_approval_mail["Approval email<br/>Laravel mail"]
  node_ai_controller["AI interface<br/>AI controller<br/>[AIController.php]"]
  node_university_agent["University agent<br/>AI agent"]
  node_submit_clearance_tool["Submit clearance tool<br/>AI tool"]
end

subgraph group_platform["Runtime &amp; persistence"]
  node_database[("Application database<br/>Laravel database<br/>[database.php]")]
  node_request_migration["Request schema<br/>database migration"]
  node_notification_store[("Notification storage<br/>database notifications")]
  node_mail_transport{{"Mail transport<br/>mail configuration<br/>[mail.php]"}}
  node_queue["Queue subsystem<br/>Laravel queue<br/>[queue.php]"]
end

node_public_index -->|"boots"| node_laravel_bootstrap
node_laravel_bootstrap -->|"loads"| node_web_routes
node_web_routes -->|"auth endpoints"| node_auth_session
node_web_routes -->|"protected routes"| node_role_middleware
node_web_routes -->|"clearance actions"| node_clearance_controller
node_web_routes -->|"finance actions"| node_finance
node_web_routes -->|"certificate actions"| node_certificate
node_web_routes -->|"AI endpoint"| node_ai_controller
node_role_middleware -->|"authorizes"| node_clearance_controller
node_clearance_controller -->|"creates and updates"| node_clearance_request
node_clearance_request -->|"assigned review"| node_office
node_finance -->|"financial review"| node_clearance_request
node_certificate -->|"reads completion state"| node_clearance_request
node_clearance_controller -->|"workflow outcome"| node_approval_notification
node_approval_notification -->|"shown to user"| node_notification_controller
node_approval_notification -->|"email channel"| node_approval_mail
node_approval_mail -->|"delivers through"| node_mail_transport
node_notification_controller -->|"reads"| node_notification_store
node_ai_controller -->|"invokes"| node_university_agent
node_university_agent -->|"uses"| node_submit_clearance_tool
node_submit_clearance_tool -->|"submits through"| node_clearance_controller
node_clearance_request -->|"persists in"| node_database
node_request_migration -->|"defines table"| node_database
node_notification_store -->|"stored in"| node_database
node_blade_assets -.->|"browser UI"| node_web_routes

click node_public_index "https://github.com/aredo97/clearance_system/blob/main/public/index.php"
click node_laravel_bootstrap "https://github.com/aredo97/clearance_system/blob/main/bootstrap/app.php"
click node_web_routes "https://github.com/aredo97/clearance_system/blob/main/routes/web.php"
click node_auth_session "https://github.com/aredo97/clearance_system/blob/main/app/Http/Controllers/Auth/AuthenticatedSessionController.php"
click node_role_middleware "https://github.com/aredo97/clearance_system/blob/main/app/Http/Middleware/RoleMiddleware.php"
click node_blade_assets "https://github.com/aredo97/clearance_system/blob/main/resources/js/app.js"
click node_clearance_controller "https://github.com/aredo97/clearance_system/blob/main/app/Http/Controllers/ClearanceRequestController.php"
click node_clearance_request "https://github.com/aredo97/clearance_system/blob/main/app/Models/ClearanceRequest.php"
click node_office "https://github.com/aredo97/clearance_system/blob/main/app/Models/Office.php"
click node_finance "https://github.com/aredo97/clearance_system/blob/main/app/Http/Controllers/financeController.php"
click node_certificate "https://github.com/aredo97/clearance_system/blob/main/app/Http/Controllers/CertificateController.php"
click node_notification_controller "https://github.com/aredo97/clearance_system/blob/main/app/Http/Controllers/NotificationController.php"
click node_approval_notification "https://github.com/aredo97/clearance_system/blob/main/app/Notifications/requestApprovedNotification.php"
click node_approval_mail "https://github.com/aredo97/clearance_system/blob/main/app/Mail/clearanceApprovalMail.php"
click node_ai_controller "https://github.com/aredo97/clearance_system/blob/main/app/Http/Controllers/AIController.php"
click node_university_agent "https://github.com/aredo97/clearance_system/blob/main/app/Ai/Agents/UniversityAgent.php"
click node_submit_clearance_tool "https://github.com/aredo97/clearance_system/blob/main/app/Ai/Tools/SubmitClearanceTool.php"
click node_database "https://github.com/aredo97/clearance_system/blob/main/config/database.php"
click node_request_migration "https://github.com/aredo97/clearance_system/blob/main/database/migrations/2026_07_11_073818_create_clearance_requests_table.php"
click node_notification_store "https://github.com/aredo97/clearance_system/blob/main/database/migrations/2026_07_13_141151_create_notifications_table.php"
click node_mail_transport "https://github.com/aredo97/clearance_system/blob/main/config/mail.php"
click node_queue "https://github.com/aredo97/clearance_system/blob/main/config/queue.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_public_index,node_laravel_bootstrap,node_web_routes,node_auth_session,node_role_middleware,node_blade_assets toneBlue
class node_clearance_controller,node_clearance_request,node_office,node_finance,node_certificate toneAmber
class node_notification_controller,node_approval_notification,node_approval_mail,node_ai_controller,node_university_agent,node_submit_clearance_tool toneMint
class node_database,node_request_migration,node_notification_store,node_mail_transport,node_queue toneRose
```

## Components

### HTTP & UI

- [Web entry point](https://github.com/aredo97/clearance_system/blob/main/public/index.php): PHP entry · `public/index.php`
- [Laravel bootstrap](https://github.com/aredo97/clearance_system/blob/main/bootstrap/app.php): application bootstrap · `bootstrap/app.php`
- [Web routes](https://github.com/aredo97/clearance_system/blob/main/routes/web.php): route definitions · `routes/web.php`
- [Authentication](https://github.com/aredo97/clearance_system/blob/main/app/Http/Controllers/Auth/AuthenticatedSessionController.php): auth controller · Handles browser session login. · `app/Http/Controllers/Auth/AuthenticatedSessionController.php`
- [Role boundary](https://github.com/aredo97/clearance_system/blob/main/app/Http/Middleware/RoleMiddleware.php): HTTP middleware · Separates student, office, finance, and administrative workflows. · `app/Http/Middleware/RoleMiddleware.php`
- [Server UI assets](https://github.com/aredo97/clearance_system/blob/main/resources/js/app.js): Blade + Vite assets · `resources/js/app.js`

### Clearance workflow

- [Clearance requests](https://github.com/aredo97/clearance_system/blob/main/app/Http/Controllers/ClearanceRequestController.php): domain controller · Student submission, status, detail, and office-review actions. · `app/Http/Controllers/ClearanceRequestController.php`
- [Clearance request](https://github.com/aredo97/clearance_system/blob/main/app/Models/ClearanceRequest.php): Eloquent model · Central request and workflow-state record. · `app/Models/ClearanceRequest.php`
- [Offices](https://github.com/aredo97/clearance_system/blob/main/app/Models/Office.php): Eloquent model · Assigned clearance-review organizations. · `app/Models/Office.php`
- [Finance checkpoint](https://github.com/aredo97/clearance_system/blob/main/app/Http/Controllers/financeController.php): finance controller · Specialized financial clearance stage. · `app/Http/Controllers/financeController.php`
- [Certificate issuance](https://github.com/aredo97/clearance_system/blob/main/app/Http/Controllers/CertificateController.php): certificate controller · Produces the terminal printable clearance artifact. · `app/Http/Controllers/CertificateController.php`

### Notifications & AI

- [Notification center](https://github.com/aredo97/clearance_system/blob/main/app/Http/Controllers/NotificationController.php): notification controller · `app/Http/Controllers/NotificationController.php`
- [Approval notification](https://github.com/aredo97/clearance_system/blob/main/app/Notifications/requestApprovedNotification.php): Laravel notification · Workflow approval notification channel. · `app/Notifications/requestApprovedNotification.php`
- [Approval email](https://github.com/aredo97/clearance_system/blob/main/app/Mail/clearanceApprovalMail.php): Laravel mail · `app/Mail/clearanceApprovalMail.php`
- [AI interface](https://github.com/aredo97/clearance_system/blob/main/app/Http/Controllers/AIController.php): AI controller · Renders conversational prompt and response views. · `app/Http/Controllers/AIController.php`
- [University agent](https://github.com/aredo97/clearance_system/blob/main/app/Ai/Agents/UniversityAgent.php): AI agent · `app/Ai/Agents/UniversityAgent.php`
- [Submit clearance tool](https://github.com/aredo97/clearance_system/blob/main/app/Ai/Tools/SubmitClearanceTool.php): AI tool · Delegates conversational submissions into the clearance workflow. · `app/Ai/Tools/SubmitClearanceTool.php`

### Runtime & persistence

- [Application database](https://github.com/aredo97/clearance_system/blob/main/config/database.php): Laravel database · Stores users, offices, requests, jobs, and notifications. · `config/database.php`
- [Request schema](https://github.com/aredo97/clearance_system/blob/main/database/migrations/2026_07_11_073818_create_clearance_requests_table.php): database migration · `database/migrations/2026_07_11_073818_create_clearance_requests_table.php`
- [Notification storage](https://github.com/aredo97/clearance_system/blob/main/database/migrations/2026_07_13_141151_create_notifications_table.php): database notifications · `database/migrations/2026_07_13_141151_create_notifications_table.php`
- [Mail transport](https://github.com/aredo97/clearance_system/blob/main/config/mail.php): mail configuration · External email delivery is configured here. · `config/mail.php`
- [Queue subsystem](https://github.com/aredo97/clearance_system/blob/main/config/queue.php): Laravel queue · Configurable asynchronous-work backend. · `config/queue.php`

## Connections

- Web entry point → Laravel bootstrap: boots
- Laravel bootstrap → Web routes: loads
- Web routes → Authentication: auth endpoints
- Web routes → Role boundary: protected routes
- Web routes → Clearance requests: clearance actions
- Web routes → Finance checkpoint: finance actions
- Web routes → Certificate issuance: certificate actions
- Web routes → AI interface: AI endpoint
- Role boundary → Clearance requests: authorizes
- Clearance requests → Clearance request: creates and updates
- Clearance request → Offices: assigned review
- Finance checkpoint → Clearance request: financial review
- Certificate issuance → Clearance request: reads completion state
- Clearance requests → Approval notification: workflow outcome
- Approval notification → Notification center: shown to user
- Approval notification → Approval email: email channel
- Approval email → Mail transport: delivers through
- Notification center → Notification storage: reads
- AI interface → University agent: invokes
- University agent → Submit clearance tool: uses
- Submit clearance tool → Clearance requests: submits through
- Clearance request → Application database: persists in
- Request schema → Application database: defines table
- Notification storage → Application database: stored in
- Server UI assets → Web routes: browser UI
