# ctrlpanel-gg/panel architecture

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

- Interactive diagram: https://gitdiagram.com/ctrlpanel-gg/panel
- Repository: https://github.com/ctrlpanel-gg/panel

## Overview

1. **Overall shape**
   - This is a single Laravel monolith, not a split frontend/backend system.
   - It serves a browser UI, a JSON API, background console jobs, and an installer flow from the same codebase.
   - The app is built around billing and account management for **Pterodactyl** only.

2. **Primary user surfaces**
   - The `themes/default/views` and `themes/BlueInfinity/views` trees show a themeable Blade-based UI for customers and admins.
   - Public-facing flows include store, profile, servers, tickets, notifications, terms, and authentication.
   - Admin flows live under `themes/default/views/admin` and are backed by `app/Http/Controllers/Admin`.

3. **Core domain model**
   - The main persisted entities are `User`, `Server`, `Product`, `Payment`, `Invoice`, `Coupon`, `Voucher`, `Ticket`, `Role`, `Permission`, `UsefulLink`, and `ApplicationApi`.
   - Pterodactyl-specific inventory is modeled separately as `Location`, `Node`, `Nest`, and `Egg`.
   - This domain split is important: billing and support live inside CtrlPanel, while server provisioning state is tracked through Pterodactyl-related models.

4. **Billing and commerce flow**
   - The store and checkout path is centered on products, credits, invoices, and payments.
   - The typical flow is: user buys or renews a product, payment is created, payment status changes, then invoices/credits/server actions are triggered.
   - `PaymentStatus`, `BillingPriority`, and the `Invoiceable` trait indicate that recurring billing and prioritization are first-class concerns.

5. **Payment gateway extension layer**
   - Payment methods are implemented as extensions under `app/Extensions/PaymentGateways` for Stripe, PayPal, Mollie, and MercadoPago.
   - The abstract extension classes and gateway-specific settings classes show a pluggable architecture rather than hardcoded payment logic.
   - Gateway routes and migrations are packaged with each gateway, so each provider owns its own configuration and persistence boundary.

6. **Server lifecycle and Pterodactyl integration**
   - `app/Classes/PterodactylClient.php` is the integration boundary to the external Pterodactyl panel API.
   - Provisioning, suspension, unsuspension, and related server lifecycle changes are coordinated through listeners and console commands.
   - The app’s server models and Pterodactyl inventory models suggest it stores enough local state to manage billing while delegating actual server control to Pterodactyl.

7. **Event-driven business actions**
   - Key events include `PaymentEvent`, `CouponUsedEvent`, and `UserUpdateCreditsEvent`.
   - Listeners like `CreateInvoice`, `UserPayment`, `UnsuspendServers`, and `Verified` convert state changes into follow-up actions.
   - This gives the app a clear internal pipeline: domain change first, then side effects such as invoices, credit updates, server changes, and notifications.

8. **Admin and API boundaries**
   - Admin controllers manage operational data: users, payments, products, roles, settings, tickets, vouchers, coupons, partners, and activity logs.
   - The `app/Http/Controllers/Api` namespace exposes a separate programmatic surface for notifications, roles, servers, users, and vouchers.
   - `ApiAuthToken` middleware indicates token-based access control for these machine clients.

9. **Authentication, authorization, and account state**
   - Standard auth controllers handle login, registration, password reset, email verification, and social login via Socialite.
   - Middleware such as `CheckSuspended`, `LastSeen`, `SetLocale`, `InstallerLock`, and `ApiAuthToken` gate behavior by account state, localization, installation state, and token validity.
   - Permissions are role-based and backed by dedicated permission tables plus constants for default and grouped permissions.

10. **Settings and runtime configuration**
   - The app uses typed settings classes under `app/Settings` for general, mail, Discord, locale, invoice, server, ticket, referral, terms, website, and Pterodactyl configuration.
   - The `database/settings` migrations show these settings are stored in the database and versioned separately from the main schema.
   - This makes runtime behavior highly configurable without changing code, which matters for diagrams: settings are a central control plane.

11. **Console and scheduled automation**
   - `app/Console/Commands` contains operational jobs like charging servers, cleaning up open payments, deleting expired coupons, disabling reCAPTCHA, importing users, and syncing versions/settings.
   - `app/Console/Kernel.php` ties those commands into the scheduler/CLI lifecycle.
   - These tasks are part of the billing engine’s background processing, not just maintenance scripts.

12. **Notifications and user communication**
   - Notifications are used for payment confirmation, invoices, referrals, server suspension/unsuspension, welcome messages, and ticket activity.
   - Mail and notification templates live in the theme layer, so the communication layer is integrated with presentation rather than separated into a service.
   - This is a key outbound boundary: state changes trigger email/in-app notifications as part of the same business flow.

