How ctrlpanel-gg/panel works
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: Models Billing core · Controllers Web controllers · Listeners Listeners · Settings Settings
Components 18
Presentation
Blade themes, assets, and browser-facing UI.
- Default theme · Primary customer and admin presentation layer with shared layouts, forms, mail, and notifications.
themes/default - BlueInfinity · Secondary theme package used for alternate layouts and styling.
themes/BlueInfinity - Installer · 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 · Browser-facing controllers for home, store, profile, servers, tickets, notifications, terms, and preferences.
app/Http/Controllers - Admin controllers · Administrative control surface for users, products, payments, coupons, vouchers, roles, tickets, settings, and logs.
app/Http/Controllers/Admin - API controllers · Token-protected programmatic surface for notifications, roles, servers, users, and vouchers.
app/Http/Controllers/Api - Middleware gate · Request guards for suspension, locale, installer lock, auth, and API token validation.
app/Http/Middleware - Domain events · Business-state events such as payment changes, coupon use, credit updates, and verification.
app/Events - Listeners · Follow-up actions for invoices, payment handling, server unsuspension, coupon use, and verification.
app/Listeners - Console jobs · Recurring operational commands for charging servers, cleanup, sync, imports, and maintenance tasks.
app/Console/Commands - Notifications · Email and in-app notifications for payments, invoices, referrals, server lifecycle, and tickets.
app/Notifications
Domain
Core billing, support, account, and Pterodactyl models.
- Settings · Typed database-backed configuration for billing, mail, locale, Discord, tickets, referrals, terms, and Pterodactyl.
app/Settings - Billing core · Users, products, payments, invoices, coupons, vouchers, roles, permissions, and shop entities.
app/Models - Pterodactyl models · Local model set for servers and Pterodactyl inventory: locations, nodes, nests, and eggs.
app/Models/Pterodactyl - Ticketing · Ticket, category, blacklist, and comment records for support workflows.
app/Models - Migrations · Database schema, settings migrations, and seeders that define persisted state and defaults.
database/migrations
Integrations
External services and extension boundaries.
- Gateways · Pluggable payment gateway implementations with provider-owned routes, settings, and migrations.
app/Extensions/PaymentGateways - Pterodactyl client · Integration boundary to the external Pterodactyl panel API for provisioning and lifecycle control.
app/Classes/PterodactylClient.php
Connections 27
- 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.