# ISP360 Project Structure

**Version:** 1.0  
**Date:** 2026-06-13  
**Prepared by:** Polakis Technologies  
**Total files:** 564+

---

## Architecture Summary

| Layer | Location | Count |
|-------|----------|-------|
| Root UI pages | `/` (project root) | 164 |
| AJAX endpoints | `/ajax/` | 265 |
| Core includes | `/includes/` | 32 |
| Layouts | `/layouts/` | 13 |
| REST API | `/api/v1/` | 41 |
| Cron jobs | `/cron/` | 20 |
| Install wizard | `/install/` | 7 |
| Captive templates | `/templates/` | 15 |
| Backup scripts | `/backups/` | 4 |
| Frontend assets | `/assets/` | retained |
| Vendor libs | `/vendor/` | retained |

## Naming Conventions

| Prefix | Audience | Example |
|--------|----------|---------|
| *(none)* | ISP staff / admin | `customers.php`, `routers.php` |
| `portal_` | Customer portal | `portal_login.php` |
| `report_` | Reports | `report_revenue.php` |
| `settings_` | Configuration | `settings_payments.php` |

## Standard Page Include Pattern

```php
require_once('includes/config.php');
require_once('includes/auth.php');
require_once('layouts/session.php');
```

---

## Root UI Pages


### Auth

| File | Purpose | Permission | Layout | AJAX | Tables | Roles |
|------|---------|------------|--------|------|--------|-------|
| `change_password.php` | Change password form | `authenticated` | `main` | `ajax/change_password.php` | `users` | ISP Admin, Support, Finance, Technician |
| `forgot_password.php` | Password recovery request | `public` | `auth` | `ajax/send_password_reset.php` | `password_reset_tokens` | ISP Admin, Support, Finance, Technician |
| `index.php` | Landing redirect to login or dashboard | `public` | `main` | — | — | ISP Admin, Support, Finance, Technician |
| `login.php` | Staff login form | `public` | `auth` | `ajax/login_attempt.php` | `users`, `login_history` | ISP Admin, Support, Finance, Technician |
| `login_process.php` | Staff login handler | `public` | `main` | — | `users`, `sessions`, `login_history` | ISP Admin, Support, Finance, Technician |
| `logout.php` | Session termination | `authenticated` | `main` | — | `sessions` | ISP Admin, Support, Finance, Technician |
| `profile.php` | User profile view/edit | `authenticated` | `main` | `ajax/save_profile.php`, `ajax/change_password.php` | `users`, `user_preferences` | ISP Admin, Support, Finance, Technician |
| `reset_password.php` | Password reset handler | `public` | `main` | — | `password_reset_tokens`, `users` | ISP Admin, Support, Finance, Technician |
| `reset_password_page.php` | Password reset form | `public` | `auth` | — | `password_reset_tokens` | ISP Admin, Support, Finance, Technician |

### Billing

| File | Purpose | Permission | Layout | AJAX | Tables | Roles |
|------|---------|------------|--------|------|--------|-------|
| `billing.php` | Billing overview | `billing.view` | `main` | `ajax/billing_summary.php` | `invoices`, `payments` | ISP Admin, Finance |
| `billing_cycles.php` | Billing cycles | `billing.edit` | `main` | `ajax/save_billing_cycle.php` | `billing_cycles` | ISP Admin, Finance |
| `credit_notes.php` | Credit notes | `billing.view` | `main` | `ajax/save_credit_note.php` | `credit_notes` | ISP Admin, Finance |
| `debit_notes.php` | Debit notes | `billing.view` | `main` | `ajax/save_debit_note.php` | `debit_notes` | ISP Admin, Finance |
| `dunning.php` | Dunning rules | `billing.edit` | `main` | `ajax/save_dunning_rule.php` | `dunning_rules`, `dunning_log` | ISP Admin, Finance |
| `invoice_edit.php` | Create/edit invoice | `billing.create|billing.edit` | `main` | `ajax/save_invoice.php`, `ajax/add_invoice_item.php`, `ajax/remove_invoice_item.php` | `invoices`, `invoice_items` | ISP Admin, Finance |
| `invoice_view.php` | Invoice detail/PDF | `billing.view` | `main` | `ajax/generate_invoice_pdf.php` | `invoices`, `invoice_items` | ISP Admin, Finance |
| `invoices.php` | Invoice list | `billing.view` | `main` | `ajax/get_invoices.php`, `ajax/send_invoice.php` | `invoices` | ISP Admin, Finance |
| `payment_allocate.php` | Allocate payment | `payments.create` | `main` | `ajax/allocate_payment.php` | `payments`, `payment_allocations`, `invoices` | ISP Admin, Finance |
| `payment_plans.php` | Payment plans | `payments.view` | `main` | `ajax/save_payment_plan.php` | `payment_plans`, `payment_plan_installments` | ISP Admin, Finance |
| `payment_view.php` | Payment detail | `payments.view` | `main` | `ajax/get_payment_details.php` | `payments`, `payment_allocations` | ISP Admin, Finance |
| `payments.php` | Payment list | `payments.view` | `main` | `ajax/get_payments.php`, `ajax/record_payment.php` | `payments` | ISP Admin, Finance |

### Captive Portal

| File | Purpose | Permission | Layout | AJAX | Tables | Roles |
|------|---------|------------|--------|------|--------|-------|
| `captive_portal_edit.php` | Portal builder | `hotspot.edit` | `main` | `ajax/save_captive_portal.php`, `ajax/preview_captive_portal.php` | `captive_portal_templates`, `captive_portal_themes`, `captive_portal_pages` | ISP Admin, Support, Finance, Technician |
| `captive_portal_preview.php` | Live preview | `hotspot.view` | `main` | `ajax/render_captive_preview.php` | `captive_portal_templates` | ISP Admin, Support, Finance, Technician |
| `captive_portal_themes.php` | Theme editor | `hotspot.edit` | `main` | `ajax/save_captive_theme.php` | `captive_portal_themes`, `captive_portal_assets` | ISP Admin, Support, Finance, Technician |
| `captive_portals.php` | Portal list | `hotspot.edit` | `main` | `ajax/get_captive_portals.php` | `captive_portal_templates` | ISP Admin, Support, Finance, Technician |

### Customer Portal

