# leandrosalvas/csserver_wstats architecture

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

- Interactive diagram: https://gitdiagram.com/leandrosalvas/csserver_wstats
- Repository: https://github.com/leandrosalvas/csserver_wstats

## Overview

CS Server Stats combines a multi-server Counter-Strike 1.6 statistics service with a web dashboard. Players and administrators use the dashboard to view live status, rankings, player and match history, and manage servers; the browser reaches an Express API, which serves domain routes backed by MySQL, Redis, and game-server queries. Authentication and monitoring are additional branches. The README documents several capabilities whose implementation files were not sampled; those are represented at the subsystem level, and links are limited to documented or excerpted relationships.

Main entry points: [`api/index.js`](https://github.com/leandrosalvas/csserver_wstats/blob/main/api/index.js) (Express API), [`api/lib/core.js`](https://github.com/leandrosalvas/csserver_wstats/blob/main/api/lib/core.js) (Service aggregator), [`web/admin.js`](https://github.com/leandrosalvas/csserver_wstats/blob/main/web/admin.js) (Admin controls), [`api/lib/routes/rankings.js`](https://github.com/leandrosalvas/csserver_wstats/blob/main/api/lib/routes/rankings.js) (Rankings and stats)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web dashboard"]
  node_dashboard["Dashboard shell<br/>[app.js]"]
  node_shared_ui["Shared UI<br/>[common.js]"]
  node_ranking_ui["Rankings and maps<br/>[rankings.js]"]
  node_player_ui["Player profiles<br/>[player.js]"]
  node_live_ui["Live scoreboard<br/>[live.js]"]
  node_match_ui["Match history<br/>[matches.js]"]
  node_admin_ui["Admin controls<br/>[admin.js]"]
  node_server_ui["Server management<br/>[servers.js]"]
  node_system_ui["System status<br/>[system.js]"]
  node_login_ui["Login UI<br/>[login.js]"]
end

subgraph group_api["API and domain services"]
  node_api_entry["Express API<br/>[index.js]"]
  node_route_rankings["Rankings and stats<br/>[rankings.js]"]
  node_route_top["Top statistics<br/>[top.js]"]
  node_route_matches["Match tracking<br/>[matches.js]"]
  node_route_live["Live endpoints<br/>[live.js]"]
  node_route_auth["Authentication routes<br/>[auth.js]"]
  node_route_admin["Admin routes<br/>[admin.js]"]
  node_route_admin_servers["Server controls<br/>[adminServers.js]"]
  node_route_admin_users["User administration<br/>[adminUsers.js]"]
  node_route_system["System routes<br/>[system.js]"]
  node_core["Service aggregator<br/>[core.js]"]
  node_auth["Identity and RBAC<br/>[auth.js]"]
  node_server_manager["Server manager<br/>[serverManager.js]"]
  node_config["Runtime configuration<br/>[config.js]"]
end

subgraph group_state["Data and live state"]
  node_server_context["Server state and polling<br/>[serverCtx.js]"]
  node_live_service["Live data service<br/>[live.js]"]
  node_database[("Statistics database<br/>[db.js]")]
  node_cache[("Cache and sessions<br/>[cache.js]")]
end

subgraph group_ops["Operations and integrations"]
  node_metrics["Prometheus metrics<br/>[metrics.js]"]
  node_alerts["Status alerts<br/>[alerts.js]"]
  node_discord["Discord bot<br/>[discordBot.js]"]
end

node_players(("Players and admins"))
node_game_servers["CS game servers"]
node_mariadb[("MariaDB")]

node_players -->|"uses"| node_dashboard
node_dashboard -->|"requests data"| node_api_entry
node_api_entry -->|"registers"| node_route_rankings
node_api_entry -->|"registers"| node_route_top
node_api_entry -->|"registers"| node_route_system
node_api_entry -->|"registers"| node_route_auth
node_api_entry -->|"registers"| node_route_admin
node_api_entry -->|"registers"| node_route_admin_servers
node_api_entry -->|"registers"| node_route_admin_users
node_api_entry -->|"registers"| node_route_matches
node_api_entry -->|"registers"| node_route_live
node_api_entry -->|"initializes services"| node_core
node_route_rankings -->|"queries"| node_database
node_route_rankings -->|"caches results"| node_cache
node_core -->|"imports"| node_server_context
node_core -->|"imports"| node_live_service
node_core -->|"imports"| node_auth
node_core -->|"imports"| node_server_manager
node_core -->|"imports"| node_database
node_core -->|"imports"| node_cache
node_core -->|"imports"| node_metrics
node_server_context -->|"reads and writes"| node_database
node_server_context -->|"queries status"| node_game_servers
node_players -->|"signs in"| node_login_ui
node_login_ui -->|"authenticates via"| node_route_auth
node_players -->|"manages"| node_admin_ui
node_admin_ui -->|"uses controls"| node_route_admin_servers
node_admin_ui -->|"administers users"| node_route_admin_users
node_players -->|"views rankings"| node_ranking_ui
node_players -->|"views profiles"| node_player_ui
node_players -->|"views live play"| node_live_ui
node_players -->|"views matches"| node_match_ui
node_players -->|"manages servers"| node_server_ui
node_players -->|"views monitoring"| node_system_ui
node_api_entry -->|"starts bot"| node_discord
node_server_manager -->|"controls containers"| node_game_servers
node_api_entry -->|"exposes metrics"| node_metrics
node_alerts -.->|"sends alerts"| node_players
node_auth -.->|"persists users"| node_mariadb

click node_dashboard "https://github.com/leandrosalvas/csserver_wstats/blob/main/web/app.js"
click node_shared_ui "https://github.com/leandrosalvas/csserver_wstats/blob/main/web/common.js"
click node_ranking_ui "https://github.com/leandrosalvas/csserver_wstats/blob/main/web/rankings.js"
click node_player_ui "https://github.com/leandrosalvas/csserver_wstats/blob/main/web/player.js"
click node_live_ui "https://github.com/leandrosalvas/csserver_wstats/blob/main/web/live.js"
click node_match_ui "https://github.com/leandrosalvas/csserver_wstats/blob/main/web/matches.js"
click node_admin_ui "https://github.com/leandrosalvas/csserver_wstats/blob/main/web/admin.js"
click node_server_ui "https://github.com/leandrosalvas/csserver_wstats/blob/main/web/servers.js"
click node_system_ui "https://github.com/leandrosalvas/csserver_wstats/blob/main/web/system.js"
click node_login_ui "https://github.com/leandrosalvas/csserver_wstats/blob/main/web/login.js"
click node_api_entry "https://github.com/leandrosalvas/csserver_wstats/blob/main/api/index.js"
click node_route_rankings "https://github.com/leandrosalvas/csserver_wstats/blob/main/api/lib/routes/rankings.js"
click node_route_top "https://github.com/leandrosalvas/csserver_wstats/blob/main/api/lib/routes/top.js"
click node_route_matches "https://github.com/leandrosalvas/csserver_wstats/blob/main/api/lib/routes/matches.js"
click node_route_live "https://github.com/leandrosalvas/csserver_wstats/blob/main/api/lib/routes/live.js"
click node_route_auth "https://github.com/leandrosalvas/csserver_wstats/blob/main/api/lib/routes/auth.js"
click node_route_admin "https://github.com/leandrosalvas/csserver_wstats/blob/main/api/lib/routes/admin.js"
click node_route_admin_servers "https://github.com/leandrosalvas/csserver_wstats/blob/main/api/lib/routes/adminServers.js"
click node_route_admin_users "https://github.com/leandrosalvas/csserver_wstats/blob/main/api/lib/routes/adminUsers.js"
click node_route_system "https://github.com/leandrosalvas/csserver_wstats/blob/main/api/lib/routes/system.js"
click node_core "https://github.com/leandrosalvas/csserver_wstats/blob/main/api/lib/core.js"
click node_auth "https://github.com/leandrosalvas/csserver_wstats/blob/main/api/lib/auth.js"
click node_server_manager "https://github.com/leandrosalvas/csserver_wstats/blob/main/api/lib/serverManager.js"
click node_server_context "https://github.com/leandrosalvas/csserver_wstats/blob/main/api/lib/serverCtx.js"
click node_live_service "https://github.com/leandrosalvas/csserver_wstats/blob/main/api/lib/live.js"
click node_database "https://github.com/leandrosalvas/csserver_wstats/blob/main/api/lib/db.js"
click node_cache "https://github.com/leandrosalvas/csserver_wstats/blob/main/api/lib/cache.js"
click node_config "https://github.com/leandrosalvas/csserver_wstats/blob/main/api/lib/config.js"
click node_metrics "https://github.com/leandrosalvas/csserver_wstats/blob/main/api/lib/metrics.js"
click node_alerts "https://github.com/leandrosalvas/csserver_wstats/blob/main/api/lib/alerts.js"
click node_discord "https://github.com/leandrosalvas/csserver_wstats/blob/main/api/lib/discordBot.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_dashboard,node_shared_ui,node_ranking_ui,node_player_ui,node_live_ui,node_match_ui,node_admin_ui,node_server_ui,node_system_ui,node_login_ui toneBlue
class node_api_entry,node_route_rankings,node_route_top,node_route_matches,node_route_live,node_route_auth,node_route_admin,node_route_admin_servers,node_route_admin_users,node_route_system,node_core,node_auth,node_server_manager,node_config,node_mariadb toneAmber
class node_server_context,node_live_service,node_database,node_cache,node_game_servers toneMint
class node_metrics,node_alerts,node_discord toneRose
class node_players toneIndigo
```

## Components

### Web dashboard

- [Dashboard shell](https://github.com/leandrosalvas/csserver_wstats/blob/main/web/app.js): `web/app.js`
- [Shared UI](https://github.com/leandrosalvas/csserver_wstats/blob/main/web/common.js): `web/common.js`
- [Rankings and maps](https://github.com/leandrosalvas/csserver_wstats/blob/main/web/rankings.js): `web/rankings.js`
- [Player profiles](https://github.com/leandrosalvas/csserver_wstats/blob/main/web/player.js): `web/player.js`
- [Live scoreboard](https://github.com/leandrosalvas/csserver_wstats/blob/main/web/live.js): `web/live.js`
- [Match history](https://github.com/leandrosalvas/csserver_wstats/blob/main/web/matches.js): `web/matches.js`
- [Admin controls](https://github.com/leandrosalvas/csserver_wstats/blob/main/web/admin.js): `web/admin.js`
- [Server management](https://github.com/leandrosalvas/csserver_wstats/blob/main/web/servers.js): `web/servers.js`
- [System status](https://github.com/leandrosalvas/csserver_wstats/blob/main/web/system.js): `web/system.js`
- [Login UI](https://github.com/leandrosalvas/csserver_wstats/blob/main/web/login.js): `web/login.js`

### API and domain services

- [Express API](https://github.com/leandrosalvas/csserver_wstats/blob/main/api/index.js): `api/index.js`
- [Rankings and stats](https://github.com/leandrosalvas/csserver_wstats/blob/main/api/lib/routes/rankings.js): `api/lib/routes/rankings.js`
- [Top statistics](https://github.com/leandrosalvas/csserver_wstats/blob/main/api/lib/routes/top.js): `api/lib/routes/top.js`
- [Match tracking](https://github.com/leandrosalvas/csserver_wstats/blob/main/api/lib/routes/matches.js): `api/lib/routes/matches.js`
- [Live endpoints](https://github.com/leandrosalvas/csserver_wstats/blob/main/api/lib/routes/live.js): `api/lib/routes/live.js`
- [Authentication routes](https://github.com/leandrosalvas/csserver_wstats/blob/main/api/lib/routes/auth.js): `api/lib/routes/auth.js`
- [Admin routes](https://github.com/leandrosalvas/csserver_wstats/blob/main/api/lib/routes/admin.js): `api/lib/routes/admin.js`
- [Server controls](https://github.com/leandrosalvas/csserver_wstats/blob/main/api/lib/routes/adminServers.js): `api/lib/routes/adminServers.js`
- [User administration](https://github.com/leandrosalvas/csserver_wstats/blob/main/api/lib/routes/adminUsers.js): `api/lib/routes/adminUsers.js`
- [System routes](https://github.com/leandrosalvas/csserver_wstats/blob/main/api/lib/routes/system.js): `api/lib/routes/system.js`
- [Service aggregator](https://github.com/leandrosalvas/csserver_wstats/blob/main/api/lib/core.js): `api/lib/core.js`
- [Identity and RBAC](https://github.com/leandrosalvas/csserver_wstats/blob/main/api/lib/auth.js): `api/lib/auth.js`
- [Server manager](https://github.com/leandrosalvas/csserver_wstats/blob/main/api/lib/serverManager.js): `api/lib/serverManager.js`
- [Runtime configuration](https://github.com/leandrosalvas/csserver_wstats/blob/main/api/lib/config.js): `api/lib/config.js`

### Data and live state

- [Server state and polling](https://github.com/leandrosalvas/csserver_wstats/blob/main/api/lib/serverCtx.js): `api/lib/serverCtx.js`
- [Live data service](https://github.com/leandrosalvas/csserver_wstats/blob/main/api/lib/live.js): `api/lib/live.js`
- [Statistics database](https://github.com/leandrosalvas/csserver_wstats/blob/main/api/lib/db.js): `api/lib/db.js`
- [Cache and sessions](https://github.com/leandrosalvas/csserver_wstats/blob/main/api/lib/cache.js): `api/lib/cache.js`

### Operations and integrations

- [Prometheus metrics](https://github.com/leandrosalvas/csserver_wstats/blob/main/api/lib/metrics.js): `api/lib/metrics.js`
- [Status alerts](https://github.com/leandrosalvas/csserver_wstats/blob/main/api/lib/alerts.js): `api/lib/alerts.js`
- [Discord bot](https://github.com/leandrosalvas/csserver_wstats/blob/main/api/lib/discordBot.js): `api/lib/discordBot.js`

### Other components

- **Players and admins**
- **CS game servers**
- **MariaDB**

## Connections

- Players and admins → Dashboard shell: uses (evidence: `README.md`)
- Dashboard shell → Express API: requests data (evidence: `README.md`)
- Express API → Rankings and stats: registers (evidence: `api/index.js`)
- Express API → Top statistics: registers (evidence: `api/index.js`)
- Express API → System routes: registers (evidence: `api/index.js`)
- Express API → Authentication routes: registers (evidence: `api/index.js`)
- Express API → Admin routes: registers (evidence: `api/index.js`)
- Express API → Server controls: registers (evidence: `api/index.js`)
- Express API → User administration: registers (evidence: `api/index.js`)
- Express API → Match tracking: registers (evidence: `api/index.js`)
- Express API → Live endpoints: registers (evidence: `api/index.js`)
- Express API → Service aggregator: initializes services (evidence: `api/index.js`)
- Rankings and stats → Statistics database: queries (evidence: `api/lib/routes/rankings.js`)
- Rankings and stats → Cache and sessions: caches results (evidence: `api/lib/routes/rankings.js`)
- Service aggregator → Server state and polling: imports (evidence: `api/lib/core.js`)
- Service aggregator → Live data service: imports (evidence: `api/lib/core.js`)
- Service aggregator → Identity and RBAC: imports (evidence: `api/lib/core.js`)
- Service aggregator → Server manager: imports (evidence: `api/lib/core.js`)
- Service aggregator → Statistics database: imports (evidence: `api/lib/core.js`)
- Service aggregator → Cache and sessions: imports (evidence: `api/lib/core.js`)
- Service aggregator → Prometheus metrics: imports (evidence: `api/lib/core.js`)
- Server state and polling → Statistics database: reads and writes (evidence: `api/lib/serverCtx.js`)
- Server state and polling → CS game servers: queries status (evidence: `api/lib/serverCtx.js`)
- Players and admins → Login UI: signs in (evidence: `README.md`)
- Login UI → Authentication routes: authenticates via (evidence: `README.md`)
- Players and admins → Admin controls: manages (evidence: `README.md`)
- Admin controls → Server controls: uses controls (evidence: `README.md`)
- Admin controls → User administration: administers users (evidence: `README.md`)
- Players and admins → Rankings and maps: views rankings (evidence: `README.md`)
- Players and admins → Player profiles: views profiles (evidence: `README.md`)
- Players and admins → Live scoreboard: views live play (evidence: `README.md`)
- Players and admins → Match history: views matches (evidence: `README.md`)
- Players and admins → Server management: manages servers (evidence: `README.md`)
- Players and admins → System status: views monitoring (evidence: `README.md`)
- Express API → Discord bot: starts bot (evidence: `api/index.js`)
- Server manager → CS game servers: controls containers (evidence: `api/lib/serverManager.js`)
- Express API → Prometheus metrics: exposes metrics (evidence: `README.md`)
- Status alerts → Players and admins: sends alerts (evidence: `README.md`)
- Identity and RBAC → MariaDB: persists users (evidence: `api/lib/auth.js`)
