# tikajhq/tiket architecture

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

- Interactive diagram: https://gitdiagram.com/tikajhq/tiket
- Repository: https://github.com/tikajhq/tiket

## Overview

1. **Overall shape**
   This is a PHP 7.x helpdesk application built on CodeIgniter, with a custom in-house layer called “Scone” on top of the framework. It follows a classic server-rendered MVC architecture: HTTP requests enter `index.php`, route through CodeIgniter, hit controllers, which coordinate models and render views.

2. **Main user-facing domains**
   The application is organized around four core business areas:
   - **Authentication / access control**
   - **Ticketing / thread conversations**
   - **User management and KYC/profile data**
   - **SMS / notification handling**
   
   The README confirms the key product behavior: separate roles for Admin, Agent, and User; ticket creation/reply by email; attachments; and dashboard reporting.

3. **Role and boundary model**
   Role separation is a major architectural boundary. Admin and agent workflows are distinct from end-user workflows, and the views reflect that split:
   - `views/admin/*` for operational and reporting screens
   - `views/user/*` for customer/user self-service
   - `views/auth/*` for login, OTP, password reset, etc.
   - `views/limited` and `views/deactivated` for restricted access states
   
   This suggests authorization is enforced both at controller level and in the layout/menu layer.

4. **Controller layer**
   Controllers are grouped by responsibility:
   - `Auth`, `User`, `Tickets`, `Sms`, `Tabler` are the main web controllers
   - `controllers/API/*` exposes programmatic endpoints
   - `controllers/API/sms/Sms.php` indicates a dedicated SMS API surface
   - `controllers/API/Pub.php`, `Ticket.php`, `User.php` suggest API access to public or external integrations
   
   The controllers are the orchestration layer: they read request input, apply auth rules, invoke models, and select the appropriate view or API response.

5. **Model layer and domain decomposition**
   Models are split into domain-oriented folders:
   - `models/user/*` for auth, profile, bank, documents, KYC, locations, FA2/2FA, flow logic
   - `models/ticket/*` for tickets, messages, and threads
   - `models/notification/*` for email and SMS notifications
   - `models/sms/*` for SMS-specific user and sender/provider logic
   - `models/storage/Storage_model.php` for file/asset persistence
   - `models/language/Language_model.php` and `models/core/*` for shared platform services
   
   This is the main business logic boundary. Ticketing, identity/KYC, notifications, and storage are clearly separated rather than being lumped into generic CRUD models.

6. **Core framework extensions**
   The repository includes custom framework extensions in `application/core`:
   - `MY_Controller.php`
   - `MY_Model.php`
   
   These are the shared base classes used to standardize behavior across the app, likely adding common auth/session handling, helper loading, response formatting, and model utilities.

7. **Shared platform services**
   The `models/core` folder contains reusable service-style components:
   - `Session_model`, `Token_model` for session and token handling
   - `Settings_model` for app configuration stored in the database
   - `Template_model` and `QuickTemplate` for rendering/view composition
   - `DataHandler` and `Utils` for common data transformations
   - `BaseApi_model` for shared API mechanics
   
   This indicates the app has a platform layer beneath the feature models, handling cross-cutting concerns like sessions, tokens, template rendering, and utility work.

8. **Ticket lifecycle and conversation flow**
   Ticketing is the central business workflow. The `ticket` models separate:
   - ticket records
   - message history
   - thread handling
   
   Views like `ticket/create_new`, `ticket/view_ticket`, `ticket/list`, `ticket/my_tickets`, and `ticket/close_ticket` show the user journey. The README’s “reply to ticket thread by replying on associated email thread” feature implies a bi-directional flow between email and ticket threads, with the system mapping incoming mail back into ticket messages.

9. **Notification and integration flow**
   Notifications are first-class subsystems:
   - `notification/Email_model.php`
   - `notification/Sms_model.php`
   - SMS controller/API endpoints
   - README mentions automatic ticket creation from email
   
   The architecture likely uses email as both an outbound notification channel and an inbound ticket-ingestion channel. SMS appears to be another outbound notification and operational channel, with dedicated views for sending and inspecting SMS activity.

10. **Authentication, security, and identity**
   Authentication is not just login/password; the repository includes:
   - OTP login flow in `views/auth/otp.php`
   - password reset and forgot password screens
   - `FA2Auth_model.php` for second-factor support
   - `Token_model` for token-based security actions
   - permissions constants in configuration
   
   This suggests the app enforces a fairly rich identity boundary with multi-step login and privileged operations.