| File | Purpose | Permission | Layout | AJAX | Tables | Roles |
|------|---------|------------|--------|------|--------|-------|
| `portal_dashboard.php` | Customer dashboard | `portal_auth` | `portal` | `ajax/portal_dashboard_data.php` | `customer_subscriptions`, `usage_aggregates_daily` | Customer |
| `portal_invoice_view.php` | Invoice detail | `portal_auth` | `portal` | `ajax/portal_download_invoice.php` | `invoices`, `invoice_items` | Customer |
| `portal_invoices.php` | My invoices | `portal_auth` | `portal` | `ajax/portal_get_invoices.php` | `invoices` | Customer |
| `portal_login.php` | Customer login | `public` | `portal` | `ajax/portal_login.php` | `customers`, `portal_sessions` | Customer |
| `portal_logout.php` | Portal logout | `portal_auth` | `portal` | — | `portal_sessions` | Customer |
| `portal_packages.php` | Browse packages | `portal_auth` | `portal` | `ajax/portal_get_packages.php` | `packages`, `package_pricing` | Customer |
| `portal_password.php` | Change password | `portal_auth` | `portal` | `ajax/portal_change_password.php` | `users` | Customer |
| `portal_pay.php` | Make payment | `portal_auth` | `portal` | `ajax/portal_initiate_payment.php` | `payments`, `mpesa_transactions` | Customer |
| `portal_payments.php` | Payment history | `portal_auth` | `portal` | `ajax/portal_get_payments.php` | `payments` | Customer |
| `portal_profile.php` | My profile | `portal_auth` | `portal` | `ajax/portal_save_profile.php` | `customers`, `customer_addresses` | Customer |
| `portal_purchase.php` | Purchase package | `portal_auth` | `portal` | `ajax/portal_purchase_package.php`, `ajax/portal_stk_push.php` | `customer_subscriptions`, `invoices`, `mpesa_transactions` | Customer |
| `portal_register.php` | Self registration | `public` | `portal` | `ajax/portal_register.php` | `customers` | Customer |
| `portal_ticket_view.php` | Ticket detail | `portal_auth` | `portal` | `ajax/portal_reply_ticket.php` | `ticket_messages` | Customer |
| `portal_tickets.php` | Support tickets | `portal_auth` | `portal` | `ajax/portal_get_tickets.php`, `ajax/portal_create_ticket.php` | `tickets` | Customer |
| `portal_usage.php` | Usage monitor | `portal_auth` | `portal` | `ajax/portal_usage_data.php` | `usage_aggregates_daily`, `pppoe_sessions` | Customer |
| `portal_voucher.php` | Redeem voucher | `portal_auth` | `portal` | `ajax/portal_redeem_voucher.php` | `vouchers`, `voucher_usage` | Customer |

### Customers

| File | Purpose | Permission | Layout | AJAX | Tables | Roles |
|------|---------|------------|--------|------|--------|-------|
| `customer_devices.php` | Device registry | `customers.view` | `main` | `ajax/save_customer_device.php` | `customer_devices` | ISP Admin, Support, Finance, Technician |
| `customer_documents.php` | Document management | `customers.edit` | `main` | `ajax/upload_customer_document.php`, `ajax/delete_customer_document.php` | `customer_documents` | ISP Admin, Support, Finance, Technician |
| `customer_edit.php` | Create/edit customer | `customers.create|customers.edit` | `main` | `ajax/save_customer.php`, `ajax/check_customer_phone.php`, `ajax/check_customer_email.php` | `customers`, `customer_addresses`, `customer_contacts` | ISP Admin, Support, Finance, Technician |
| `customer_groups.php` | Customer groups | `customers.view` | `main` | `ajax/get_customer_groups.php`, `ajax/save_customer_group.php` | `customer_groups` | ISP Admin, Support, Finance, Technician |
| `customer_import.php` | Bulk import | `customers.create` | `main` | `ajax/upload_customer_import.php`, `ajax/process_customer_import.php` | `customer_import_batches`, `customer_import_rows` | ISP Admin, Support, Finance, Technician |
| `customer_kyc.php` | KYC verification | `customers.edit` | `main` | `ajax/verify_customer_kyc.php` | `customer_kyc` | ISP Admin, Support, Finance, Technician |
| `customer_notes.php` | Customer notes | `customers.view` | `main` | `ajax/save_customer_note.php` | `customer_notes` | ISP Admin, Support, Finance, Technician |
| `customer_subscriptions.php` | Subscription management | `customers.edit` | `main` | `ajax/save_customer_subscription.php`, `ajax/suspend_subscription.php` | `customer_subscriptions`, `packages` | ISP Admin, Support, Finance, Technician |
| `customer_view.php` | Customer 360 view | `customers.view` | `main` | `ajax/get_customer_details.php`, `ajax/get_customer_subscriptions.php` | `customers`, `customer_subscriptions`, `invoices` +1 | ISP Admin, Support, Finance, Technician |
| `customers.php` | Customer list | `customers.view` | `main` | `ajax/get_customers.php`, `ajax/search_customers.php`, `ajax/export_customers.php` | `customers` | ISP Admin, Support, Finance, Technician |

### Dashboard

| File | Purpose | Permission | Layout | AJAX | Tables | Roles |
|------|---------|------------|--------|------|--------|-------|
| `dashboard.php` | Main KPI dashboard | `authenticated` | `main` | `ajax/dashboard_metrics.php`, `ajax/dashboard_charts.php` | `vw_tenant_dashboard_metrics`, `dashboard_metrics` | All staff |

### FreeRADIUS

| File | Purpose | Permission | Layout | AJAX | Tables | Roles |
|------|---------|------------|--------|------|--------|-------|
| `nas_devices.php` | NAS devices | `routers.view` | `main` | `ajax/save_nas.php` | `nas` | ISP Admin, Technician |
| `radius_accounting.php` | Accounting viewer | `pppoe.view` | `main` | `ajax/get_radacct.php` | `radacct`, `radius_accounting_summary` | ISP Admin, Technician |
| `radius_groups.php` | RADIUS groups | `pppoe.view` | `main` | `ajax/save_radius_group.php` | `radgroupcheck`, `radgroupreply` | ISP Admin, Technician |
| `radius_profiles.php` | RADIUS profiles | `pppoe.view` | `main` | `ajax/get_radius_profiles.php`, `ajax/save_radius_profile.php` | `radius_profiles`, `radius_profile_attributes` | ISP Admin, Technician |
| `radius_sync.php` | Sync status | `routers.view` | `main` | `ajax/sync_radius.php`, `ajax/get_radius_sync_log.php` | `radius_sync_log`, `radcheck` | ISP Admin, Technician |

### Hotspot

| File | Purpose | Permission | Layout | AJAX | Tables | Roles |
|------|---------|------------|--------|------|--------|-------|
| `hotspot_edit.php` | Edit hotspot | `hotspot.create|hotspot.edit` | `main` | `ajax/save_hotspot.php` | `hotspots`, `hotspot_profiles` | ISP Admin, Support, Finance, Technician |
| `hotspot_mac_auth.php` | MAC auth | `hotspot.edit` | `main` | `ajax/save_hotspot_mac.php` | `hotspot_mac_auth`, `mac_auth_devices` | ISP Admin, Support, Finance, Technician |
| `hotspot_portals.php` | Portal config | `hotspot.edit` | `main` | `ajax/save_hotspot_portal.php` | `hotspot_portals`, `hotspot_portal_templates` | ISP Admin, Support, Finance, Technician |
| `hotspot_profiles.php` | Profiles | `hotspot.edit` | `main` | `ajax/save_hotspot_profile.php` | `hotspot_profiles`, `hotspot_profile_packages` | ISP Admin, Support, Finance, Technician |
| `hotspot_sessions.php` | Active sessions | `hotspot.view` | `main` | `ajax/get_hotspot_sessions.php`, `ajax/disconnect_hotspot_session.php` | `hotspot_sessions` | ISP Admin, Support, Finance, Technician |
| `hotspot_usage.php` | Usage reports | `hotspot.view` | `main` | `ajax/get_hotspot_usage.php` | `hotspot_usage` | ISP Admin, Support, Finance, Technician |
| `hotspot_users.php` | Hotspot users | `hotspot.users` | `main` | `ajax/save_hotspot_user.php`, `ajax/suspend_hotspot_user.php` | `hotspot_users` | ISP Admin, Support, Finance, Technician |
| `hotspot_walled_garden.php` | Walled garden | `hotspot.edit` | `main` | `ajax/save_walled_garden.php` | `hotspot_walled_garden` | ISP Admin, Support, Finance, Technician |
| `hotspots.php` | Hotspot list | `hotspot.view` | `main` | `ajax/get_hotspots.php` | `hotspots` | ISP Admin, Support, Finance, Technician |