13. **Installer and deployment packaging**
   - `public/installer` contains a self-hosted installation wizard that handles environment setup, database configuration, Redis, SMTP, timezone, and Pterodactyl connection details.
   - The repository also includes Docker targets for standalone and development use, which affects how the app is deployed and bootstrapped.
   - For an architecture diagram, the installer is a distinct entry path that initializes the same application code and database schema.

14. **Localization and theming**
   - Multiple translation packs exist under `lang/`, indicating the UI is multilingual.
   - The theme system is explicit, with both Blade templates and compiled assets under theme-specific directories.
   - UI skinning is therefore a presentation-layer concern, while business logic remains in the Laravel app and extension layer.

15. **External dependencies that materially shape the system**
   - Pterodactyl is the main external system.
   - Payment providers, mail services, reCAPTCHA/Turnstile, Discord, and social auth are also meaningful integrations.
   - The architecture is best understood as a billing/control plane around these services, with Pterodactyl as the primary operational backend.

Main entry points: [`app/Models`](https://github.com/ctrlpanel-gg/panel/tree/main/app/Models) (Billing core), [`app/Http/Controllers`](https://github.com/ctrlpanel-gg/panel/tree/main/app/Http/Controllers) (Web controllers), [`app/Listeners`](https://github.com/ctrlpanel-gg/panel/tree/main/app/Listeners) (Listeners), [`app/Settings`](https://github.com/ctrlpanel-gg/panel/tree/main/app/Settings) (Settings)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_presentation["Presentation"]
  node_themes_default["Default theme<br/>Blade UI"]
  node_themes_blueinfinity["BlueInfinity<br/>Alt theme"]
  node_public_installer["Installer<br/>Bootstrap wizard"]
end

subgraph group_application["Application"]
  node_web_controllers["Web controllers<br/>HTTP surface"]
  node_admin_controllers["Admin controllers<br/>Ops HTTP"]
  node_api_controllers["API controllers<br/>JSON API"]
  node_auth_middleware{{"Middleware gate<br/>HTTP middleware"}}
  node_domain_events(("Domain events<br/>Event bus"))
  node_domain_listeners(("Listeners<br/>Side effects"))
  node_console_jobs["Console jobs<br/>Scheduler CLI"]
  node_notifications["Notifications<br/>Outbound comms"]
end

subgraph group_domain["Domain"]
  node_settings_runtime[("Settings<br/>Runtime config")]
  node_billing_models[("Billing core<br/>Commerce models")]
  node_server_models[("Pterodactyl models<br/>Inventory models")]
  node_ticket_models[("Ticketing<br/>Support models")]
  node_persistence["Migrations<br/>Schema/history"]
end

subgraph group_integrations["Integrations"]
  node_payment_gateways["Gateways<br/>Extension layer"]
  node_pterodactyl_client["Pterodactyl client<br/>API boundary"]
end

node_themes_default -->|"renders"| node_web_controllers
node_themes_default -->|"templates"| node_notifications
node_themes_blueinfinity -->|"alternate UI"| node_web_controllers
node_public_installer -->|"boots config"| node_settings_runtime
node_public_installer -->|"creates schema"| node_persistence
node_web_controllers -->|"uses"| node_billing_models
node_web_controllers -->|"uses"| node_server_models
node_web_controllers -->|"uses"| node_ticket_models
node_admin_controllers -->|"administers"| node_billing_models
node_admin_controllers -->|"tunes"| node_settings_runtime
node_api_controllers -->|"exposes"| node_billing_models
node_auth_middleware -->|"guards"| node_web_controllers
node_auth_middleware -->|"guards"| node_api_controllers
node_domain_events -->|"triggers"| node_domain_listeners
node_domain_listeners -->|"updates"| node_billing_models
node_domain_listeners -->|"orchestrates"| node_server_models
node_console_jobs -->|"invokes"| node_domain_listeners
node_console_jobs -->|"calls"| node_pterodactyl_client
node_billing_models -->|"charges via"| node_payment_gateways
node_billing_models -->|"emits"| node_domain_events
node_server_models -->|"provisions via"| node_pterodactyl_client
node_settings_runtime -->|"configures"| node_payment_gateways
node_settings_runtime -->|"configures"| node_pterodactyl_client
node_domain_listeners -->|"sends"| node_notifications
node_persistence -->|"persists"| node_billing_models
node_persistence -->|"persists"| node_settings_runtime
node_payment_gateways -->|"owns schema"| node_persistence

click node_themes_default "https://github.com/ctrlpanel-gg/panel/tree/main/themes/default"
click node_themes_blueinfinity "https://github.com/ctrlpanel-gg/panel/tree/main/themes/BlueInfinity"
click node_public_installer "https://github.com/ctrlpanel-gg/panel/tree/main/public/installer"
click node_web_controllers "https://github.com/ctrlpanel-gg/panel/tree/main/app/Http/Controllers"
click node_admin_controllers "https://github.com/ctrlpanel-gg/panel/tree/main/app/Http/Controllers/Admin"
click node_api_controllers "https://github.com/ctrlpanel-gg/panel/tree/main/app/Http/Controllers/Api"
click node_auth_middleware "https://github.com/ctrlpanel-gg/panel/tree/main/app/Http/Middleware"
click node_domain_events "https://github.com/ctrlpanel-gg/panel/tree/main/app/Events"
click node_domain_listeners "https://github.com/ctrlpanel-gg/panel/tree/main/app/Listeners"
click node_console_jobs "https://github.com/ctrlpanel-gg/panel/tree/main/app/Console/Commands"
click node_settings_runtime "https://github.com/ctrlpanel-gg/panel/tree/main/app/Settings"
click node_billing_models "https://github.com/ctrlpanel-gg/panel/tree/main/app/Models"
click node_server_models "https://github.com/ctrlpanel-gg/panel/tree/main/app/Models/Pterodactyl"
click node_ticket_models "https://github.com/ctrlpanel-gg/panel/tree/main/app/Models"
click node_payment_gateways "https://github.com/ctrlpanel-gg/panel/tree/main/app/Extensions/PaymentGateways"
click node_pterodactyl_client "https://github.com/ctrlpanel-gg/panel/blob/main/app/Classes/PterodactylClient.php"
click node_notifications "https://github.com/ctrlpanel-gg/panel/tree/main/app/Notifications"
click node_persistence "https://github.com/ctrlpanel-gg/panel/tree/main/database/migrations"

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_themes_default,node_themes_blueinfinity,node_public_installer toneBlue
class node_web_controllers,node_admin_controllers,node_api_controllers,node_auth_middleware,node_domain_events,node_domain_listeners,node_console_jobs,node_notifications toneAmber
class node_settings_runtime,node_billing_models,node_server_models,node_ticket_models,node_persistence toneMint
class node_payment_gateways,node_pterodactyl_client toneRose
```

## Components

### Presentation

Blade themes, assets, and browser-facing UI.

- [Default theme](https://github.com/ctrlpanel-gg/panel/tree/main/themes/default): Blade UI · Primary customer and admin presentation layer with shared layouts, forms, mail, and notifications. · `themes/default`
- [BlueInfinity](https://github.com/ctrlpanel-gg/panel/tree/main/themes/BlueInfinity): Alt theme · Secondary theme package used for alternate layouts and styling. · `themes/BlueInfinity`
- [Installer](https://github.com/ctrlpanel-gg/panel/tree/main/public/installer): Bootstrap wizard · Standalone installation flow for environment, database, Redis, SMTP, timezone, and Pterodactyl setup. · `public/installer`

### Application

HTTP controllers, middleware, events, listeners, and console orchestration.

- [Web controllers](https://github.com/ctrlpanel-gg/panel/tree/main/app/Http/Controllers): HTTP surface · Browser-facing controllers for home, store, profile, servers, tickets, notifications, terms, and preferences. · `app/Http/Controllers`
- [Admin controllers](https://github.com/ctrlpanel-gg/panel/tree/main/app/Http/Controllers/Admin): Ops HTTP · Administrative control surface for users, products, payments, coupons, vouchers, roles, tickets, settings, and logs. · `app/Http/Controllers/Admin`
- [API controllers](https://github.com/ctrlpanel-gg/panel/tree/main/app/Http/Controllers/Api): JSON API · Token-protected programmatic surface for notifications, roles, servers, users, and vouchers. · `app/Http/Controllers/Api`
- [Middleware gate](https://github.com/ctrlpanel-gg/panel/tree/main/app/Http/Middleware): HTTP middleware · Request guards for suspension, locale, installer lock, auth, and API token validation. · `app/Http/Middleware`
- [Domain events](https://github.com/ctrlpanel-gg/panel/tree/main/app/Events): Event bus · Business-state events such as payment changes, coupon use, credit updates, and verification. · `app/Events`
- [Listeners](https://github.com/ctrlpanel-gg/panel/tree/main/app/Listeners): Side effects · Follow-up actions for invoices, payment handling, server unsuspension, coupon use, and verification. · `app/Listeners`
- [Console jobs](https://github.com/ctrlpanel-gg/panel/tree/main/app/Console/Commands): Scheduler CLI · Recurring operational commands for charging servers, cleanup, sync, imports, and maintenance tasks. · `app/Console/Commands`
- [Notifications](https://github.com/ctrlpanel-gg/panel/tree/main/app/Notifications): Outbound comms · Email and in-app notifications for payments, invoices, referrals, server lifecycle, and tickets. · `app/Notifications`

### Domain

Core billing, support, account, and Pterodactyl models.

- [Settings](https://github.com/ctrlpanel-gg/panel/tree/main/app/Settings): Runtime config · Typed database-backed configuration for billing, mail, locale, Discord, tickets, referrals, terms, and Pterodactyl. · `app/Settings`
- [Billing core](https://github.com/ctrlpanel-gg/panel/tree/main/app/Models): Commerce models · Users, products, payments, invoices, coupons, vouchers, roles, permissions, and shop entities. · `app/Models`
- [Pterodactyl models](https://github.com/ctrlpanel-gg/panel/tree/main/app/Models/Pterodactyl): Inventory models · Local model set for servers and Pterodactyl inventory: locations, nodes, nests, and eggs. · `app/Models/Pterodactyl`
- [Ticketing](https://github.com/ctrlpanel-gg/panel/tree/main/app/Models): Support models · Ticket, category, blacklist, and comment records for support workflows. · `app/Models`
- [Migrations](https://github.com/ctrlpanel-gg/panel/tree/main/database/migrations): Schema/history · Database schema, settings migrations, and seeders that define persisted state and defaults. · `database/migrations`

### Integrations

External services and extension boundaries.

- [Gateways](https://github.com/ctrlpanel-gg/panel/tree/main/app/Extensions/PaymentGateways): Extension layer · Pluggable payment gateway implementations with provider-owned routes, settings, and migrations. · `app/Extensions/PaymentGateways`
- [Pterodactyl client](https://github.com/ctrlpanel-gg/panel/blob/main/app/Classes/PterodactylClient.php): API boundary · Integration boundary to the external Pterodactyl panel API for provisioning and lifecycle control. · `app/Classes/PterodactylClient.php`

## Connections

- Default theme → Web controllers: renders · Blade views are driven by browser controllers.
- Default theme → Notifications: templates · Mail and notification templates live in the theme layer.
- BlueInfinity → Web controllers: alternate UI · Alternative presentation skin for the same application flows.
- Installer → Settings: boots config · Installer initializes runtime configuration and environment.
- Installer → Migrations: creates schema · Installer performs database setup and migrations.
- Web controllers → Billing core: uses · Store, profile, and server flows operate on core billing entities.
- Web controllers → Pterodactyl models: uses · Server pages and actions depend on provisioning inventory state.
- Web controllers → Ticketing: uses · Ticketing pages manage support records.
- Admin controllers → Billing core: administers · Operational CRUD and oversight for commerce and account data.
- Admin controllers → Settings: tunes · Admin settings controller edits runtime configuration.
- API controllers → Billing core: exposes · Programmatic access to users, roles, servers, and vouchers.
- Middleware gate → Web controllers: guards · Applies auth, locale, suspension, and installer access rules.
- Middleware gate → API controllers: guards · Validates API tokens and account state for machine clients.
- Domain events → Listeners: triggers · State changes fan out into business side effects.
- Listeners → Billing core: updates · Listeners create invoices, apply payments, and adjust credits.
- Listeners → Pterodactyl models: orchestrates · Listeners suspend, unsuspend, and otherwise coordinate server lifecycle.
- Console jobs → Listeners: invokes · Scheduled commands drive billing and operational side effects.
- Console jobs → Pterodactyl client: calls · Background commands may sync or act against Pterodactyl.
- Billing core → Gateways: charges via · Payments are processed through pluggable gateway extensions.
- Billing core → Domain events: emits · Billing and account changes publish business events.
- Pterodactyl models → Pterodactyl client: provisions via · Local server state is reconciled with the external panel API.
- Settings → Gateways: configures · Gateway and provider settings are stored as typed configuration.
- Settings → Pterodactyl client: configures · Pterodactyl connection details come from runtime settings.
- Listeners → Notifications: sends · User-facing communication is part of business side effects.
- Migrations → Billing core: persists · Schema defines the core commerce and account tables.
- Migrations → Settings: persists · Database settings migrations store runtime configuration.
- Gateways → Migrations: owns schema · Each payment extension brings its own migration boundary.
