# tdung1807/minecraft-server-online-check architecture

> Architecture diagram of the GitHub repository tdung1807/minecraft-server-online-check, 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/tdung1807/minecraft-server-online-check
- Repository: https://github.com/tdung1807/minecraft-server-online-check

## Overview

Minecraft Monitor polls one configured Minecraft Java server, keeps a current in-memory snapshot, and serves it to a browser through REST and SSE. The browser also has a polling fallback and displays live player information. A separate listener exposes readiness and Prometheus metrics. The README documents a separately deployed GitHub Pages frontend as well as the embedded frontend; deployment mechanics are omitted. Relationships are based on the shown source and README; unsampled deployment details are not inferred.

Main entry points: [`cmd/server/main.go`](https://github.com/tdung1807/minecraft-server-online-check/blob/main/cmd/server/main.go) (Server bootstrap), [`internal/httpapi/server.go`](https://github.com/tdung1807/minecraft-server-online-check/blob/main/internal/httpapi/server.go) (REST and SSE API), [`internal/monitor/store.go`](https://github.com/tdung1807/minecraft-server-online-check/blob/main/internal/monitor/store.go) (Poller and state transitions), [`internal/minecraft/client.go`](https://github.com/tdung1807/minecraft-server-online-check/blob/main/internal/minecraft/client.go) (Status ping client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Startup and configuration"]
  node_config["Runtime configuration<br/>[config.go]"]
  node_server["Server bootstrap<br/>[main.go]"]
end

subgraph group_polling["Minecraft polling"]
  node_poller["Poller and state transitions<br/>[store.go]"]
  node_minecraft_client["Status ping client<br/>[client.go]"]
  node_snapshot_store[("Snapshot and subscribers<br/>[store.go]")]
end

subgraph group_api["HTTP and monitoring"]
  node_http_api["REST and SSE API<br/>[server.go]"]
  node_metrics["Metrics endpoint<br/>[server.go]"]
end

subgraph group_frontend["Browser interface"]
  node_web_assets["Embedded web assets<br/>[index.html]"]
  node_browser_app["Live status interface<br/>[app.js]"]
end

node_operator(("Website visitor"))
node_minecraft_server{{"Minecraft server"}}
node_scraper(("Metrics scraper"))

node_operator -->|"views"| node_browser_app
node_config -->|"configures"| node_server
node_server -->|"starts"| node_poller
node_server -->|"configures"| node_minecraft_client
node_server -->|"serves HTTP"| node_http_api
node_server -->|"serves metrics"| node_metrics
node_poller -->|"queries"| node_minecraft_client
node_minecraft_client -->|"TCP status ping"| node_minecraft_server
node_poller -->|"records results"| node_snapshot_store
node_http_api -->|"reads and subscribes"| node_snapshot_store
node_http_api -->|"serves embedded"| node_web_assets
node_browser_app -->|"fetches and streams"| node_http_api
node_scraper -.->|"scrapes"| node_metrics

click node_config "https://github.com/tdung1807/minecraft-server-online-check/blob/main/internal/config/config.go"
click node_server "https://github.com/tdung1807/minecraft-server-online-check/blob/main/cmd/server/main.go"
click node_poller "https://github.com/tdung1807/minecraft-server-online-check/blob/main/internal/monitor/store.go"
click node_minecraft_client "https://github.com/tdung1807/minecraft-server-online-check/blob/main/internal/minecraft/client.go"
click node_snapshot_store "https://github.com/tdung1807/minecraft-server-online-check/blob/main/internal/monitor/store.go"
click node_http_api "https://github.com/tdung1807/minecraft-server-online-check/blob/main/internal/httpapi/server.go"
click node_metrics "https://github.com/tdung1807/minecraft-server-online-check/blob/main/internal/httpapi/server.go"
click node_web_assets "https://github.com/tdung1807/minecraft-server-online-check/blob/main/internal/httpapi/web/index.html"
click node_browser_app "https://github.com/tdung1807/minecraft-server-online-check/blob/main/internal/httpapi/web/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_config,node_server toneBlue
class node_poller,node_minecraft_client,node_snapshot_store toneAmber
class node_http_api,node_metrics,node_minecraft_server toneMint
class node_web_assets,node_browser_app toneRose
class node_operator,node_scraper toneIndigo
```

## Components

### Startup and configuration

- [Runtime configuration](https://github.com/tdung1807/minecraft-server-online-check/blob/main/internal/config/config.go): `internal/config/config.go`
- [Server bootstrap](https://github.com/tdung1807/minecraft-server-online-check/blob/main/cmd/server/main.go): `cmd/server/main.go`

### Minecraft polling

- [Poller and state transitions](https://github.com/tdung1807/minecraft-server-online-check/blob/main/internal/monitor/store.go): `internal/monitor/store.go`
- [Status ping client](https://github.com/tdung1807/minecraft-server-online-check/blob/main/internal/minecraft/client.go): `internal/minecraft/client.go`
- [Snapshot and subscribers](https://github.com/tdung1807/minecraft-server-online-check/blob/main/internal/monitor/store.go): `internal/monitor/store.go`

### HTTP and monitoring

- [REST and SSE API](https://github.com/tdung1807/minecraft-server-online-check/blob/main/internal/httpapi/server.go): `internal/httpapi/server.go`
- [Metrics endpoint](https://github.com/tdung1807/minecraft-server-online-check/blob/main/internal/httpapi/server.go): `internal/httpapi/server.go`

### Browser interface

- [Embedded web assets](https://github.com/tdung1807/minecraft-server-online-check/blob/main/internal/httpapi/web/index.html): `internal/httpapi/web/index.html`
- [Live status interface](https://github.com/tdung1807/minecraft-server-online-check/blob/main/internal/httpapi/web/app.js): `internal/httpapi/web/app.js`

### Other components

- **Website visitor**
- **Minecraft server**
- **Metrics scraper**

## Connections

- Website visitor → Live status interface: views (evidence: `README.md`)
- Runtime configuration → Server bootstrap: configures (evidence: `cmd/server/main.go`)
- Server bootstrap → Poller and state transitions: starts (evidence: `cmd/server/main.go`)
- Server bootstrap → Status ping client: configures (evidence: `cmd/server/main.go`)
- Server bootstrap → REST and SSE API: serves HTTP (evidence: `cmd/server/main.go`)
- Server bootstrap → Metrics endpoint: serves metrics (evidence: `cmd/server/main.go`)
- Poller and state transitions → Status ping client: queries (evidence: `internal/monitor/store.go`)
- Status ping client → Minecraft server: TCP status ping (evidence: `internal/minecraft/client.go`)
- Poller and state transitions → Snapshot and subscribers: records results (evidence: `internal/monitor/store.go`)
- REST and SSE API → Snapshot and subscribers: reads and subscribes (evidence: `internal/httpapi/server.go`)
- REST and SSE API → Embedded web assets: serves embedded (evidence: `internal/httpapi/server.go`)
- Live status interface → REST and SSE API: fetches and streams (evidence: `internal/httpapi/web/app.js`)
- Metrics scraper → Metrics endpoint: scrapes (evidence: `README.md`)