### Mobile Money

| File | Purpose | Permission | Layout | AJAX | Tables | Roles |
|------|---------|------------|--------|------|--------|-------|
| `airtel_transactions.php` | Airtel Money log | `payments.view` | `main` | `ajax/get_airtel_transactions.php` | `airtel_transactions` | ISP Admin, Finance |
| `momo_transactions.php` | MTN MoMo log | `payments.view` | `main` | `ajax/get_momo_transactions.php` | `momo_transactions` | ISP Admin, Finance |
| `mpesa_transactions.php` | M-Pesa log | `payments.view` | `main` | `ajax/get_mpesa_transactions.php` | `mpesa_transactions` | ISP Admin, Finance |
| `payment_callbacks.php` | Callback log | `payments.view` | `main` | `ajax/get_payment_callbacks.php` | `payment_callbacks` | ISP Admin, Finance |
| `payment_disbursements.php` | Disbursements | `payments.create` | `main` | `ajax/initiate_disbursement.php` | `payment_disbursements` | ISP Admin, Finance |
| `payment_reconciliation.php` | Reconciliation | `payments.reconcile` | `main` | `ajax/run_reconciliation.php`, `ajax/match_payment.php` | `payment_reconciliation`, `payment_reconciliation_items` | ISP Admin, Finance |
| `payment_refunds.php` | Refunds | `payments.refund` | `main` | `ajax/process_refund.php` | `payment_refunds` | ISP Admin, Finance |

### Notifications

| File | Purpose | Permission | Layout | AJAX | Tables | Roles |
|------|---------|------------|--------|------|--------|-------|
| `email_logs.php` | Email log | `settings.view` | `main` | `ajax/get_email_logs.php`, `ajax/send_email.php` | `email_logs` | ISP Admin, Support, Finance, Technician |
| `notification_rules.php` | Automation rules | `settings.edit` | `main` | `ajax/save_notification_rule.php` | `notification_rules` | ISP Admin, Support, Finance, Technician |
| `notification_templates.php` | Templates | `settings.edit` | `main` | `ajax/save_notification_template.php` | `notification_templates` | ISP Admin, Support, Finance, Technician |
| `notifications.php` | Notification center | `settings.view` | `main` | `ajax/get_notification_queue.php` | `notification_queue` | ISP Admin, Support, Finance, Technician |
| `sms_logs.php` | SMS log | `settings.view` | `main` | `ajax/get_sms_logs.php`, `ajax/send_sms.php` | `sms_logs` | ISP Admin, Support, Finance, Technician |

### PPPoE

| File | Purpose | Permission | Layout | AJAX | Tables | Roles |
|------|---------|------------|--------|------|--------|-------|
| `fibre_connections.php` | Fibre connections | `pppoe.view` | `main` | `ajax/save_fibre_connection.php` | `fibre_connections` | ISP Admin, Support, Finance, Technician |
| `pppoe_account_edit.php` | Edit account | `pppoe.create|pppoe.edit` | `main` | `ajax/save_pppoe_account.php`, `ajax/suspend_pppoe_account.php` | `pppoe_accounts`, `radcheck` | ISP Admin, Support, Finance, Technician |
| `pppoe_accounts.php` | PPPoE accounts | `pppoe.view` | `main` | `ajax/get_pppoe_accounts.php`, `ajax/save_pppoe_account.php` | `pppoe_accounts` | ISP Admin, Support, Finance, Technician |
| `pppoe_ip_pools.php` | IP pools | `pppoe.edit` | `main` | `ajax/save_pppoe_pool.php` | `pppoe_ip_pools`, `pppoe_pool_assignments` | ISP Admin, Support, Finance, Technician |
| `pppoe_profiles.php` | PPPoE profiles | `pppoe.view` | `main` | `ajax/save_pppoe_profile.php` | `pppoe_profiles`, `pppoe_profile_packages` | ISP Admin, Support, Finance, Technician |
| `pppoe_sessions.php` | Active sessions | `pppoe.view` | `main` | `ajax/get_pppoe_sessions.php`, `ajax/disconnect_pppoe_session.php` | `pppoe_sessions` | ISP Admin, Support, Finance, Technician |
| `pppoe_static_ips.php` | Static IPs | `pppoe.edit` | `main` | `ajax/assign_static_ip.php` | `pppoe_static_ips`, `ip_address_reservations` | ISP Admin, Support, Finance, Technician |

### Packages

| File | Purpose | Permission | Layout | AJAX | Tables | Roles |
|------|---------|------------|--------|------|--------|-------|
| `package_edit.php` | Create/edit package | `packages.create|packages.edit` | `main` | `ajax/save_package.php`, `ajax/save_package_limits.php`, `ajax/save_package_pricing.php` | `packages`, `package_limits`, `package_pricing` +1 | ISP Admin, Support, Finance, Technician |
| `package_groups.php` | Package groups | `packages.view` | `main` | `ajax/save_package_group.php` | `package_groups` | ISP Admin, Support, Finance, Technician |
| `package_promotions.php` | Promotions | `packages.edit` | `main` | `ajax/save_promotion.php` | `package_promotions` | ISP Admin, Support, Finance, Technician |
| `package_view.php` | Package detail | `packages.view` | `main` | `ajax/get_package_details.php` | `packages`, `package_features` | ISP Admin, Support, Finance, Technician |
| `packages.php` | Package list | `packages.view` | `main` | `ajax/get_packages.php`, `ajax/delete_package.php` | `packages` | ISP Admin, Support, Finance, Technician |

### Reports