11. **Storage and attachments**
   Attachments are an explicit feature, and the repo has a `storage` model plus upload-capable CodeIgniter infrastructure. File handling is therefore a distinct subsystem, likely used by ticket attachments, user documents, and KYC uploads. The `Documents_model`, `Storage_model`, and various ticket/user views point to shared document persistence across domains.

12. **Rendering and templating**
   The app is primarily server-rendered with PHP views, but it also includes a bundled Mustache library under `application/libraries/mustache`. There are also template-related models and shared view helpers. This indicates mixed presentation support: standard CodeIgniter views for most pages, with templated rendering available for email/notifications or dynamic content generation.

13. **Database and persistence**
   Persistence is MySQL-oriented by default, configured through `application/config/database.php`, with a demo SQL dump in `tiket_demo.sql`. The repository includes a full CodeIgniter database layer and common cache/session drivers, so the app can persist application state in the DB and potentially use file/memcached/redis-backed session/cache mechanisms depending on configuration.

14. **Frontend assets and admin UI**
   `assets/` contains a substantial prebuilt frontend stack: CSS themes, jQuery-based scripts, charts, datatables, select2, date pickers, rich text/UI plugins, and fullcalendar. This is an admin-heavy interface with dashboards, reports, forms, and interactive tables. The frontend is bundled as static assets served by the PHP app, not as a separate SPA.

15. **Deployment and environment boundaries**
   The project expects a traditional PHP deployment with a web server or built-in PHP server, `.htaccess` rewrite support, and a configurable client/product settings split:
   - `application/config/client.config.sample.php` for environment-specific integration details
   - `application/config/config.product.php` for product naming/branding
   - `composer.json` for PHP dependency installation
   
   External services that materially affect architecture are email, SMS, and the relational database; the rest of the application is self-contained within the CodeIgniter runtime.

