# magomedmirza/zhaamon architecture

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

- Interactive diagram: https://gitdiagram.com/magomedmirza/zhaamon
- Repository: https://github.com/magomedmirza/zhaamon

## Overview

ZhaaMon is a local Android/desktop MikroTik hotspot manager. Users select a router, navigate management pages, and make requests to the local server; backend capabilities manage router configuration and hotspot activity through RouterOS, while router configuration is stored locally. The graph preserves documented feature areas even where their implementations were not sampled. Relationships are limited to those visible in excerpts or explicitly documented; unsampled handler and service internals are represented without guessed call chains.

Main entry points: [`src/routes.rs`](https://github.com/magomedmirza/zhaamon/blob/main/src/routes.rs) (HTTP routes), [`static/js/app.js`](https://github.com/magomedmirza/zhaamon/blob/main/static/js/app.js) (Browser / WebView), [`src/store/router_repo.rs`](https://github.com/magomedmirza/zhaamon/blob/main/src/store/router_repo.rs) (Router repository), [`src/mikrotik/client.rs`](https://github.com/magomedmirza/zhaamon/blob/main/src/mikrotik/client.rs) (RouterOS client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web client"]
  node_webview["Browser / WebView<br/>[app.js]"]
  node_navigation["Routes and navigation<br/>[routes.js]"]
  node_ui_core["UI and shared state<br/>[dom.js]"]
  node_api_client["HTTP API client<br/>[api.js]"]
  node_router_pages["Router selection<br/>[routers.js]"]
  node_management_pages["Hotspot pages<br/>[routes.js]"]
  node_system_pages["System pages<br/>[ntp-client.js]"]
  node_localization["Localization<br/>[index.js]"]
  node_android_bridge["Android bridge<br/>[bridge.js]"]
end

subgraph group_server["HTTP server"]
  node_server_entry["Server entry<br/>[main.rs]"]
  node_http_routes["HTTP routes<br/>[routes.rs]"]
  node_error_handling["Error responses<br/>[mod.rs]"]
end

subgraph group_domain["Management features"]
  node_router_handlers["Router management<br/>[routers.rs]"]
  node_hotspot_handlers["Hotspot devices"]
  node_profile_handlers["Profiles and vouchers"]
  node_user_handlers["Users and sessions"]
  node_system_handlers["System automation"]
  node_ntp_handlers["NTP management"]
  node_services["Domain services"]
end

subgraph group_router["Router integration"]
  node_routeros_client["RouterOS client<br/>[client.rs]"]
  node_routeros_records["Protocol records<br/>[record.rs]"]
  node_routeros_stream["Transport stream<br/>[stream.rs]"]
end

subgraph group_storage["Local storage"]
  node_router_store[("Router repository<br/>[router_repo.rs]")]
  node_store_files["File persistence<br/>[files.rs]"]
  node_store_atomic["Atomic writes<br/>[atomic.rs]"]
  node_store_model["Router data model<br/>[model.rs]"]
  node_store_validation["Input validation<br/>[validation.rs]"]
end

node_operator(("Device user"))
node_routeros{{"MikroTik router"}}

node_operator -->|"uses"| node_webview
node_webview -->|"boots routes"| node_navigation
node_webview -->|"loads routers"| node_router_pages
node_navigation -->|"registers pages"| node_management_pages
node_navigation -->|"registers pages"| node_system_pages
node_management_pages -.->|"requests data"| node_api_client
node_system_pages -->|"requests data"| node_api_client
node_router_pages -->|"requests routers"| node_api_client
node_webview -->|"initializes locale"| node_localization
node_webview -.->|"uses native bridge"| node_android_bridge
node_webview -->|"fetches local API"| node_http_routes
node_server_entry -.->|"serves routes"| node_http_routes
node_http_routes -->|"routes requests"| node_router_handlers
node_http_routes -->|"routes requests"| node_hotspot_handlers
node_http_routes -->|"routes requests"| node_profile_handlers
node_http_routes -->|"routes requests"| node_user_handlers
node_http_routes -->|"routes requests"| node_system_handlers
node_http_routes -->|"routes requests"| node_ntp_handlers
node_router_handlers -.->|"delegates operations"| node_services
node_services -->|"uses API client"| node_routeros_client
node_routeros_client -->|"transfers sentences"| node_routeros_stream
node_routeros_client -->|"parses records"| node_routeros_records
node_routeros_client -.->|"sends commands"| node_routeros
node_services -->|"reads router data"| node_router_store
node_router_store -->|"loads router file"| node_store_files
node_router_store -->|"persists updates"| node_store_atomic
node_router_store -->|"uses models"| node_store_model
node_router_store -->|"validates input"| node_store_validation

click node_webview "https://github.com/magomedmirza/zhaamon/blob/main/static/js/app.js"
click node_navigation "https://github.com/magomedmirza/zhaamon/blob/main/static/js/routes.js"
click node_ui_core "https://github.com/magomedmirza/zhaamon/blob/main/static/js/dom.js"
click node_api_client "https://github.com/magomedmirza/zhaamon/blob/main/static/js/api.js"
click node_router_pages "https://github.com/magomedmirza/zhaamon/blob/main/static/js/routers.js"
click node_management_pages "https://github.com/magomedmirza/zhaamon/blob/main/static/js/routes.js"
click node_system_pages "https://github.com/magomedmirza/zhaamon/blob/main/static/js/pages/ntp-client.js"
click node_localization "https://github.com/magomedmirza/zhaamon/blob/main/static/js/i18n/index.js"
click node_android_bridge "https://github.com/magomedmirza/zhaamon/blob/main/static/bridge.js"
click node_server_entry "https://github.com/magomedmirza/zhaamon/blob/main/src/main.rs"
click node_http_routes "https://github.com/magomedmirza/zhaamon/blob/main/src/routes.rs"
click node_error_handling "https://github.com/magomedmirza/zhaamon/blob/main/src/error/mod.rs"
click node_router_handlers "https://github.com/magomedmirza/zhaamon/blob/main/src/handlers/routers.rs"
click node_hotspot_handlers "https://github.com/magomedmirza/zhaamon/tree/main/src/handlers/devices"
click node_profile_handlers "https://github.com/magomedmirza/zhaamon/tree/main/src/handlers/profiles"
click node_user_handlers "https://github.com/magomedmirza/zhaamon/tree/main/src/handlers/users"
click node_system_handlers "https://github.com/magomedmirza/zhaamon/tree/main/src/handlers/system"
click node_ntp_handlers "https://github.com/magomedmirza/zhaamon/tree/main/src/handlers/ntp"
click node_services "https://github.com/magomedmirza/zhaamon/tree/main/src/services"
click node_routeros_client "https://github.com/magomedmirza/zhaamon/blob/main/src/mikrotik/client.rs"
click node_routeros_records "https://github.com/magomedmirza/zhaamon/blob/main/src/mikrotik/record.rs"
click node_routeros_stream "https://github.com/magomedmirza/zhaamon/blob/main/src/mikrotik/stream.rs"
click node_router_store "https://github.com/magomedmirza/zhaamon/blob/main/src/store/router_repo.rs"
click node_store_files "https://github.com/magomedmirza/zhaamon/blob/main/src/store/files.rs"
click node_store_atomic "https://github.com/magomedmirza/zhaamon/blob/main/src/store/atomic.rs"
click node_store_model "https://github.com/magomedmirza/zhaamon/blob/main/src/store/model.rs"
click node_store_validation "https://github.com/magomedmirza/zhaamon/blob/main/src/store/validation.rs"

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_webview,node_navigation,node_ui_core,node_api_client,node_router_pages,node_management_pages,node_system_pages,node_localization,node_android_bridge,node_operator toneBlue
class node_server_entry,node_http_routes,node_error_handling toneAmber
class node_router_handlers,node_hotspot_handlers,node_profile_handlers,node_user_handlers,node_system_handlers,node_ntp_handlers,node_services,node_routeros toneMint
class node_routeros_client,node_routeros_records,node_routeros_stream toneRose
class node_router_store,node_store_files,node_store_atomic,node_store_model,node_store_validation toneIndigo
```

## Components

### Web client

- [Browser / WebView](https://github.com/magomedmirza/zhaamon/blob/main/static/js/app.js): `static/js/app.js`
- [Routes and navigation](https://github.com/magomedmirza/zhaamon/blob/main/static/js/routes.js): `static/js/routes.js`
- [UI and shared state](https://github.com/magomedmirza/zhaamon/blob/main/static/js/dom.js): `static/js/dom.js`
- [HTTP API client](https://github.com/magomedmirza/zhaamon/blob/main/static/js/api.js): `static/js/api.js`
- [Router selection](https://github.com/magomedmirza/zhaamon/blob/main/static/js/routers.js): `static/js/routers.js`
- [Hotspot pages](https://github.com/magomedmirza/zhaamon/blob/main/static/js/routes.js): `static/js/routes.js`
- [System pages](https://github.com/magomedmirza/zhaamon/blob/main/static/js/pages/ntp-client.js): `static/js/pages/ntp-client.js`
- [Localization](https://github.com/magomedmirza/zhaamon/blob/main/static/js/i18n/index.js): `static/js/i18n/index.js`
- [Android bridge](https://github.com/magomedmirza/zhaamon/blob/main/static/bridge.js): `static/bridge.js`

### HTTP server

- [Server entry](https://github.com/magomedmirza/zhaamon/blob/main/src/main.rs): `src/main.rs`
- [HTTP routes](https://github.com/magomedmirza/zhaamon/blob/main/src/routes.rs): `src/routes.rs`
- [Error responses](https://github.com/magomedmirza/zhaamon/blob/main/src/error/mod.rs): `src/error/mod.rs`

### Management features

- [Router management](https://github.com/magomedmirza/zhaamon/blob/main/src/handlers/routers.rs): `src/handlers/routers.rs`
- [Hotspot devices](https://github.com/magomedmirza/zhaamon/tree/main/src/handlers/devices): `src/handlers/devices`
- [Profiles and vouchers](https://github.com/magomedmirza/zhaamon/tree/main/src/handlers/profiles): `src/handlers/profiles`
- [Users and sessions](https://github.com/magomedmirza/zhaamon/tree/main/src/handlers/users): `src/handlers/users`
- [System automation](https://github.com/magomedmirza/zhaamon/tree/main/src/handlers/system): `src/handlers/system`
- [NTP management](https://github.com/magomedmirza/zhaamon/tree/main/src/handlers/ntp): `src/handlers/ntp`
- [Domain services](https://github.com/magomedmirza/zhaamon/tree/main/src/services): `src/services`

### Router integration

- [RouterOS client](https://github.com/magomedmirza/zhaamon/blob/main/src/mikrotik/client.rs): `src/mikrotik/client.rs`
- [Protocol records](https://github.com/magomedmirza/zhaamon/blob/main/src/mikrotik/record.rs): `src/mikrotik/record.rs`
- [Transport stream](https://github.com/magomedmirza/zhaamon/blob/main/src/mikrotik/stream.rs): `src/mikrotik/stream.rs`

### Local storage

- [Router repository](https://github.com/magomedmirza/zhaamon/blob/main/src/store/router_repo.rs): `src/store/router_repo.rs`
- [File persistence](https://github.com/magomedmirza/zhaamon/blob/main/src/store/files.rs): `src/store/files.rs`
- [Atomic writes](https://github.com/magomedmirza/zhaamon/blob/main/src/store/atomic.rs): `src/store/atomic.rs`
- [Router data model](https://github.com/magomedmirza/zhaamon/blob/main/src/store/model.rs): `src/store/model.rs`
- [Input validation](https://github.com/magomedmirza/zhaamon/blob/main/src/store/validation.rs): `src/store/validation.rs`

### Other components

- **Device user**
- **MikroTik router**

## Connections

- Device user → Browser / WebView: uses (evidence: `README.md`)
- Browser / WebView → Routes and navigation: boots routes (evidence: `static/js/app.js`)
- Browser / WebView → Router selection: loads routers (evidence: `static/js/app.js`)
- Routes and navigation → Hotspot pages: registers pages (evidence: `static/js/routes.js`)
- Routes and navigation → System pages: registers pages (evidence: `static/js/routes.js`)
- Hotspot pages → HTTP API client: requests data
- System pages → HTTP API client: requests data (evidence: `static/js/pages/ntp-client.js`)
- Router selection → HTTP API client: requests routers (evidence: `static/js/pages/routers.js`)
- Browser / WebView → Localization: initializes locale (evidence: `static/js/app.js`)
- Browser / WebView → Android bridge: uses native bridge (evidence: `README.md`)
- Browser / WebView → HTTP routes: fetches local API
- Server entry → HTTP routes: serves routes
- HTTP routes → Router management: routes requests (evidence: `src/routes.rs`)
- HTTP routes → Hotspot devices: routes requests (evidence: `src/routes.rs`)
- HTTP routes → Profiles and vouchers: routes requests (evidence: `src/routes.rs`)
- HTTP routes → Users and sessions: routes requests (evidence: `src/routes.rs`)
- HTTP routes → System automation: routes requests (evidence: `src/routes.rs`)
- HTTP routes → NTP management: routes requests (evidence: `src/routes.rs`)
- Router management → Domain services: delegates operations
- Domain services → RouterOS client: uses API client (evidence: `src/services/router_ops.rs`)
- RouterOS client → Transport stream: transfers sentences (evidence: `src/mikrotik/client.rs`)
- RouterOS client → Protocol records: parses records (evidence: `src/mikrotik/client.rs`)
- RouterOS client → MikroTik router: sends commands
- Domain services → Router repository: reads router data (evidence: `src/services/routers.rs`)
- Router repository → File persistence: loads router file (evidence: `src/store/router_repo.rs`)
- Router repository → Atomic writes: persists updates (evidence: `src/store/router_repo.rs`)
- Router repository → Router data model: uses models (evidence: `src/store/router_repo.rs`)
- Router repository → Input validation: validates input (evidence: `src/store/router_repo.rs`)