| File | Purpose | Permission | Layout | AJAX | Tables | Roles |
|------|---------|------------|--------|------|--------|-------|
| `report_aging.php` | AR aging | `reports.view` | `main` | `ajax/report_aging_data.php` | `invoices`, `vw_customer_balances` | ISP Admin, Finance |
| `report_builder.php` | Custom report builder | `reports.export` | `main` | `ajax/save_report_definition.php` | `report_definitions` | ISP Admin, Finance |
| `report_collections.php` | Collections report | `reports.view` | `main` | `ajax/report_collections_data.php` | `payments`, `payment_allocations` | ISP Admin, Finance |
| `report_customers.php` | Customer report | `reports.view` | `main` | `ajax/report_customers_data.php` | `customer_metrics_daily` | ISP Admin, Finance |
| `report_hotspot.php` | Hotspot report | `reports.view` | `main` | `ajax/report_hotspot_data.php` | `hotspot_sessions`, `hotspot_usage` | ISP Admin, Finance |
| `report_network.php` | Network report | `reports.view` | `main` | `ajax/report_network_data.php` | `network_metrics_hourly` | ISP Admin, Finance |
| `report_pppoe.php` | PPPoE report | `reports.view` | `main` | `ajax/report_pppoe_data.php` | `pppoe_sessions`, `radacct` | ISP Admin, Finance |
| `report_revenue.php` | Revenue report | `reports.view` | `main` | `ajax/report_revenue_data.php`, `ajax/export_report.php` | `vw_revenue_by_period`, `revenue_aggregates_daily` | ISP Admin, Finance |
| `report_routers.php` | Router report | `reports.view` | `main` | `ajax/report_routers_data.php` | `vw_router_health`, `router_metrics` | ISP Admin, Finance |
| `report_schedules.php` | Scheduled reports | `reports.export` | `main` | `ajax/save_report_schedule.php` | `report_schedules` | ISP Admin, Finance |
| `report_subscriptions.php` | Subscription report | `reports.view` | `main` | `ajax/report_subscriptions_data.php` | `customer_subscriptions` | ISP Admin, Finance |
| `report_tax.php` | Tax report | `reports.view` | `main` | `ajax/report_tax_data.php` | `invoices`, `tax_rates` | ISP Admin, Finance |
| `report_tickets.php` | Ticket report | `reports.view` | `main` | `ajax/report_tickets_data.php` | `tickets` | ISP Admin, Finance |
| `report_usage.php` | Usage report | `reports.view` | `main` | `ajax/report_usage_data.php` | `usage_aggregates_daily`, `usage_aggregates_monthly` | ISP Admin, Finance |
| `report_vouchers.php` | Voucher report | `reports.view` | `main` | `ajax/report_vouchers_data.php` | `vw_voucher_inventory` | ISP Admin, Finance |

### Routers

| File | Purpose | Permission | Layout | AJAX | Tables | Roles |
|------|---------|------------|--------|------|--------|-------|
| `bandwidth_profiles.php` | Bandwidth profiles | `routers.edit` | `main` | `ajax/save_bandwidth_profile.php` | `bandwidth_profiles` | ISP Admin, Technician |
| `router_alerts.php` | Alerts | `routers.view` | `main` | `ajax/acknowledge_router_alert.php` | `router_alerts` | ISP Admin, Technician |
| `router_backup.php` | Backup management | `routers.backup` | `main` | `ajax/create_router_backup.php`, `ajax/restore_router_backup.php`, `ajax/download_router_backup.php` | `router_backups` | ISP Admin, Technician |
| `router_commands.php` | Command queue | `routers.command` | `main` | `ajax/queue_router_command.php`, `ajax/get_router_commands.php` | `router_commands` | ISP Admin, Technician |
| `router_discovery.php` | Network discovery | `routers.create` | `main` | `ajax/run_router_discovery.php` | `router_discovery` | ISP Admin, Technician |
| `router_edit.php` | Add/edit router | `routers.create|routers.edit` | `main` | `ajax/save_router.php`, `ajax/test_router_connection.php`, `ajax/discover_router.php` | `routers`, `router_credentials`, `nas` | ISP Admin, Technician |
| `router_firewall.php` | Firewall rules | `routers.edit` | `main` | `ajax/save_firewall_rule.php` | `router_firewall_rules` | ISP Admin, Technician |
| `router_groups.php` | Router groups | `routers.view` | `main` | `ajax/save_router_group.php` | `router_groups`, `router_group_members` | ISP Admin, Technician |
| `router_metrics.php` | Metrics charts | `routers.view` | `main` | `ajax/get_router_metrics.php` | `router_metrics`, `network_metrics_hourly` | ISP Admin, Technician |
| `router_queues.php` | Queue trees | `routers.edit` | `main` | `ajax/save_router_queue.php`, `ajax/apply_queue_template.php` | `router_queues`, `queue_tree_templates` | ISP Admin, Technician |
| `router_schedules.php` | Schedules | `routers.edit` | `main` | `ajax/save_router_schedule.php` | `router_schedules` | ISP Admin, Technician |
| `router_scripts.php` | Scripts | `routers.edit` | `main` | `ajax/save_router_script.php`, `ajax/run_router_script.php` | `router_scripts` | ISP Admin, Technician |
| `router_view.php` | Router detail | `routers.view` | `main` | `ajax/get_router_details.php`, `ajax/get_router_status.php` | `routers`, `router_status`, `router_interfaces` | ISP Admin, Technician |
| `routers.php` | Router list | `routers.view` | `main` | `ajax/get_routers.php`, `ajax/delete_router.php` | `routers` | ISP Admin, Technician |
| `service_locations.php` | POP/locations | `routers.view` | `main` | `ajax/save_service_location.php` | `service_locations` | ISP Admin, Technician |

### Settings

| File | Purpose | Permission | Layout | AJAX | Tables | Roles |
|------|---------|------------|--------|------|--------|-------|
| `settings_api.php` | API settings | `settings.edit` | `main` | `ajax/save_api_settings.php` | `tenant_api_keys`, `api_tokens` | ISP Admin, Support, Finance, Technician |
| `settings_billing.php` | Billing settings | `settings.edit` | `main` | `ajax/save_billing_settings.php` | `tax_rates`, `invoice_sequences`, `billing_cycles` | ISP Admin, Support, Finance, Technician |
| `settings_branding.php` | White-label branding | `settings.edit` | `main` | `ajax/save_tenant_theme.php` | `tenant_themes` | ISP Admin, Support, Finance, Technician |
| `settings_general.php` | General settings | `settings.view` | `main` | `ajax/save_tenant_settings.php` | `tenant_settings` | ISP Admin, Support, Finance, Technician |
| `settings_localization.php` | Locale/currency | `settings.edit` | `main` | `ajax/save_localization.php` | `tenants`, `currencies`, `timezones` | ISP Admin, Support, Finance, Technician |
| `settings_modules.php` | Module settings | `settings.edit` | `main` | `ajax/save_module_config.php` | `tenant_modules` | ISP Admin, Support, Finance, Technician |
| `settings_network.php` | Network defaults | `settings.edit` | `main` | `ajax/save_network_settings.php` | `bandwidth_profiles`, `queue_tree_templates` | ISP Admin, Support, Finance, Technician |
| `settings_notifications.php` | Notification config | `settings.edit` | `main` | `ajax/save_notification_config.php` | `notification_channels`, `notification_provider_configs` | ISP Admin, Support, Finance, Technician |
| `settings_payments.php` | Payment gateways | `settings.edit` | `main` | `ajax/save_payment_gateway_config.php`, `ajax/test_gateway_connection.php` | `payment_gateway_configs`, `payment_gateways` | ISP Admin, Support, Finance, Technician |
| `settings_radius.php` | RADIUS settings | `settings.edit` | `main` | `ajax/save_radius_settings.php` | `tenant_settings`, `nas` | ISP Admin, Support, Finance, Technician |
| `settings_security.php` | Security settings | `settings.edit` | `main` | `ajax/save_security_settings.php` | `ip_whitelist`, `api_rate_limits` | ISP Admin, Support, Finance, Technician |
| `settings_webhooks.php` | Webhooks | `settings.edit` | `main` | `ajax/save_webhook.php`, `ajax/test_webhook.php` | `tenant_webhooks`, `webhook_delivery_log` | ISP Admin, Support, Finance, Technician |