Main entry points: [`application/core/MY_Controller.php`](https://github.com/tikajhq/tiket/blob/master/application/core/MY_Controller.php) (MY_Controller), [`assets/js/app.js`](https://github.com/tikajhq/tiket/blob/master/assets/js/app.js) (Assets), [`system/core/CodeIgniter.php`](https://github.com/tikajhq/tiket/blob/master/system/core/CodeIgniter.php) (CodeIgniter), [`application/models/user/Auth_model.php`](https://github.com/tikajhq/tiket/blob/master/application/models/user/Auth_model.php) (Identity)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_group_framework["Framework"]
  node_index_php["index.php<br/>front controller<br/>[index.php]"]
  node_ci_core["CodeIgniter<br/>framework core<br/>[CodeIgniter.php]"]
  node_my_controller["MY_Controller<br/>app base controller<br/>[MY_Controller.php]"]
  node_my_model["MY_Model<br/>app base model<br/>[MY_Model.php]"]
  node_helpers["Helpers<br/>[core_helper.php]"]
  node_template_models["Templates<br/>rendering models<br/>[Template_model.php]"]
  node_mustache["Mustache<br/>templating library<br/>[Engine.php]"]
end

subgraph group_group_domain["Domain"]
  node_auth_ctrl["Auth<br/>web controller<br/>[Auth.php]"]
  node_user_ctrl["User<br/>web controller<br/>[User.php]"]
  node_tickets_ctrl["Tickets<br/>web controller<br/>[Tickets.php]"]
  node_sms_ctrl["Sms<br/>web controller<br/>[Sms.php]"]
  node_api_surface["API<br/>integration controllers<br/>[Pub.php]"]
  node_auth_models["Identity<br/>auth and profile models<br/>[Auth_model.php]"]
  node_ticket_models["Ticketing<br/>ticket models<br/>[Ticket_model.php]"]
  node_notification_models["Notifications<br/>notification models"]
  node_sms_models["SMS Models<br/>[Smsmodel_model.php]"]
  node_storage_model[("Storage<br/>file persistence<br/>[Storage_model.php]")]
end

subgraph group_group_presentation["Presentation"]
  node_admin_views["Admin UI<br/>admin views<br/>[dashboard.php]"]
  node_auth_views["Auth UI<br/>auth views<br/>[login.php]"]
  node_ticket_views["Ticket UI<br/>ticket views<br/>[list.php]"]
  node_user_views["User UI<br/>user views<br/>[dashboard.php]"]
  node_sms_views["SMS UI<br/>sms views<br/>[send_sms.php]"]
end

subgraph group_group_platform["Platform"]
  node_config["Config<br/>[config.php]"]
  node_assets["Assets<br/>frontend bundle<br/>[app.js]"]
  node_database[("MySQL DB<br/>persistence<br/>[database.php]")]
end

node_index_php -->|"boots"| node_ci_core
node_ci_core -->|"loads"| node_config
node_ci_core -->|"extends"| node_my_controller
node_ci_core -->|"extends"| node_my_model
node_my_controller -->|"uses"| node_helpers
node_my_controller -->|"hosts"| node_auth_ctrl
node_my_controller -->|"hosts"| node_user_ctrl
node_my_controller -->|"hosts"| node_tickets_ctrl
node_my_controller -->|"hosts"| node_sms_ctrl
node_my_controller -->|"hosts"| node_api_surface
node_auth_ctrl -->|"orchestrates"| node_auth_models
node_user_ctrl -->|"orchestrates"| node_auth_models
node_tickets_ctrl -->|"orchestrates"| node_ticket_models
node_tickets_ctrl -->|"triggers"| node_notification_models
node_sms_ctrl -->|"orchestrates"| node_sms_models
node_api_surface -->|"exposes"| node_ticket_models
node_api_surface -->|"exposes"| node_auth_models
node_notification_models -->|"renders"| node_mustache
node_auth_models -->|"stores"| node_storage_model
node_ticket_models -->|"stores"| node_storage_model
node_storage_model -->|"persists"| node_database
node_ticket_views -->|"styled by"| node_assets
node_admin_views -->|"styled by"| node_assets
node_auth_views -->|"styled by"| node_assets
node_user_views -->|"styled by"| node_assets
node_sms_views -->|"styled by"| node_assets
node_template_models -->|"uses"| node_mustache
node_config -->|"configures"| node_database

click node_index_php "https://github.com/tikajhq/tiket/blob/master/index.php"
click node_ci_core "https://github.com/tikajhq/tiket/blob/master/system/core/CodeIgniter.php"
click node_my_controller "https://github.com/tikajhq/tiket/blob/master/application/core/MY_Controller.php"
click node_my_model "https://github.com/tikajhq/tiket/blob/master/application/core/MY_Model.php"
click node_helpers "https://github.com/tikajhq/tiket/blob/master/application/helpers/core_helper.php"
click node_auth_ctrl "https://github.com/tikajhq/tiket/blob/master/application/controllers/Auth.php"
click node_user_ctrl "https://github.com/tikajhq/tiket/blob/master/application/controllers/User.php"
click node_tickets_ctrl "https://github.com/tikajhq/tiket/blob/master/application/controllers/Tickets.php"
click node_sms_ctrl "https://github.com/tikajhq/tiket/blob/master/application/controllers/Sms.php"
click node_api_surface "https://github.com/tikajhq/tiket/blob/master/application/controllers/API/Pub.php"
click node_auth_models "https://github.com/tikajhq/tiket/blob/master/application/models/user/Auth_model.php"
click node_ticket_models "https://github.com/tikajhq/tiket/blob/master/application/models/ticket/Ticket_model.php"
click node_notification_models "https://github.com/tikajhq/tiket/blob/master/application/models/notification/Notification_model.php"
click node_sms_models "https://github.com/tikajhq/tiket/blob/master/application/models/sms/Smsmodel_model.php"
click node_storage_model "https://github.com/tikajhq/tiket/blob/master/application/models/storage/Storage_model.php"
click node_template_models "https://github.com/tikajhq/tiket/blob/master/application/models/core/Template_model.php"
click node_admin_views "https://github.com/tikajhq/tiket/blob/master/application/views/admin/dashboard.php"
click node_auth_views "https://github.com/tikajhq/tiket/blob/master/application/views/auth/login.php"
click node_ticket_views "https://github.com/tikajhq/tiket/blob/master/application/views/ticket/list.php"
click node_user_views "https://github.com/tikajhq/tiket/blob/master/application/views/user/dashboard.php"
click node_sms_views "https://github.com/tikajhq/tiket/blob/master/application/views/sms/send_sms.php"
click node_config "https://github.com/tikajhq/tiket/blob/master/application/config/config.php"
click node_assets "https://github.com/tikajhq/tiket/blob/master/assets/js/app.js"
click node_mustache "https://github.com/tikajhq/tiket/blob/master/application/libraries/mustache/src/Mustache/Engine.php"
click node_database "https://github.com/tikajhq/tiket/blob/master/application/config/database.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_index_php,node_ci_core,node_my_controller,node_my_model,node_helpers,node_template_models,node_mustache toneBlue
class node_auth_ctrl,node_user_ctrl,node_tickets_ctrl,node_sms_ctrl,node_api_surface,node_auth_models,node_ticket_models,node_notification_models,node_sms_models,node_storage_model toneAmber
class node_admin_views,node_auth_views,node_ticket_views,node_user_views,node_sms_views toneMint
class node_config,node_assets,node_database toneRose
```

## Components

### Framework

CodeIgniter core plus app-specific base classes and shared helpers.

- [index.php](https://github.com/tikajhq/tiket/blob/master/index.php): front controller · Entry point that boots the application and hands requests to CodeIgniter. · `index.php`
- [CodeIgniter](https://github.com/tikajhq/tiket/blob/master/system/core/CodeIgniter.php): framework core · The underlying MVC framework runtime, router, loader, session, database, and HTTP handling. · `system/core/CodeIgniter.php`
- [MY_Controller](https://github.com/tikajhq/tiket/blob/master/application/core/MY_Controller.php): app base controller · Project-specific controller base class for shared request, auth, and rendering behavior. · `application/core/MY_Controller.php`
- [MY_Model](https://github.com/tikajhq/tiket/blob/master/application/core/MY_Model.php): app base model · Project-specific model base class for shared data access behavior. · `application/core/MY_Model.php`
- [Helpers](https://github.com/tikajhq/tiket/blob/master/application/helpers/core_helper.php): shared helpers · Common helper functions used across controllers, views, and models. · `application/helpers/core_helper.php`
- [Templates](https://github.com/tikajhq/tiket/blob/master/application/models/core/Template_model.php): rendering models · Shared template composition and quick rendering support. · `application/models/core/Template_model.php`
- [Mustache](https://github.com/tikajhq/tiket/blob/master/application/libraries/mustache/src/Mustache/Engine.php): templating library · Bundled Mustache renderer for template-driven output such as messages or emails. · `application/libraries/mustache/src/Mustache/Engine.php`

### Domain

Feature controllers and models for auth, users, tickets, notifications, storage, and SMS.

- [Auth](https://github.com/tikajhq/tiket/blob/master/application/controllers/Auth.php): web controller · Login, OTP, password reset, and access-control entry points. · `application/controllers/Auth.php`
- [User](https://github.com/tikajhq/tiket/blob/master/application/controllers/User.php): web controller · User profile, dashboard, and account management orchestration. · `application/controllers/User.php`
- [Tickets](https://github.com/tikajhq/tiket/blob/master/application/controllers/Tickets.php): web controller · Ticket creation, listing, viewing, and lifecycle actions. · `application/controllers/Tickets.php`
- [Sms](https://github.com/tikajhq/tiket/blob/master/application/controllers/Sms.php): web controller · Administrative SMS sending and inspection screens. · `application/controllers/Sms.php`
- [API](https://github.com/tikajhq/tiket/blob/master/application/controllers/API/Pub.php): integration controllers · Programmatic endpoints for users, tickets, public access, and SMS integrations. · `application/controllers/API/Pub.php`
- [Identity](https://github.com/tikajhq/tiket/blob/master/application/models/user/Auth_model.php): auth and profile models · Authentication, 2FA, user details, KYC, documents, banking, locations, and flow logic. · `application/models/user/Auth_model.php`
- [Ticketing](https://github.com/tikajhq/tiket/blob/master/application/models/ticket/Ticket_model.php): ticket models · Ticket records, threads, and message history. · `application/models/ticket/Ticket_model.php`
- [Notifications](https://github.com/tikajhq/tiket/blob/master/application/models/notification/Notification_model.php): notification models · Outbound email and SMS notification logic plus notification coordination. · `application/models/notification/Notification_model.php`
- [SMS Models](https://github.com/tikajhq/tiket/blob/master/application/models/sms/Smsmodel_model.php): sms models · SMS-specific data models for users and sender/provider behavior. · `application/models/sms/Smsmodel_model.php`
- [Storage](https://github.com/tikajhq/tiket/blob/master/application/models/storage/Storage_model.php): file persistence · Attachment and document storage handling. · `application/models/storage/Storage_model.php`

### Presentation

Server-rendered views and shared UI shells.

- [Admin UI](https://github.com/tikajhq/tiket/blob/master/application/views/admin/dashboard.php): admin views · Operational dashboards, reports, KYC, withdrawals, and member management screens. · `application/views/admin/dashboard.php`
- [Auth UI](https://github.com/tikajhq/tiket/blob/master/application/views/auth/login.php): auth views · Login, OTP, registration, password reset, and unauthorized screens. · `application/views/auth/login.php`
- [Ticket UI](https://github.com/tikajhq/tiket/blob/master/application/views/ticket/list.php): ticket views · Create, list, view, close, and my-ticket pages. · `application/views/ticket/list.php`
- [User UI](https://github.com/tikajhq/tiket/blob/master/application/views/user/dashboard.php): user views · User dashboards, profile, list, and password management screens. · `application/views/user/dashboard.php`
- [SMS UI](https://github.com/tikajhq/tiket/blob/master/application/views/sms/send_sms.php): sms views · Screens for sending and reviewing SMS activity. · `application/views/sms/send_sms.php`

### Platform

Environment, config, persistence, and bundled frontend assets.

- [Config](https://github.com/tikajhq/tiket/blob/master/application/config/config.php): app config · Routing, permissions, database, environment, and product settings. · `application/config/config.php`
- [Assets](https://github.com/tikajhq/tiket/blob/master/assets/js/app.js): frontend bundle · Bundled CSS, JS, charting, tables, forms, and UI plugins for the server-rendered interface. · `assets/js/app.js`
- [MySQL DB](https://github.com/tikajhq/tiket/blob/master/application/config/database.php): persistence · Primary relational persistence backed by CodeIgniter database configuration and SQL dump. · `application/config/database.php`

## Connections

- index.php → CodeIgniter: boots · The entry script initializes the CodeIgniter runtime.
- CodeIgniter → Config: loads · Framework startup reads app configuration and routing.
- CodeIgniter → MY_Controller: extends · Controllers inherit shared application behavior.
- CodeIgniter → MY_Model: extends · Models inherit shared application behavior.
- MY_Controller → Helpers: uses · Controllers rely on shared helper functions.
- MY_Controller → Auth: hosts · Authentication flows are handled by the auth controller.
- MY_Controller → User: hosts · User workflows are handled by the user controller.
- MY_Controller → Tickets: hosts · Ticket workflows are handled by the tickets controller.
- MY_Controller → Sms: hosts · SMS admin workflows are handled by the SMS controller.
- MY_Controller → API: hosts · API controllers expose integration endpoints.
- Auth → Identity: orchestrates · Login and access control delegate into identity models.
- User → Identity: orchestrates · Profile and account management use user identity data.
- Tickets → Ticketing: orchestrates · Ticket actions read and write ticket domain state.
- Tickets → Notifications: triggers · Ticket events can emit email or SMS notifications.
- Sms → SMS Models: orchestrates · SMS screens use SMS domain models.
- API → Ticketing: exposes · External endpoints can interact with ticket data.
- API → Identity: exposes · External endpoints can interact with user data.
- Notifications → Mustache: renders · Template rendering supports generated messages and email content.
- Identity → Storage: stores · Identity flows use document and attachment persistence.
- Ticketing → Storage: stores · Ticket attachments and related files are persisted through storage.
- Storage → MySQL DB: persists · Metadata and file references are stored in the database.
- Ticket UI → Assets: styled by · Ticket screens are driven by bundled frontend assets.
- Admin UI → Assets: styled by · Admin dashboards and reports depend on the frontend bundle.
- Auth UI → Assets: styled by · Authentication screens depend on the frontend bundle.
- User UI → Assets: styled by · User dashboards and profile screens depend on the frontend bundle.
- SMS UI → Assets: styled by · SMS management screens depend on the frontend bundle.
- Templates → Mustache: uses · Template services can use the bundled Mustache engine.
- Config → MySQL DB: configures · Database connection settings define the persistence backend.
