# sti-233/localserverkt architecture

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

- Interactive diagram: https://gitdiagram.com/sti-233/localserverkt
- Repository: https://github.com/sti-233/localserverkt

## Overview

LocalServerKt is a Ktor-based LAN server offering authenticated chat and AI, administrative controls, file browsing, music and video search, and a browser/download proxy. The main flow is a client request entering the server, passing realm checks where required, reaching a feature route, and receiving a page, API response, stream, or file. The graph preserves the README’s major capabilities; several routes and integrations are documented but their implementation excerpts were not provided, so those relationships are shown only when supported by the README or source index.

Main entry points: [`src/main/kotlin/localserver/Server.kt`](https://github.com/sti-233/localserverkt/blob/main/src/main/kotlin/localserver/Server.kt) (Ktor server), [`src/main/kotlin/localserver/module/Chat.kt`](https://github.com/sti-233/localserverkt/blob/main/src/main/kotlin/localserver/module/Chat.kt) (Chat routes), [`src/main/kotlin/localserver/module/Ai.kt`](https://github.com/sti-233/localserverkt/blob/main/src/main/kotlin/localserver/module/Ai.kt) (AI routes), [`src/main/kotlin/localserver/utils/Network.kt`](https://github.com/sti-233/localserverkt/blob/main/src/main/kotlin/localserver/utils/Network.kt) (Browser and download)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Server and access"]
  node_server["Ktor server<br/>[Server.kt]"]
  node_auth["Access realms<br/>[Server.kt]"]
end

subgraph group_collaboration["Chat and AI"]
  node_chat["Chat routes<br/>[Chat.kt]"]
  node_chatui["Chat page<br/>[chat.html]"]
  node_ai["AI routes<br/>[Ai.kt]"]
  node_aiui["AI page<br/>[ai.html]"]
  node_model["AI model service"]
end

subgraph group_media["Media search"]
  node_music["Music routes<br/>[Music.kt]"]
  node_musicapi["Music API client<br/>[MusicNetwork.kt]"]
  node_musicservice["Music service API<br/>[MusicService.kt]"]
  node_netease["Netease service"]
  node_video["Video routes<br/>[Video.kt]"]
  node_bilisearch["Bilibili search<br/>[Search.kt]"]
  node_bili["Bilibili service"]
end

subgraph group_operations["Control and files"]
  node_control["Control routes<br/>[Control.kt]"]
  node_file["File browser routes<br/>[File.kt]"]
  node_fileui["File browser page<br/>[file.html]"]
  node_network["Browser and download<br/>[Network.kt]"]
  node_browserui["Browser page<br/>[browser.html]"]
end

subgraph group_shared["Shared services"]
  node_util[("User and history data<br/>[Util.kt]")]
  node_http["HTTP client<br/>[HttpClient.kt]"]
  node_logger["Logging<br/>[Logger.kt]"]
end

node_client(("Browser client"))

node_client -->|"requests"| node_server
node_server -->|"checks access"| node_auth
node_server -->|"routes to"| node_chat
node_server -->|"routes to"| node_ai
node_server -->|"routes to"| node_control
node_server -->|"routes to"| node_music
node_server -->|"routes to"| node_video
node_server -->|"routes to"| node_network
node_chat -->|"reads and writes"| node_util
node_chat -->|"redirects to"| node_chatui
node_ai -->|"redirects to"| node_aiui
node_ai -->|"streams requests"| node_model
node_music -->|"calls"| node_musicapi
node_musicapi -->|"uses"| node_musicservice
node_musicservice -->|"requests"| node_netease
node_video -->|"calls"| node_bilisearch
node_bilisearch -->|"searches"| node_bili
node_client -->|"browses files"| node_file
node_file -->|"redirects to"| node_fileui
node_client -->|"uses proxy"| node_network
node_network -.->|"uses"| node_http
node_server -.->|"serves page"| node_browserui
node_control -->|"manages users"| node_util
node_server -->|"logs errors"| node_logger

click node_server "https://github.com/sti-233/localserverkt/blob/main/src/main/kotlin/localserver/Server.kt"
click node_auth "https://github.com/sti-233/localserverkt/blob/main/src/main/kotlin/localserver/Server.kt"
click node_chat "https://github.com/sti-233/localserverkt/blob/main/src/main/kotlin/localserver/module/Chat.kt"
click node_chatui "https://github.com/sti-233/localserverkt/blob/main/src/main/resources/chat.html"
click node_ai "https://github.com/sti-233/localserverkt/blob/main/src/main/kotlin/localserver/module/Ai.kt"
click node_aiui "https://github.com/sti-233/localserverkt/blob/main/src/main/resources/ai.html"
click node_music "https://github.com/sti-233/localserverkt/blob/main/src/main/kotlin/localserver/module/Music.kt"
click node_musicapi "https://github.com/sti-233/localserverkt/blob/main/src/main/kotlin/localserver/lib/NeteaseMusicApi/network/MusicNetwork.kt"
click node_musicservice "https://github.com/sti-233/localserverkt/blob/main/src/main/kotlin/localserver/lib/NeteaseMusicApi/network/MusicService.kt"
click node_video "https://github.com/sti-233/localserverkt/blob/main/src/main/kotlin/localserver/module/Video.kt"
click node_bilisearch "https://github.com/sti-233/localserverkt/blob/main/src/main/kotlin/localserver/lib/bilibili/Search.kt"
click node_control "https://github.com/sti-233/localserverkt/blob/main/src/main/kotlin/localserver/module/Control.kt"
click node_file "https://github.com/sti-233/localserverkt/blob/main/src/main/kotlin/localserver/module/File.kt"
click node_fileui "https://github.com/sti-233/localserverkt/blob/main/src/main/resources/file.html"
click node_network "https://github.com/sti-233/localserverkt/blob/main/src/main/kotlin/localserver/utils/Network.kt"
click node_browserui "https://github.com/sti-233/localserverkt/blob/main/src/main/resources/browser.html"
click node_util "https://github.com/sti-233/localserverkt/blob/main/src/main/kotlin/localserver/utils/Util.kt"
click node_http "https://github.com/sti-233/localserverkt/blob/main/src/main/kotlin/localserver/utils/HttpClient.kt"
click node_logger "https://github.com/sti-233/localserverkt/blob/main/src/main/kotlin/localserver/utils/Logger.kt"

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_server,node_auth,node_client toneBlue
class node_chat,node_chatui,node_ai,node_aiui,node_model toneAmber
class node_music,node_musicapi,node_musicservice,node_netease,node_video,node_bilisearch,node_bili toneMint
class node_control,node_file,node_fileui,node_network,node_browserui toneRose
class node_util,node_http,node_logger toneIndigo
```

## Components

### Server and access

- [Ktor server](https://github.com/sti-233/localserverkt/blob/main/src/main/kotlin/localserver/Server.kt): `src/main/kotlin/localserver/Server.kt`
- [Access realms](https://github.com/sti-233/localserverkt/blob/main/src/main/kotlin/localserver/Server.kt): `src/main/kotlin/localserver/Server.kt`

### Chat and AI

- [Chat routes](https://github.com/sti-233/localserverkt/blob/main/src/main/kotlin/localserver/module/Chat.kt): `src/main/kotlin/localserver/module/Chat.kt`
- [Chat page](https://github.com/sti-233/localserverkt/blob/main/src/main/resources/chat.html): `src/main/resources/chat.html`
- [AI routes](https://github.com/sti-233/localserverkt/blob/main/src/main/kotlin/localserver/module/Ai.kt): `src/main/kotlin/localserver/module/Ai.kt`
- [AI page](https://github.com/sti-233/localserverkt/blob/main/src/main/resources/ai.html): `src/main/resources/ai.html`
- **AI model service**

### Media search

- [Music routes](https://github.com/sti-233/localserverkt/blob/main/src/main/kotlin/localserver/module/Music.kt): `src/main/kotlin/localserver/module/Music.kt`
- [Music API client](https://github.com/sti-233/localserverkt/blob/main/src/main/kotlin/localserver/lib/NeteaseMusicApi/network/MusicNetwork.kt): `src/main/kotlin/localserver/lib/NeteaseMusicApi/network/MusicNetwork.kt`
- [Music service API](https://github.com/sti-233/localserverkt/blob/main/src/main/kotlin/localserver/lib/NeteaseMusicApi/network/MusicService.kt): `src/main/kotlin/localserver/lib/NeteaseMusicApi/network/MusicService.kt`
- **Netease service**
- [Video routes](https://github.com/sti-233/localserverkt/blob/main/src/main/kotlin/localserver/module/Video.kt): `src/main/kotlin/localserver/module/Video.kt`
- [Bilibili search](https://github.com/sti-233/localserverkt/blob/main/src/main/kotlin/localserver/lib/bilibili/Search.kt): `src/main/kotlin/localserver/lib/bilibili/Search.kt`
- **Bilibili service**

### Control and files

- [Control routes](https://github.com/sti-233/localserverkt/blob/main/src/main/kotlin/localserver/module/Control.kt): `src/main/kotlin/localserver/module/Control.kt`
- [File browser routes](https://github.com/sti-233/localserverkt/blob/main/src/main/kotlin/localserver/module/File.kt): `src/main/kotlin/localserver/module/File.kt`
- [File browser page](https://github.com/sti-233/localserverkt/blob/main/src/main/resources/file.html): `src/main/resources/file.html`
- [Browser and download](https://github.com/sti-233/localserverkt/blob/main/src/main/kotlin/localserver/utils/Network.kt): `src/main/kotlin/localserver/utils/Network.kt`
- [Browser page](https://github.com/sti-233/localserverkt/blob/main/src/main/resources/browser.html): `src/main/resources/browser.html`

### Shared services

- [User and history data](https://github.com/sti-233/localserverkt/blob/main/src/main/kotlin/localserver/utils/Util.kt): `src/main/kotlin/localserver/utils/Util.kt`
- [HTTP client](https://github.com/sti-233/localserverkt/blob/main/src/main/kotlin/localserver/utils/HttpClient.kt): `src/main/kotlin/localserver/utils/HttpClient.kt`
- [Logging](https://github.com/sti-233/localserverkt/blob/main/src/main/kotlin/localserver/utils/Logger.kt): `src/main/kotlin/localserver/utils/Logger.kt`

### Other components

- **Browser client**

## Connections

- Browser client → Ktor server: requests (evidence: `README.md`)
- Ktor server → Access realms: checks access (evidence: `src/main/kotlin/localserver/Server.kt`)
- Ktor server → Chat routes: routes to (evidence: `src/main/kotlin/localserver/Server.kt`)
- Ktor server → AI routes: routes to (evidence: `src/main/kotlin/localserver/Server.kt`)
- Ktor server → Control routes: routes to (evidence: `src/main/kotlin/localserver/Server.kt`)
- Ktor server → Music routes: routes to (evidence: `src/main/kotlin/localserver/Server.kt`)
- Ktor server → Video routes: routes to (evidence: `src/main/kotlin/localserver/Server.kt`)
- Ktor server → Browser and download: routes to (evidence: `src/main/kotlin/localserver/Server.kt`)
- Chat routes → User and history data: reads and writes (evidence: `src/main/kotlin/localserver/module/Chat.kt`)
- Chat routes → Chat page: redirects to (evidence: `README.md`)
- AI routes → AI page: redirects to (evidence: `README.md`)
- AI routes → AI model service: streams requests (evidence: `src/main/kotlin/localserver/module/Ai.kt`)
- Music routes → Music API client: calls (evidence: `src/main/kotlin/localserver/module/Music.kt`)
- Music API client → Music service API: uses (evidence: `src/main/kotlin/localserver/lib/NeteaseMusicApi/network/MusicNetwork.kt`)
- Music service API → Netease service: requests (evidence: `src/main/kotlin/localserver/lib/NeteaseMusicApi/network/MusicService.kt`)
- Video routes → Bilibili search: calls (evidence: `src/main/kotlin/localserver/module/Video.kt`)
- Bilibili search → Bilibili service: searches (evidence: `src/main/kotlin/localserver/lib/bilibili/Search.kt`)
- Browser client → File browser routes: browses files (evidence: `README.md`)
- File browser routes → File browser page: redirects to (evidence: `README.md`)
- Browser client → Browser and download: uses proxy (evidence: `README.md`)
- Browser and download → HTTP client: uses (evidence: `src/main/kotlin/localserver/utils/Network.kt`)
- Ktor server → Browser page: serves page
- Control routes → User and history data: manages users (evidence: `src/main/kotlin/localserver/module/Control.kt`)
- Ktor server → Logging: logs errors (evidence: `src/main/kotlin/localserver/Server.kt`)