### Tenants

| File | Purpose | Permission | Layout | AJAX | Tables | Roles |
|------|---------|------------|--------|------|--------|-------|
| `tenant_billing.php` | SaaS billing config | `tenants.edit` | `main` | `ajax/save_tenant_billing.php` | `tenant_billing`, `tenant_subscriptions` | Super Admin |
| `tenant_domains.php` | Domain management | `tenants.edit` | `main` | `ajax/save_tenant_domain.php`, `ajax/verify_domain.php` | `tenant_domains` | Super Admin |
| `tenant_edit.php` | Create/edit tenant | `tenants.create|tenants.edit` | `main` | `ajax/save_tenant.php`, `ajax/provision_tenant.php` | `tenants`, `tenant_billing`, `tenant_settings` | Super Admin |
| `tenant_modules.php` | Module toggles | `tenants.edit` | `main` | `ajax/toggle_tenant_module.php` | `tenant_modules`, `system_modules` | Super Admin |
| `tenant_view.php` | Tenant detail | `tenants.view` | `main` | `ajax/get_tenant_details.php` | `tenants`, `tenant_domains`, `tenant_modules` | Super Admin |
| `tenants.php` | Tenant list | `tenants.view` | `main` | `ajax/get_tenants.php`, `ajax/delete_tenant.php` | `tenants` | Super Admin |

### Ticketing

| File | Purpose | Permission | Layout | AJAX | Tables | Roles |
|------|---------|------------|--------|------|--------|-------|
| `ticket_categories.php` | Categories | `tickets.view` | `main` | `ajax/save_ticket_category.php` | `ticket_categories` | ISP Admin, Support |
| `ticket_edit.php` | Create ticket | `tickets.create` | `main` | `ajax/save_ticket.php` | `tickets`, `ticket_messages` | ISP Admin, Support |
| `ticket_sla.php` | SLA rules | `settings.edit` | `main` | `ajax/save_ticket_sla.php` | `ticket_sla_rules` | ISP Admin, Support |
| `ticket_view.php` | Ticket detail | `tickets.view` | `main` | `ajax/get_ticket_messages.php`, `ajax/reply_ticket.php`, `ajax/assign_ticket.php` | `tickets`, `ticket_messages`, `ticket_attachments` | ISP Admin, Support |
| `tickets.php` | Ticket list | `tickets.view` | `main` | `ajax/get_tickets.php` | `tickets` | ISP Admin, Support |

### Users & RBAC

| File | Purpose | Permission | Layout | AJAX | Tables | Roles |
|------|---------|------------|--------|------|--------|-------|
| `api_tokens.php` | API token management | `settings.edit` | `main` | `ajax/create_api_token.php`, `ajax/revoke_api_token.php` | `api_tokens` | ISP Admin, Support, Finance, Technician |
| `audit_logs.php` | Audit trail | `settings.view` | `main` | `ajax/get_audit_logs.php` | `audit_logs` | ISP Admin, Support, Finance, Technician |
| `login_history.php` | Login history | `users.view` | `main` | `ajax/get_login_history.php` | `login_history` | ISP Admin, Support, Finance, Technician |
| `permissions.php` | Permission matrix view | `users.view` | `main` | `ajax/get_permissions.php` | `permissions`, `role_permissions` | ISP Admin, Support, Finance, Technician |
| `role_edit.php` | Create/edit role | `users.edit` | `main` | `ajax/save_role.php`, `ajax/save_role_permissions.php` | `roles`, `role_permissions`, `permissions` | ISP Admin, Support, Finance, Technician |
| `roles.php` | Role list | `users.view` | `main` | `ajax/get_roles.php` | `roles` | ISP Admin, Support, Finance, Technician |
| `user_edit.php` | Create/edit user | `users.create|users.edit` | `main` | `ajax/save_user.php`, `ajax/assign_roles.php` | `users`, `user_roles`, `roles` | ISP Admin, Support, Finance, Technician |
| `users.php` | Staff user list | `users.view` | `main` | `ajax/get_users.php`, `ajax/delete_user.php` | `users`, `user_roles` | ISP Admin, Support, Finance, Technician |

### VPN

| File | Purpose | Permission | Layout | AJAX | Tables | Roles |
|------|---------|------------|--------|------|--------|-------|
| `vpn_logs.php` | VPN logs | `vpn.view` | `main` | `ajax/get_vpn_logs.php` | `vpn_logs` | ISP Admin, Technician |
| `vpn_peer_edit.php` | Edit peer | `vpn.edit` | `main` | `ajax/generate_vpn_keys.php`, `ajax/push_vpn_config.php` | `vpn_peers`, `vpn_keys` | ISP Admin, Technician |
| `vpn_peers.php` | VPN peers | `vpn.view` | `main` | `ajax/get_vpn_peers.php`, `ajax/save_vpn_peer.php` | `vpn_peers` | ISP Admin, Technician |
| `vpn_server_edit.php` | Edit VPN server | `vpn.create|vpn.edit` | `main` | `ajax/save_vpn_server.php` | `vpn_servers`, `vpn_server_interfaces` | ISP Admin, Technician |
| `vpn_servers.php` | VPN servers | `vpn.view` | `main` | `ajax/get_vpn_servers.php`, `ajax/save_vpn_server.php` | `vpn_servers` | ISP Admin, Technician |
| `vpn_tunnels.php` | Tunnel monitor | `vpn.view` | `main` | `ajax/get_vpn_tunnels.php` | `vpn_tunnels`, `vpn_peer_status` | ISP Admin, Technician |

### Vouchers

| File | Purpose | Permission | Layout | AJAX | Tables | Roles |
|------|---------|------------|--------|------|--------|-------|
| `voucher_batch_edit.php` | Create batch | `vouchers.create` | `main` | `ajax/generate_voucher_batch.php` | `voucher_batches`, `vouchers` | ISP Admin, Support, Finance, Technician |
| `voucher_batch_view.php` | Batch detail | `vouchers.view` | `main` | `ajax/get_voucher_batch_details.php` | `vouchers`, `voucher_usage` | ISP Admin, Support, Finance, Technician |
| `voucher_batches.php` | Batch list | `vouchers.view` | `main` | `ajax/get_voucher_batches.php` | `voucher_batches` | ISP Admin, Support, Finance, Technician |
| `voucher_print.php` | Print vouchers | `vouchers.print` | `main` | `ajax/get_vouchers_for_print.php` | `voucher_prints` | ISP Admin, Support, Finance, Technician |
| `voucher_resellers.php` | Resellers | `vouchers.view` | `main` | `ajax/save_voucher_reseller.php` | `voucher_resellers` | ISP Admin, Support, Finance, Technician |
| `voucher_templates.php` | Print templates | `vouchers.create` | `main` | `ajax/save_voucher_template.php` | `voucher_templates` | ISP Admin, Support, Finance, Technician |
| `vouchers.php` | Voucher search | `vouchers.view` | `main` | `ajax/search_vouchers.php` | `vouchers` | ISP Admin, Support, Finance, Technician |

