# gitwithravi/support-ticketing architecture

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

- Interactive diagram: https://gitdiagram.com/gitwithravi/support-ticketing
- Repository: https://github.com/gitwithravi/support-ticketing

## Overview

1. **Overall shape**
   - This is a **single Laravel 12 monolith** with a strong admin/portal split, built on **Filament**, **Livewire**, **Blade**, and **Tailwind**.
   - The core business domain is **university support ticketing**: tickets, campus buildings, maintenance categories, help-center content, and material requests.

2. **Two user-facing surfaces**
   - The app has **two distinct panels** wired through separate Filament panel providers:
     - **Staff/admin panel** for agents, supervisors, and administrators.
     - **Client/student portal** for self-service ticket submission and account management.
   - The client portal includes its own auth flow (`Login`, `Register`, `GoogleRegister`, `VerifyOtp`), dashboard, profile editing, and ticket pages.

3. **Main domain boundary: tickets**
   - `Ticket` is the central aggregate and connects to:
     - `Category` / `SubCategory`
     - `Building`
     - `Client`
     - `TicketComment`, `TicketActivity`, `TicketField`
     - `TicketSla`
     - `Breakage`
   - Ticket lifecycle is driven by dedicated actions for **priority, status, type**, and **SLA creation**, which keeps business rules out of controllers and UI code.

4. **Campus-specific modeling**
   - The repository is specialized for university operations with domain entities for:
     - **Buildings** and building supervisors
     - **Maintenance categories**
     - **Breakages** with responsible-party tracking
     - **Material requests**
     - **User types** that distinguish admin, agent, and university client roles
   - Several migrations show the schema evolving toward campus workflows, including building supervisor pivots, maintenance terms, and university-style authentication fields.

5. **Input channels into the system**
   - Tickets can enter the system through multiple paths:
     - **Client portal forms**
     - **Public/support pages** in `resources/views/forms` and `resources/views/articles`
     - **REST API** endpoints under `app/Http/Controllers/Api`
     - **Inbound email ingestion** using `Mailbox` plus queued import jobs
   - This makes the system multi-channel: web UI, API, and email all converge into the same ticket domain.

6. **Workflow and automation**
   - Business automation is handled by **jobs**, **console commands**, **observers**, and **actions**:
     - `ImportImapEmails` / `ImportImapEmailsCommand` for email-to-ticket conversion
     - `CloseResolvedTicketJob` / `CloseResolvedTicketsCommand` for ticket closure automation
     - observers for tickets, help-center content, and form fields to keep related records consistent
   - The architecture favors event-like side effects around model changes instead of putting everything in controllers.

7. **Authorization and data scoping**
   - Access control is layered:
     - **Policies** for models like tickets, users, buildings, categories, help-center content, and material requests
     - **Filament Shield**-style role/permission configuration
     - **Middleware** for active-user checks, locale handling, policy bypass in controlled contexts, and client auth debugging
   - Additional model scopes (`ClientScope`, `GroupScope`, `CategoryScope`) imply record visibility is constrained by group/category relationships, not just by role.

8. **Help center subsystem**
   - There is a separate knowledge-base domain under `app/Models/HelpCenter` and `app/Filament/Clusters/HelpCenter`.
   - It includes **articles, categories, sections, and forms**, with form fields managed through relation managers.
   - This subsystem is used both publicly and inside Filament, so it acts as a shared content layer for self-service support.

9. **Notifications and communications**
   - Ticket state changes trigger email notifications such as:
     - created
     - resolved
     - closed
     - comment by agent
     - escalation required
     - OTP verification
   - Livewire components handle **ticket comments** and comment creation in the UI, while notifications keep clients and staff synchronized asynchronously.

10. **Admin UX and reporting**
    - The staff panel is heavily built around Filament **resources, relation managers, widgets, infolists, and custom form/table components**.
    - Notable operational features include:
      - ticket exports
      - pivot-table style widgets for building/category/agent status
      - ticket activity views
      - custom notes/comments components
    - This suggests the admin experience is designed for operational throughput and oversight rather than a simple CRUD interface.

11. **Settings and external integration**
    - Cross-cutting configuration is centralized in Laravel **Settings** classes and persisted via settings migrations.
    - A dedicated `PrfApiService` and PRF API settings indicate integration with an external institutional system.
    - The app also uses standard Laravel infrastructure for **queues, mail, Sanctum, filesystem, and database-backed sessions/cache**, with MySQL/PostgreSQL support implied by the README.

12. **Persistence and evolution**
    - The database layer is migration-heavy and reflects a mature domain model with:
      - tickets, comments, activities, SLAs
      - client auth and OTP fields
      - help-center content
      - groups, permissions, and pivots
      - imports/exports tracking
    - Seeders and factories exist for most core entities, which suggests the repo supports both development/test data and repeatable setup.

