# dzakywifinet-lgtm/dzw-monitoring-sales architecture

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

- Interactive diagram: https://gitdiagram.com/dzakywifinet-lgtm/dzw-monitoring-sales
- Repository: https://github.com/dzakywifinet-lgtm/dzw-monitoring-sales

## Overview

This is a MikroTik voucher-sales and usage dashboard. The main flow is router credentials at login, then dashboard polling and on-demand voucher/PPPoE operations; settings configure quota, notifications, and cron. The graph also preserves sales, bandwidth/traffic, usage analysis, voucher printing, and PWA capabilities described by the README. Most endpoint-to-frontend wiring and several subsystems are documented but not sampled, so those links are dashed and marked unverified rather than inferred as confirmed calls.

Main entry points: [`includes/functions.php`](https://github.com/dzakywifinet-lgtm/dzw-monitoring-sales/blob/main/includes/functions.php) (Router and domain logic), [`includes/auth.php`](https://github.com/dzakywifinet-lgtm/dzw-monitoring-sales/blob/main/includes/auth.php) (Session auth), [`index.php`](https://github.com/dzakywifinet-lgtm/dzw-monitoring-sales/blob/main/index.php) (Dashboard view), [`assets/app.js`](https://github.com/dzakywifinet-lgtm/dzw-monitoring-sales/blob/main/assets/app.js) (Dashboard browser app)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_access["Access &amp; Dashboard"]
  node_login["Router login<br/>[login.php]"]
  node_auth["Session auth<br/>[auth.php]"]
  node_dashboard["Dashboard view<br/>[index.php]"]
  node_assets["Dashboard browser app<br/>[app.js]"]
end

subgraph group_router["Router Operations"]
  node_api_client["RouterOS API"]
  node_core["Router and domain logic<br/>[functions.php]"]
  node_pppoe_api["PPPoE actions<br/>[pppoe.php]"]
  node_voucher_api["Voucher actions<br/>[vouchers.php]"]
end

subgraph group_insights["Usage &amp; Sales"]
  node_live_api["Live status API<br/>[live.php]"]
  node_sales_api["Sales API<br/>[sales.php]"]
  node_traffic_api["Live traffic API<br/>[traffic.php]"]
  node_usage_script["Router usage categories"]
end

subgraph group_config["Settings &amp; Storage"]
  node_settings["Dashboard settings<br/>[settings.php]"]
  node_template_api["Print templates API"]
  node_storage[("Local JSON state<br/>[storage.php]")]
end

subgraph group_delivery["Notifications &amp; PWA"]
  node_cron["Scheduled checks<br/>[cron.php]"]
  node_telegram{{"Telegram notifications"}}
  node_pwa["Offline app shell<br/>[service-worker.js]"]
end

node_user(("Dashboard user"))
node_router{{"MikroTik router"}}

node_user -->|"enters credentials"| node_login
node_login -->|"tests and connects"| node_core
node_login -->|"stores session"| node_auth
node_auth -->|"connects session"| node_core
node_core -->|"uses API client"| node_api_client
node_api_client -->|"sends RouterOS commands"| node_router
node_user -->|"opens dashboard"| node_dashboard
node_dashboard -->|"requires login"| node_auth
node_dashboard -->|"builds dashboard data"| node_core
node_dashboard -.->|"loads browser app"| node_assets
node_assets -.->|"polls status"| node_live_api
node_assets -.->|"refreshes sales"| node_sales_api
node_assets -.->|"polls bandwidth"| node_traffic_api
node_live_api -->|"checks session"| node_auth
node_live_api -->|"fetches live data"| node_core
node_sales_api -->|"builds sales data"| node_core
node_traffic_api -->|"fetches interface rate"| node_core
node_user -.->|"requests PPPoE actions"| node_pppoe_api
node_pppoe_api -->|"checks session"| node_auth
node_pppoe_api -->|"runs PPPoE actions"| node_core
node_user -.->|"manages vouchers"| node_voucher_api
node_voucher_api -->|"runs voucher actions"| node_core
node_user -.->|"edits print layouts"| node_template_api
node_template_api -->|"reads and writes templates"| node_storage
node_user -->|"configures dashboard"| node_settings
node_settings -->|"requires login"| node_auth
node_settings -->|"saves settings and cron credentials"| node_storage
node_core -->|"tracks usage state"| node_storage
node_cron -->|"loads cron credentials"| node_storage
node_cron -->|"runs scheduled checks"| node_core
node_cron -.->|"sends alerts"| node_telegram
node_core -.->|"reads router counters"| node_usage_script
node_dashboard -->|"registers service worker"| node_pwa

click node_login "https://github.com/dzakywifinet-lgtm/dzw-monitoring-sales/blob/main/login.php"
click node_auth "https://github.com/dzakywifinet-lgtm/dzw-monitoring-sales/blob/main/includes/auth.php"
click node_dashboard "https://github.com/dzakywifinet-lgtm/dzw-monitoring-sales/blob/main/index.php"
click node_settings "https://github.com/dzakywifinet-lgtm/dzw-monitoring-sales/blob/main/settings.php"
click node_api_client "https://github.com/dzakywifinet-lgtm/dzw-monitoring-sales/blob/main/lib/routeros_api.class.php"
click node_core "https://github.com/dzakywifinet-lgtm/dzw-monitoring-sales/blob/main/includes/functions.php"
click node_live_api "https://github.com/dzakywifinet-lgtm/dzw-monitoring-sales/blob/main/api/live.php"
click node_sales_api "https://github.com/dzakywifinet-lgtm/dzw-monitoring-sales/blob/main/api/sales.php"
click node_traffic_api "https://github.com/dzakywifinet-lgtm/dzw-monitoring-sales/blob/main/api/traffic.php"
click node_pppoe_api "https://github.com/dzakywifinet-lgtm/dzw-monitoring-sales/blob/main/api/pppoe.php"
click node_voucher_api "https://github.com/dzakywifinet-lgtm/dzw-monitoring-sales/blob/main/api/vouchers.php"
click node_template_api "https://github.com/dzakywifinet-lgtm/dzw-monitoring-sales/blob/main/api/voucher_templates.php"
click node_storage "https://github.com/dzakywifinet-lgtm/dzw-monitoring-sales/blob/main/includes/storage.php"
click node_cron "https://github.com/dzakywifinet-lgtm/dzw-monitoring-sales/blob/main/cron.php"
click node_usage_script "https://github.com/dzakywifinet-lgtm/dzw-monitoring-sales/blob/main/usage-kategori-mikrotik.rsc"
click node_pwa "https://github.com/dzakywifinet-lgtm/dzw-monitoring-sales/blob/main/service-worker.js"
click node_assets "https://github.com/dzakywifinet-lgtm/dzw-monitoring-sales/blob/main/assets/app.js"

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_login,node_auth,node_dashboard,node_assets,node_user toneBlue
class node_api_client,node_core,node_pppoe_api,node_voucher_api toneAmber
class node_live_api,node_sales_api,node_traffic_api,node_usage_script,node_router toneMint
class node_settings,node_template_api,node_storage toneRose
class node_cron,node_telegram,node_pwa toneIndigo
```

## Components

### Access & Dashboard

- [Router login](https://github.com/dzakywifinet-lgtm/dzw-monitoring-sales/blob/main/login.php): `login.php`
- [Session auth](https://github.com/dzakywifinet-lgtm/dzw-monitoring-sales/blob/main/includes/auth.php): `includes/auth.php`
- [Dashboard view](https://github.com/dzakywifinet-lgtm/dzw-monitoring-sales/blob/main/index.php): `index.php`
- [Dashboard browser app](https://github.com/dzakywifinet-lgtm/dzw-monitoring-sales/blob/main/assets/app.js): `assets/app.js`

### Router Operations

- [RouterOS API](https://github.com/dzakywifinet-lgtm/dzw-monitoring-sales/blob/main/lib/routeros_api.class.php): `lib/routeros_api.class.php`
- [Router and domain logic](https://github.com/dzakywifinet-lgtm/dzw-monitoring-sales/blob/main/includes/functions.php): `includes/functions.php`
- [PPPoE actions](https://github.com/dzakywifinet-lgtm/dzw-monitoring-sales/blob/main/api/pppoe.php): `api/pppoe.php`
- [Voucher actions](https://github.com/dzakywifinet-lgtm/dzw-monitoring-sales/blob/main/api/vouchers.php): `api/vouchers.php`

### Usage & Sales

- [Live status API](https://github.com/dzakywifinet-lgtm/dzw-monitoring-sales/blob/main/api/live.php): `api/live.php`
- [Sales API](https://github.com/dzakywifinet-lgtm/dzw-monitoring-sales/blob/main/api/sales.php): `api/sales.php`
- [Live traffic API](https://github.com/dzakywifinet-lgtm/dzw-monitoring-sales/blob/main/api/traffic.php): `api/traffic.php`
- [Router usage categories](https://github.com/dzakywifinet-lgtm/dzw-monitoring-sales/blob/main/usage-kategori-mikrotik.rsc): `usage-kategori-mikrotik.rsc`

### Settings & Storage

- [Dashboard settings](https://github.com/dzakywifinet-lgtm/dzw-monitoring-sales/blob/main/settings.php): `settings.php`
- [Print templates API](https://github.com/dzakywifinet-lgtm/dzw-monitoring-sales/blob/main/api/voucher_templates.php): `api/voucher_templates.php`
- [Local JSON state](https://github.com/dzakywifinet-lgtm/dzw-monitoring-sales/blob/main/includes/storage.php): `includes/storage.php`

### Notifications & PWA

- [Scheduled checks](https://github.com/dzakywifinet-lgtm/dzw-monitoring-sales/blob/main/cron.php): `cron.php`
- **Telegram notifications**
- [Offline app shell](https://github.com/dzakywifinet-lgtm/dzw-monitoring-sales/blob/main/service-worker.js): `service-worker.js`

### Other components

- **Dashboard user**
- **MikroTik router**

## Connections

- Dashboard user → Router login: enters credentials (evidence: `README.md`)
- Router login → Router and domain logic: tests and connects (evidence: `login.php`)
- Router login → Session auth: stores session (evidence: `login.php`)
- Session auth → Router and domain logic: connects session (evidence: `includes/auth.php`)
- Router and domain logic → RouterOS API: uses API client (evidence: `includes/functions.php`)
- RouterOS API → MikroTik router: sends RouterOS commands (evidence: `lib/routeros_api.class.php`)
- Dashboard user → Dashboard view: opens dashboard (evidence: `README.md`)
- Dashboard view → Session auth: requires login (evidence: `index.php`)
- Dashboard view → Router and domain logic: builds dashboard data (evidence: `index.php`)
- Dashboard view → Dashboard browser app: loads browser app
- Dashboard browser app → Live status API: polls status
- Dashboard browser app → Sales API: refreshes sales
- Dashboard browser app → Live traffic API: polls bandwidth
- Live status API → Session auth: checks session (evidence: `api/live.php`)
- Live status API → Router and domain logic: fetches live data (evidence: `api/live.php`)
- Sales API → Router and domain logic: builds sales data (evidence: `api/sales.php`)
- Live traffic API → Router and domain logic: fetches interface rate (evidence: `api/traffic.php`)
- Dashboard user → PPPoE actions: requests PPPoE actions
- PPPoE actions → Session auth: checks session (evidence: `api/pppoe.php`)
- PPPoE actions → Router and domain logic: runs PPPoE actions (evidence: `api/pppoe.php`)
- Dashboard user → Voucher actions: manages vouchers
- Voucher actions → Router and domain logic: runs voucher actions (evidence: `api/vouchers.php`)
- Dashboard user → Print templates API: edits print layouts
- Print templates API → Local JSON state: reads and writes templates (evidence: `api/voucher_templates.php`)
- Dashboard user → Dashboard settings: configures dashboard (evidence: `README.md`)
- Dashboard settings → Session auth: requires login (evidence: `settings.php`)
- Dashboard settings → Local JSON state: saves settings and cron credentials (evidence: `settings.php`)
- Router and domain logic → Local JSON state: tracks usage state (evidence: `includes/functions.php`)
- Scheduled checks → Local JSON state: loads cron credentials (evidence: `cron.php`)
- Scheduled checks → Router and domain logic: runs scheduled checks (evidence: `cron.php`)
- Scheduled checks → Telegram notifications: sends alerts
- Router and domain logic → Router usage categories: reads router counters
- Dashboard view → Offline app shell: registers service worker (evidence: `index.php`)