---

## Support Directories


### `/includes/` — Core PHP

| File | Purpose |
|------|---------|
| `config.php` | App configuration, constants, environment |
| `db.php` | PDO connection, query helpers, tenant scoping |
| `auth.php` | Authentication, session, permission_check(), role_check() |
| `tenant.php` | Tenant resolution from domain/session |
| `audit.php` | audit_log() wrapper |
| `menu_config.php` | Sidebar menu definition |
| `functions.php` | Global helper functions |
| `date_helpers.php` | Date/time formatting per tenant timezone |
| `validation.php` | Input validation helpers |
| `pagination.php` | DataTables/pagination helpers |
| `MikrotikAPI.php` | RouterOS API client |
| `RouterManager.php` | Router CRUD, health, backup orchestration |
| `RadiusManager.php` | FreeRADIUS provisioning and sync |
| `WireGuardManager.php` | VPN key generation and config push |
| `PaymentGateway.php` | Abstract payment gateway base |
| `MpesaGateway.php` | M-Pesa Daraja integration |
| `MomoGateway.php` | MTN MoMo integration |
| `AirtelGateway.php` | Airtel Money integration |
| `TigoGateway.php` | Tigo Pesa integration |
| `VoucherManager.php` | Voucher generation and redemption |
| `NotificationService.php` | SMS/email queue dispatcher |
| `ReportEngine.php` | Report generation and caching |
| `CaptivePortalEngine.php` | Portal template rendering |
| `InvoiceGenerator.php` | Invoice PDF/Excel generation |
| `BackupManager.php` | Router config backup handler |
| `Encryption.php` | Credential encryption at rest |
| `ApiAuth.php` | API token validation |
| `WebhookDispatcher.php` | Outbound webhook delivery |
| `TenantProvisioner.php` | New tenant setup |
| `SessionManager.php` | Session lifecycle |
| `mpesa_helper.php` | Legacy M-Pesa helpers (reference) |
| `rbac_system.php` | Legacy RBAC (reference, rewrite target) |

### `/layouts/` — UI Layouts

| File | Purpose |
|------|---------|
| `session.php` | Session bootstrap |
| `header.php` | Admin header |
| `sidebar.php` | Admin sidebar navigation |
| `footer.php` | Admin footer |
| `main_start.php` | Main content wrapper open |
| `main_end.php` | Main content wrapper close |
| `auth_header.php` | Auth page header |
| `auth_footer.php` | Auth page footer |
| `portal_header.php` | Customer portal header |
| `portal_sidebar.php` | Customer portal nav |
| `portal_footer.php` | Customer portal footer |
| `print_layout.php` | Print-friendly layout |
| `email_layout.php` | HTML email wrapper |

### `/ajax/` — AJAX Endpoints (265 files)