13. **Tests and quality boundary**
    - The test suite is focused on core domain behavior: models, enums, observers, traits, and settings.
    - That reinforces that the most important architecture boundary is the **domain model and its side effects**, not just HTTP endpoints.

14. **How to draw the architecture**
    - A good diagram would place **Ticket** at the center, with inbound channels from **client portal**, **admin panel**, **API**, and **email import**.
    - Surround that core with **authorization/scoping**, **notifications**, **SLA automation**, **help center**, **campus entities**, and **external PRF integration**.
    - The UI layer is split into **Filament staff panel** and **Filament client panel**, both backed by the same Laravel domain and database.

Main entry points: [`app/Models/Ticket.php`](https://github.com/gitwithravi/support-ticketing/blob/main/app/Models/Ticket.php) (Ticket), [`app/Notifications/TicketCreated.php`](https://github.com/gitwithravi/support-ticketing/blob/main/app/Notifications/TicketCreated.php) (Notifications), [`app/Models/HelpCenter/Article.php`](https://github.com/gitwithravi/support-ticketing/blob/main/app/Models/HelpCenter/Article.php) (Help center), [`app/Filament/Resources/TicketResource.php`](https://github.com/gitwithravi/support-ticketing/blob/main/app/Filament/Resources/TicketResource.php) (Filament admin)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_grp_ui["User surfaces"]
  node_node_staff_panel["Staff panel<br/>Filament panel"]
  node_node_client_portal["Client portal<br/>Filament panel"]
  node_node_public_pages["Public pages<br/>Blade/HTTP UI<br/>[show.blade.php]"]
end

subgraph group_grp_domain["Core domain"]
  node_node_ticket[("Ticket<br/>core aggregate<br/>[Ticket.php]")]
  node_node_campus[("Campus data<br/>domain models<br/>[Building.php]")]
  node_node_breakage[("Breakages<br/>domain model<br/>[Breakage.php]")]
  node_node_material[("Material requests<br/>domain model")]
  node_node_help_center[("Help center<br/>knowledge base<br/>[Article.php]")]
end

subgraph group_grp_ops["Workflow"]
  node_node_ticket_actions["Ticket actions<br/>business actions"]
  node_node_ticket_automation["Automation<br/>jobs and commands"]
  node_node_observers(("Observers<br/>model hooks<br/>[TicketObserver.php]"))
  node_node_notifications["Notifications<br/>mail/alerts<br/>[TicketCreated.php]"]
  node_node_authorization{{"Access control<br/>policies and scopes<br/>[TicketPolicy.php]"}}
end

subgraph group_grp_platform["Platform"]
  node_node_api["REST API<br/>HTTP API"]
  node_node_livewire["Livewire comments<br/>interactive UI"]
  node_node_filament_admin["Filament admin<br/>admin resources<br/>[TicketResource.php]"]
  node_node_filament_client["Filament client<br/>client resources<br/>[TicketResource.php]"]
  node_node_settings["Settings<br/>configuration"]
  node_node_prf["PRF integration<br/>external service<br/>[PrfApiService.php]"]
end

node_node_staff_panel -->|"serves"| node_node_filament_admin
node_node_client_portal -->|"serves"| node_node_filament_client
node_node_public_pages -->|"renders"| node_node_help_center
node_node_filament_admin -->|"manages"| node_node_ticket
node_node_filament_client -->|"creates/views"| node_node_ticket
node_node_api -->|"ingests"| node_node_ticket
node_node_livewire -->|"comments on"| node_node_ticket
node_node_ticket_actions -->|"mutates"| node_node_ticket
node_node_ticket_automation -->|"automates"| node_node_ticket
node_node_observers -->|"reacts to"| node_node_ticket
node_node_notifications -->|"notifies for"| node_node_ticket
node_node_authorization -->|"controls access"| node_node_ticket
node_node_ticket -->|"relates to"| node_node_campus
node_node_ticket -->|"tracks"| node_node_breakage
node_node_ticket -->|"connects to"| node_node_material
node_node_ticket -->|"supported by"| node_node_help_center
node_node_campus -->|"scoped by"| node_node_authorization
node_node_help_center -->|"kept consistent by"| node_node_observers
node_node_settings -->|"configures"| node_node_prf
node_node_prf -->|"integrates with"| node_node_material
node_node_notifications -->|"updates"| node_node_client_portal
node_node_notifications -->|"updates"| node_node_filament_admin

click node_node_staff_panel "https://github.com/gitwithravi/support-ticketing/blob/main/app/Providers/Filament/AppPanelProvider.php"
click node_node_client_portal "https://github.com/gitwithravi/support-ticketing/blob/main/app/Providers/Filament/ClientPanelProvider.php"
click node_node_public_pages "https://github.com/gitwithravi/support-ticketing/blob/main/resources/views/articles/show.blade.php"
click node_node_ticket "https://github.com/gitwithravi/support-ticketing/blob/main/app/Models/Ticket.php"
click node_node_campus "https://github.com/gitwithravi/support-ticketing/blob/main/app/Models/Building.php"
click node_node_breakage "https://github.com/gitwithravi/support-ticketing/blob/main/app/Models/Breakage.php"
click node_node_material "https://github.com/gitwithravi/support-ticketing/blob/main/app/Models/MaterialRequest.php"
click node_node_help_center "https://github.com/gitwithravi/support-ticketing/blob/main/app/Models/HelpCenter/Article.php"
click node_node_ticket_actions "https://github.com/gitwithravi/support-ticketing/blob/main/app/Actions/Tickets/UpdateTicketStatus.php"
click node_node_ticket_automation "https://github.com/gitwithravi/support-ticketing/blob/main/app/Jobs/ImportImapEmails.php"
click node_node_observers "https://github.com/gitwithravi/support-ticketing/blob/main/app/Observers/TicketObserver.php"
click node_node_notifications "https://github.com/gitwithravi/support-ticketing/blob/main/app/Notifications/TicketCreated.php"
click node_node_authorization "https://github.com/gitwithravi/support-ticketing/blob/main/app/Policies/TicketPolicy.php"
click node_node_api "https://github.com/gitwithravi/support-ticketing/blob/main/app/Http/Controllers/Api/TicketController.php"
click node_node_livewire "https://github.com/gitwithravi/support-ticketing/blob/main/app/Livewire/CreateTicketComment.php"
click node_node_filament_admin "https://github.com/gitwithravi/support-ticketing/blob/main/app/Filament/Resources/TicketResource.php"
click node_node_filament_client "https://github.com/gitwithravi/support-ticketing/blob/main/app/Filament/Client/Resources/TicketResource.php"
click node_node_settings "https://github.com/gitwithravi/support-ticketing/blob/main/app/Settings/WorkflowSettings.php"
click node_node_prf "https://github.com/gitwithravi/support-ticketing/blob/main/app/Services/PrfApiService.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_node_staff_panel,node_node_client_portal,node_node_public_pages toneBlue
class node_node_ticket,node_node_campus,node_node_breakage,node_node_material,node_node_help_center toneAmber
class node_node_ticket_actions,node_node_ticket_automation,node_node_observers,node_node_notifications,node_node_authorization toneMint
class node_node_api,node_node_livewire,node_node_filament_admin,node_node_filament_client,node_node_settings,node_node_prf toneRose
```

## Components

### User surfaces

Staff panel, client portal, and public support pages.

- [Staff panel](https://github.com/gitwithravi/support-ticketing/blob/main/app/Providers/Filament/AppPanelProvider.php): Filament panel · Admin-facing Filament surface for operations and management. · `app/Providers/Filament/AppPanelProvider.php`
- [Client portal](https://github.com/gitwithravi/support-ticketing/blob/main/app/Providers/Filament/ClientPanelProvider.php): Filament panel · Self-service portal for students/clients with auth and ticketing. · `app/Providers/Filament/ClientPanelProvider.php`
- [Public pages](https://github.com/gitwithravi/support-ticketing/blob/main/resources/views/articles/show.blade.php): Blade/HTTP UI · Public article, category, and form pages used for support intake. · `resources/views/articles/show.blade.php`

### Core domain

Ticketing, campus entities, help center, and shared models.

- [Ticket](https://github.com/gitwithravi/support-ticketing/blob/main/app/Models/Ticket.php): core aggregate · Central support case model tying together requesters, campus context, workflow, and history. · `app/Models/Ticket.php`
- [Campus data](https://github.com/gitwithravi/support-ticketing/blob/main/app/Models/Building.php): domain models · Buildings, categories, subcategories, clients, and group-based scoping for university workflows. · `app/Models/Building.php`
- [Breakages](https://github.com/gitwithravi/support-ticketing/blob/main/app/Models/Breakage.php): domain model · Maintenance/breakage tracking attached to tickets. · `app/Models/Breakage.php`
- [Material requests](https://github.com/gitwithravi/support-ticketing/blob/main/app/Models/MaterialRequest.php): domain model · Separate operational request stream with items and status tracking. · `app/Models/MaterialRequest.php`
- [Help center](https://github.com/gitwithravi/support-ticketing/blob/main/app/Models/HelpCenter/Article.php): knowledge base · Shared self-service content layer for articles, categories, sections, and forms. · `app/Models/HelpCenter/Article.php`

### Workflow

Actions, jobs, commands, observers, notifications, and policy enforcement.

- [Ticket actions](https://github.com/gitwithravi/support-ticketing/blob/main/app/Actions/Tickets/UpdateTicketStatus.php): business actions · Encapsulated ticket mutations for priority, status, type, and SLA creation. · `app/Actions/Tickets/UpdateTicketStatus.php`
- [Automation](https://github.com/gitwithravi/support-ticketing/blob/main/app/Jobs/ImportImapEmails.php): jobs and commands · Background processing for email import and automatic ticket closure. · `app/Jobs/ImportImapEmails.php`
- [Observers](https://github.com/gitwithravi/support-ticketing/blob/main/app/Observers/TicketObserver.php): model hooks · Side effects that keep tickets and help-center records consistent. · `app/Observers/TicketObserver.php`
- [Notifications](https://github.com/gitwithravi/support-ticketing/blob/main/app/Notifications/TicketCreated.php): mail/alerts · Async notifications for ticket lifecycle events and OTP verification. · `app/Notifications/TicketCreated.php`
- [Access control](https://github.com/gitwithravi/support-ticketing/blob/main/app/Policies/TicketPolicy.php): policies and scopes · Policies, middleware, and model scopes for role and record visibility. · `app/Policies/TicketPolicy.php`

### Platform

Filament, settings, API, and infrastructure integration.

- [REST API](https://github.com/gitwithravi/support-ticketing/blob/main/app/Http/Controllers/Api/TicketController.php): HTTP API · Programmatic ticket intake and read endpoints. · `app/Http/Controllers/Api/TicketController.php`
- [Livewire comments](https://github.com/gitwithravi/support-ticketing/blob/main/app/Livewire/CreateTicketComment.php): interactive UI · Ticket comment composition and threaded comment display in the UI. · `app/Livewire/CreateTicketComment.php`
- [Filament admin](https://github.com/gitwithravi/support-ticketing/blob/main/app/Filament/Resources/TicketResource.php): admin resources · Staff resources, relation managers, widgets, exports, and infolists around tickets and operations. · `app/Filament/Resources/TicketResource.php`
- [Filament client](https://github.com/gitwithravi/support-ticketing/blob/main/app/Filament/Client/Resources/TicketResource.php): client resources · Client-facing pages, ticket resource, and onboarding/auth flow in Filament. · `app/Filament/Client/Resources/TicketResource.php`
- [Settings](https://github.com/gitwithravi/support-ticketing/blob/main/app/Settings/WorkflowSettings.php): configuration · Persisted workflow, general, advanced, and PRF API settings. · `app/Settings/WorkflowSettings.php`
- [PRF integration](https://github.com/gitwithravi/support-ticketing/blob/main/app/Services/PrfApiService.php): external service · Institutional API integration used by settings, users, and material requests. · `app/Services/PrfApiService.php`

## Connections

- Staff panel → Filament admin: serves · The staff panel is implemented through Filament admin resources and widgets.
- Client portal → Filament client: serves · The client panel exposes the self-service ticketing experience.
- Public pages → Help center: renders · Public pages surface help-center content and support forms.
- Filament admin → Ticket: manages · Admin resources operate on tickets and related records.
- Filament client → Ticket: creates/views · Clients submit and track their own tickets.
- REST API → Ticket: ingests · REST endpoints create and expose tickets programmatically.
- Livewire comments → Ticket: comments on · Livewire components add and display ticket comments.
- Ticket actions → Ticket: mutates · Dedicated actions encapsulate core ticket lifecycle changes.
- Automation → Ticket: automates · Jobs and commands import email and close resolved tickets.
- Observers → Ticket: reacts to · Observers enforce consistency around ticket and help-center changes.
- Notifications → Ticket: notifies for · Notifications broadcast ticket lifecycle events to clients and staff.
- Access control → Ticket: controls access · Policies, middleware, and scopes constrain ticket visibility and actions.
- Ticket → Campus data: relates to · Tickets are scoped by buildings, categories, subcategories, clients, and groups.
- Ticket → Breakages: tracks · Breakage records capture maintenance responsibility and outcomes.
- Ticket → Material requests: connects to · Material requests form a parallel operational flow in the same domain.
- Ticket → Help center: supported by · Help-center content supports self-service ticket resolution.
- Campus data → Access control: scoped by · Group and category scopes limit records by campus relationships.
- Help center → Observers: kept consistent by · Article, category, form, and field observers maintain content integrity.
- Settings → PRF integration: configures · Persisted settings supply credentials and workflow options for the external API.
- PRF integration → Material requests: integrates with · PRF integration supports material request and user synchronization workflows.
- Notifications → Client portal: updates · Client-facing notifications keep the portal in sync with ticket state.
- Notifications → Filament admin: updates · Staff receives async updates on ticket activity and escalations.