- `ajax/acknowledge_router_alert.php`
- `ajax/add_invoice_item.php`
- `ajax/allocate_payment.php`
- `ajax/apply_credit_note.php`
- `ajax/apply_queue_template.php`
- `ajax/assign_roles.php`
- `ajax/assign_static_ip.php`
- `ajax/assign_ticket.php`
- `ajax/attach_ticket_file.php`
- `ajax/billing_summary.php`
- `ajax/bulk_send_email.php`
- `ajax/bulk_send_sms.php`
- `ajax/bulk_suspend_customers.php`
- `ajax/captive_authenticate.php`
- `ajax/captive_package_list.php`
- `ajax/captive_voucher_login.php`
- `ajax/change_password.php`
- `ajax/check_customer_email.php`
- `ajax/check_customer_phone.php`
- `ajax/check_momo_status.php`
- `ajax/check_mpesa_status.php`
- `ajax/close_ticket.php`
- `ajax/coa_change_rate.php`
- `ajax/coa_disconnect.php`
- `ajax/create_api_token.php`
- `ajax/create_router_backup.php`
- `ajax/dashboard_charts.php`
- `ajax/dashboard_metrics.php`
- `ajax/delete_customer_document.php`
- `ajax/delete_package.php`
- `ajax/delete_router.php`
- `ajax/delete_tenant.php`
- `ajax/delete_upload.php`
- `ajax/delete_user.php`
- `ajax/disconnect_hotspot_session.php`
- `ajax/disconnect_pppoe_session.php`
- `ajax/discover_router.php`
- `ajax/download_router_backup.php`
- `ajax/end_impersonation.php`
- `ajax/escalate_ticket.php`
- `ajax/export_customers.php`
- `ajax/export_invoices.php`
- `ajax/export_payments.php`
- `ajax/export_report.php`
- `ajax/export_vouchers.php`
- `ajax/generate_invoice_pdf.php`
- `ajax/generate_voucher_batch.php`
- `ajax/generate_voucher_pins.php`
- `ajax/generate_vpn_keys.php`
- `ajax/get_airtel_transactions.php`
- `ajax/get_audit_entity.php`
- `ajax/get_audit_logs.php`
- `ajax/get_captive_portals.php`
- `ajax/get_chart_data.php`
- `ajax/get_countries.php`
- `ajax/get_currencies.php`
- `ajax/get_customer_details.php`
- `ajax/get_customer_groups.php`
- `ajax/get_customer_subscriptions.php`
- `ajax/get_customers.php`
- `ajax/get_customers_dropdown.php`
- `ajax/get_email_logs.php`
- `ajax/get_hotspot_sessions.php`
- `ajax/get_hotspot_usage.php`
- `ajax/get_hotspots.php`
- `ajax/get_invoices.php`
- `ajax/get_login_history.php`
- `ajax/get_menu.php`
- `ajax/get_momo_transactions.php`
- `ajax/get_mpesa_transactions.php`
- `ajax/get_notification_queue.php`
- `ajax/get_notifications_count.php`
- `ajax/get_package_details.php`
- `ajax/get_packages.php`
- `ajax/get_packages_dropdown.php`
- `ajax/get_payment_callbacks.php`
- `ajax/get_payment_details.php`
- `ajax/get_payments.php`
- `ajax/get_permissions.php`
- `ajax/get_pppoe_accounts.php`
- `ajax/get_pppoe_sessions.php`
- `ajax/get_radacct.php`
- `ajax/get_radius_profiles.php`
- `ajax/get_radius_sync_log.php`
- `ajax/get_roles.php`
- `ajax/get_router_commands.php`
- `ajax/get_router_details.php`
- `ajax/get_router_metrics.php`
- `ajax/get_router_status.php`
- `ajax/get_routers.php`
- `ajax/get_routers_dropdown.php`
- `ajax/get_sms_logs.php`
- `ajax/get_tenant_context.php`
- `ajax/get_tenant_details.php`
- `ajax/get_tenants.php`
- `ajax/get_ticket_messages.php`
- `ajax/get_ticket_priorities.php`
- `ajax/get_ticket_statuses.php`
- `ajax/get_tickets.php`
- `ajax/get_timezones.php`
- `ajax/get_users.php`
- `ajax/get_voucher_batch_details.php`
- `ajax/get_voucher_batches.php`
- `ajax/get_vouchers_for_print.php`
- `ajax/get_vpn_logs.php`
- `ajax/get_vpn_peers.php`
- `ajax/get_vpn_servers.php`
- `ajax/get_vpn_tunnels.php`
- `ajax/health_check.php`
- `ajax/impersonate_tenant.php`
- `ajax/import_routers.php`
- `ajax/initiate_disbursement.php`
- `ajax/issue_invoice.php`
- `ajax/login_attempt.php`
- `ajax/mark_notification_read.php`
- `ajax/match_payment.php`
- `ajax/portal_change_password.php`
- `ajax/portal_create_ticket.php`
- `ajax/portal_dashboard_data.php`
- `ajax/portal_download_invoice.php`
- `ajax/portal_forgot_password.php`
- `ajax/portal_get_invoices.php`
- `ajax/portal_get_packages.php`
- `ajax/portal_get_payments.php`
- `ajax/portal_get_tickets.php`
- `ajax/portal_initiate_payment.php`
- `ajax/portal_login.php`
- `ajax/portal_purchase_package.php`
- `ajax/portal_redeem_voucher.php`
- `ajax/portal_register.php`
- `ajax/portal_reply_ticket.php`
- `ajax/portal_reset_password.php`
- `ajax/portal_save_profile.php`
- `ajax/portal_stk_push.php`
- `ajax/portal_usage_data.php`
- `ajax/preview_captive_portal.php`
- `ajax/process_customer_import.php`
- `ajax/process_refund.php`
- `ajax/provision_tenant.php`
- `ajax/push_vpn_config.php`
- `ajax/queue_router_command.php`
- `ajax/record_payment.php`
- `ajax/refresh_all_routers.php`
- `ajax/refresh_router_status.php`
- `ajax/remove_invoice_item.php`
- `ajax/render_captive_preview.php`
- `ajax/reply_ticket.php`
- `ajax/report_aging_data.php`
- `ajax/report_collections_data.php`
- `ajax/report_customers_data.php`
- `ajax/report_hotspot_data.php`
- `ajax/report_network_data.php`
- `ajax/report_pppoe_data.php`
- `ajax/report_revenue_data.php`
- `ajax/report_routers_data.php`
- `ajax/report_subscriptions_data.php`
- `ajax/report_tax_data.php`
- `ajax/report_tickets_data.php`
- `ajax/report_usage_data.php`
- `ajax/report_vouchers_data.php`
- `ajax/restore_router_backup.php`
- `ajax/retry_callback.php`
- `ajax/reverse_payment.php`
- `ajax/revoke_api_token.php`
- `ajax/revoke_vpn_peer.php`
- `ajax/rotate_vpn_keys.php`
- `ajax/run_billing_cycle.php`
- `ajax/run_reconciliation.php`
- `ajax/run_router_discovery.php`
- `ajax/run_router_script.php`
- `ajax/save_api_settings.php`
- `ajax/save_bandwidth_profile.php`
- `ajax/save_billing_cycle.php`
- `ajax/save_billing_settings.php`
- `ajax/save_captive_portal.php`
- `ajax/save_captive_theme.php`
- `ajax/save_credit_note.php`
- `ajax/save_customer.php`
- `ajax/save_customer_device.php`
- `ajax/save_customer_group.php`
- `ajax/save_customer_note.php`
- `ajax/save_customer_subscription.php`
- `ajax/save_dashboard_layout.php`
- `ajax/save_debit_note.php`
- `ajax/save_dunning_rule.php`
- `ajax/save_fibre_connection.php`
- `ajax/save_firewall_rule.php`
- `ajax/save_hotspot.php`
- `ajax/save_hotspot_mac.php`
- `ajax/save_hotspot_portal.php`
- `ajax/save_hotspot_profile.php`
- `ajax/save_hotspot_user.php`
- `ajax/save_invoice.php`
- `ajax/save_localization.php`
- `ajax/save_module_config.php`
- `ajax/save_nas.php`
- `ajax/save_network_settings.php`
- `ajax/save_notification_config.php`
- `ajax/save_notification_rule.php`
- `ajax/save_notification_template.php`
- `ajax/save_package.php`
- `ajax/save_package_group.php`
- `ajax/save_package_limits.php`
- `ajax/save_package_pricing.php`
- `ajax/save_payment_gateway_config.php`
- `ajax/save_payment_plan.php`
- `ajax/save_pppoe_account.php`
- `ajax/save_pppoe_pool.php`
- `ajax/save_pppoe_profile.php`
- `ajax/save_profile.php`
- `ajax/save_promotion.php`
- `ajax/save_radius_group.php`
- `ajax/save_radius_profile.php`
- `ajax/save_radius_settings.php`
- `ajax/save_report_definition.php`
- `ajax/save_report_schedule.php`
- `ajax/save_role.php`
- `ajax/save_role_permissions.php`
- `ajax/save_router.php`
- `ajax/save_router_group.php`
- `ajax/save_router_queue.php`
- `ajax/save_router_schedule.php`
- `ajax/save_router_script.php`
- `ajax/save_security_settings.php`
- `ajax/save_service_location.php`
- `ajax/save_tenant.php`
- `ajax/save_tenant_billing.php`
- `ajax/save_tenant_domain.php`
- `ajax/save_tenant_settings.php`
- `ajax/save_tenant_theme.php`
- `ajax/save_ticket.php`
- `ajax/save_ticket_category.php`
- `ajax/save_ticket_sla.php`
- `ajax/save_user.php`
- `ajax/save_voucher_reseller.php`
- `ajax/save_voucher_template.php`
- `ajax/save_vpn_peer.php`
- `ajax/save_vpn_server.php`
- `ajax/save_walled_garden.php`
- `ajax/save_webhook.php`
- `ajax/search_customers.php`
- `ajax/search_global.php`
- `ajax/search_vouchers.php`
- `ajax/send_email.php`
- `ajax/send_invoice.php`
- `ajax/send_password_reset.php`
- `ajax/send_sms.php`
- `ajax/suspend_hotspot_user.php`
- `ajax/suspend_pppoe_account.php`
- `ajax/suspend_subscription.php`
- `ajax/sync_hotspot_users.php`
- `ajax/sync_pppoe_to_radius.php`
- `ajax/sync_radius.php`
- `ajax/sync_router_users.php`
- `ajax/test_gateway_connection.php`
- `ajax/test_router_connection.php`
- `ajax/test_webhook.php`
- `ajax/toggle_tenant_module.php`
- `ajax/upload_customer_document.php`
- `ajax/upload_customer_import.php`
- `ajax/upload_file.php`
- `ajax/validate_session.php`
- `ajax/verify_customer_kyc.php`
- `ajax/verify_domain.php`
- `ajax/void_invoice.php`

### `/api/v1/` — REST API

| Endpoint | Purpose |
|----------|---------|
| `api/v1/auth/login.php` | Staff API login |
| `api/v1/auth/token.php` | Token refresh |
| `api/v1/auth/logout.php` | Token revoke |
| `api/v1/tenants/index.php` | List tenants (super admin) |
| `api/v1/tenants/show.php` | Tenant detail |
| `api/v1/customers/index.php` | List customers |
| `api/v1/customers/show.php` | Customer detail |
| `api/v1/customers/store.php` | Create customer |
| `api/v1/customers/update.php` | Update customer |
| `api/v1/routers/index.php` | List routers |
| `api/v1/routers/show.php` | Router detail |
| `api/v1/routers/status.php` | Router health |
| `api/v1/routers/command.php` | Queue command |
| `api/v1/packages/index.php` | List packages |
| `api/v1/invoices/index.php` | List invoices |
| `api/v1/invoices/show.php` | Invoice detail |
| `api/v1/payments/index.php` | List payments |
| `api/v1/payments/store.php` | Record payment |
| `api/v1/radius/authenticate.php` | RADIUS auth hook |
| `api/v1/radius/accounting.php` | RADIUS accounting hook |
| `api/v1/radius/coa.php` | Change of authorization |
| `api/v1/captive/login.php` | Captive portal login |
| `api/v1/captive/status.php` | Captive session status |
| `api/v1/captive/packages.php` | Captive available packages |
| `api/v1/vouchers/redeem.php` | Voucher redemption |
| `api/v1/vouchers/validate.php` | Voucher validation |
| `api/v1/sessions/pppoe.php` | PPPoE session list |
| `api/v1/sessions/hotspot.php` | Hotspot session list |
| `api/v1/payments/callback/mpesa.php` | M-Pesa callback |
| `api/v1/payments/callback/momo.php` | MTN MoMo callback |
| `api/v1/payments/callback/airtel.php` | Airtel callback |
| `api/v1/payments/callback/tigo.php` | Tigo callback |
| `api/v1/payments/stk_push.php` | Initiate STK push |
| `api/v1/payments/status.php` | Payment status check |
| `api/v1/webhooks/router.php` | Router event webhook receiver |
| `api/v1/health.php` | API health check |
| `api/v1/portal/login.php` | Customer portal API login |
| `api/v1/portal/subscriptions.php` | Customer subscriptions |
| `api/v1/portal/usage.php` | Customer usage data |
| `api/v1/tickets/index.php` | Customer tickets |
| `api/v1/tickets/store.php` | Create ticket |

### `/cron/` — Scheduled Jobs

| File | Schedule | Purpose |
|------|----------|---------|
| `router_health.php` | `*/5 * * * *` | Poll router health status |
| `router_backup.php` | `0 2 * * *` | Scheduled router backups |
| `router_command_processor.php` | `* * * * *` | Process command queue |
| `session_sync.php` | `*/2 * * * *` | Sync PPPoE/hotspot sessions |
| `radius_sync.php` | `*/5 * * * *` | Sync RADIUS profiles |
| `radius_accounting_rollup.php` | `0 * * * *` | Aggregate radacct data |
| `invoice_generate.php` | `0 1 * * *` | Generate recurring invoices |
| `billing_run.php` | `0 6 * * *` | Execute billing cycle |
| `payment_reconcile.php` | `*/15 * * * *` | Reconcile mobile money |
| `payment_status_check.php` | `*/10 * * * *` | Poll pending payments |
| `dunning_process.php` | `0 8 * * *` | Process overdue accounts |
| `notification_queue.php` | `* * * * *` | Send queued notifications |
| `report_cache.php` | `0 */4 * * *` | Refresh report cache |
| `dashboard_metrics.php` | `*/15 * * * *` | Update dashboard metrics |
| `voucher_expiry.php` | `0 0 * * *` | Expire old vouchers |
| `subscription_renewal.php` | `0 3 * * 0` | Auto-renew subscriptions |
| `vpn_key_rotation.php` | `0 0 1 * *` | Rotate VPN keys |
| `tenant_usage_snapshot.php` | `0 4 * * *` | SaaS usage metering |
| `audit_archive.php` | `0 5 * * 0` | Archive old audit logs |
| `cleanup_sessions.php` | `0 * * * *` | Purge expired sessions |

### `/install/` — Installation Wizard

| File | Purpose |
|------|---------|
| `install.php` | Installation wizard entry |
| `steps/requirements.php` | Server requirements check |
| `steps/database.php` | Database configuration |
| `steps/admin.php` | Admin user creation |
| `steps/tenant.php` | First tenant setup |
| `steps/complete.php` | Installation complete |
| `migrations/.gitkeep` | Future migration files |

### `/templates/` — Captive Portal Themes

| File | Purpose |
|------|---------|
| `hotel/index.html` | Hotel captive portal |
| `hotel/login.html` | Hotel login page |
| `hotel/success.html` | Hotel success page |
| `school/index.html` | School portal |
| `school/login.html` | School login |
| `school/terms.html` | School terms page |
| `isp/index.html` | ISP branded portal |
| `isp/login.html` | ISP login |
| `isp/packages.html` | ISP package selection |
| `public_wifi/index.html` | Public WiFi portal |
| `public_wifi/splash.html` | Splash page |
| `event/index.html` | Event portal |
| `event/register.html` | Event registration |
| `shared/css/portal.css` | Shared portal styles |
| `shared/js/portal.js` | Shared portal scripts |

### `/backups/` — Backup Scripts

| File | Purpose |
|------|---------|
| `backup_database.sh` | MySQL dump script |
| `backup_uploads.sh` | Uploads archive script |
| `backup_router_configs.sh` | Router backup archive |
| `restore_database.sh` | Database restore script |

### Other Directories

| Directory | Purpose |
|-----------|---------|
| `/assets/` | Bootstrap 5, jQuery, Chart.js, DataTables, icons |
| `/vendor/` | PHPMailer, PHPSpreadsheet |
| `/uploads/` | Tenant/customer file uploads |
| `/logs/` | Application logs |
| `/sql/` | `database_schema.sql` and migrations |
| `/docs/` | Specifications and design docs |

---

## File Dependency Rules

1. Root pages never include other root pages — use redirects
2. All DB access goes through `includes/db.php`
3. All AJAX endpoints require `includes/auth.php` or `includes/ApiAuth.php`
4. Customer portal pages use `portal_` prefix and `layouts/portal_*.php`
5. Report pages use `report_` prefix and `includes/ReportEngine.php`
6. Permission checks use `permission_check('module.action')` per RBAC spec

## Change Log

| Version | Date | Change |
|---------|------|--------|
| 1.0 | 2026-06-13 | Initial manifest — 564+ files |
