# ghostoraner/lanchat architecture

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

- Interactive diagram: https://gitdiagram.com/ghostoraner/lanchat
- Repository: https://github.com/ghostoraner/lanchat

## Overview

LANChat is a self-hosted LAN messenger: a server accepts TLS-protected, line-delimited JSON connections, while either of two desktop clients supports chat, direct messages, user presence, history, and chunked file transfer. The classic Avalonia client discovers the server over UDP; the README documents the same protocol and discovery model for the Tauri client. The classic client and server workflow is visible in excerpts; Tauri networking and command implementations were not sampled, so their server interaction is documented rather than source-verified.

Main entry points: [`LANChat.Server/ChatServer.cs`](https://github.com/ghostoraner/lanchat/blob/master/LANChat.Server/ChatServer.cs) (TCP TLS server), [`LANChat.Server/ClientConnection.cs`](https://github.com/ghostoraner/lanchat/blob/master/LANChat.Server/ClientConnection.cs) (Connection protocol), [`LANChat.Client/ViewModels/MainViewModel.cs`](https://github.com/ghostoraner/lanchat/blob/master/LANChat.Client/ViewModels/MainViewModel.cs) (Chat workflow), [`LANChat.Client/Services/ChatClient.cs`](https://github.com/ghostoraner/lanchat/blob/master/LANChat.Client/Services/ChatClient.cs) (TLS client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_server["Server runtime"]
  node_server_entry["Server entry<br/>[Program.cs]"]
  node_chat_server["TCP TLS server<br/>[ChatServer.cs]"]
  node_connection["Connection protocol"]
  node_client_manager[("Client registry<br/>[ClientManager.cs]")]
  node_server_model["Message model<br/>[ChatMessage.cs]"]
end

subgraph group_classic["Avalonia client"]
  node_classic_ui["Chat UI"]
  node_classic_vm["Chat workflow<br/>[MainViewModel.cs]"]
  node_message_vm["Message view"]
  node_classic_net["TLS client<br/>[ChatClient.cs]"]
  node_classic_model["Message model<br/>[ChatMessage.cs]"]
end

subgraph group_tauri["Tauri client"]
  node_tauri_ui["Chat interface<br/>[main.js]"]
  node_tauri_backend["Native backend<br/>[lib.rs]"]
end

node_user(("Chat user"))
node_lan_discovery(("LAN discovery"))
node_other_client(("Compatible clients"))

node_user -->|"uses"| node_classic_ui
node_classic_ui -->|"binds"| node_classic_vm
node_classic_vm -->|"creates views"| node_message_vm
node_classic_vm -->|"sends and receives"| node_classic_net
node_classic_net -->|"discovers via UDP"| node_lan_discovery
node_classic_net -.->|"TLS JSON"| node_chat_server
node_server_entry -->|"starts"| node_chat_server
node_chat_server -->|"dispatches connections"| node_connection
node_connection -->|"manages clients"| node_client_manager
node_connection -->|"serializes messages"| node_server_model
node_chat_server -->|"broadcasts UDP"| node_lan_discovery
node_user -.->|"uses"| node_tauri_ui
node_tauri_ui -->|"invokes commands"| node_tauri_backend
node_tauri_backend -.->|"TLS JSON"| node_chat_server
node_other_client -.->|"uses protocol"| node_chat_server

click node_classic_ui "https://github.com/ghostoraner/lanchat/blob/master/LANChat.Client/MainWindow.axaml.cs"
click node_classic_vm "https://github.com/ghostoraner/lanchat/blob/master/LANChat.Client/ViewModels/MainViewModel.cs"
click node_message_vm "https://github.com/ghostoraner/lanchat/blob/master/LANChat.Client/ViewModels/ChatMessageViewModel.cs"
click node_classic_net "https://github.com/ghostoraner/lanchat/blob/master/LANChat.Client/Services/ChatClient.cs"
click node_classic_model "https://github.com/ghostoraner/lanchat/blob/master/LANChat.Client/Models/ChatMessage.cs"
click node_server_entry "https://github.com/ghostoraner/lanchat/blob/master/LANChat.Server/Program.cs"
click node_chat_server "https://github.com/ghostoraner/lanchat/blob/master/LANChat.Server/ChatServer.cs"
click node_connection "https://github.com/ghostoraner/lanchat/blob/master/LANChat.Server/ClientConnection.cs"
click node_client_manager "https://github.com/ghostoraner/lanchat/blob/master/LANChat.Server/ClientManager.cs"
click node_server_model "https://github.com/ghostoraner/lanchat/blob/master/LANChat.Server/Models/ChatMessage.cs"
click node_tauri_ui "https://github.com/ghostoraner/lanchat/blob/master/lanchat-tauri/src/main.js"
click node_tauri_backend "https://github.com/ghostoraner/lanchat/blob/master/lanchat-tauri/src-tauri/src/lib.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_server_entry,node_chat_server,node_connection,node_client_manager,node_server_model,node_user,node_other_client toneBlue
class node_classic_ui,node_classic_vm,node_message_vm,node_classic_net,node_classic_model toneAmber
class node_tauri_ui,node_tauri_backend toneMint
class node_lan_discovery toneIndigo
```

## Components

### Server runtime

- [Server entry](https://github.com/ghostoraner/lanchat/blob/master/LANChat.Server/Program.cs): `LANChat.Server/Program.cs`
- [TCP TLS server](https://github.com/ghostoraner/lanchat/blob/master/LANChat.Server/ChatServer.cs): `LANChat.Server/ChatServer.cs`
- [Connection protocol](https://github.com/ghostoraner/lanchat/blob/master/LANChat.Server/ClientConnection.cs): `LANChat.Server/ClientConnection.cs`
- [Client registry](https://github.com/ghostoraner/lanchat/blob/master/LANChat.Server/ClientManager.cs): `LANChat.Server/ClientManager.cs`
- [Message model](https://github.com/ghostoraner/lanchat/blob/master/LANChat.Server/Models/ChatMessage.cs): `LANChat.Server/Models/ChatMessage.cs`

### Avalonia client

- [Chat UI](https://github.com/ghostoraner/lanchat/blob/master/LANChat.Client/MainWindow.axaml.cs): `LANChat.Client/MainWindow.axaml.cs`
- [Chat workflow](https://github.com/ghostoraner/lanchat/blob/master/LANChat.Client/ViewModels/MainViewModel.cs): `LANChat.Client/ViewModels/MainViewModel.cs`
- [Message view](https://github.com/ghostoraner/lanchat/blob/master/LANChat.Client/ViewModels/ChatMessageViewModel.cs): `LANChat.Client/ViewModels/ChatMessageViewModel.cs`
- [TLS client](https://github.com/ghostoraner/lanchat/blob/master/LANChat.Client/Services/ChatClient.cs): `LANChat.Client/Services/ChatClient.cs`
- [Message model](https://github.com/ghostoraner/lanchat/blob/master/LANChat.Client/Models/ChatMessage.cs): `LANChat.Client/Models/ChatMessage.cs`

### Tauri client

- [Chat interface](https://github.com/ghostoraner/lanchat/blob/master/lanchat-tauri/src/main.js): `lanchat-tauri/src/main.js`
- [Native backend](https://github.com/ghostoraner/lanchat/blob/master/lanchat-tauri/src-tauri/src/lib.rs): `lanchat-tauri/src-tauri/src/lib.rs`

### Other components

- **Chat user**
- **LAN discovery**
- **Compatible clients**

## Connections

- Chat user → Chat UI: uses (evidence: `LANChat.Client/MainWindow.axaml.cs`)
- Chat UI → Chat workflow: binds (evidence: `LANChat.Client/MainWindow.axaml.cs`)
- Chat workflow → Message view: creates views (evidence: `LANChat.Client/ViewModels/MainViewModel.cs`)
- Chat workflow → TLS client: sends and receives (evidence: `LANChat.Client/ViewModels/MainViewModel.cs`)
- TLS client → LAN discovery: discovers via UDP (evidence: `LANChat.Client/Services/ChatClient.cs`)
- TLS client → TCP TLS server: TLS JSON (evidence: `README.md`)
- Server entry → TCP TLS server: starts (evidence: `LANChat.Server/Program.cs`)
- TCP TLS server → Connection protocol: dispatches connections (evidence: `LANChat.Server/ChatServer.cs`)
- Connection protocol → Client registry: manages clients (evidence: `LANChat.Server/ClientConnection.cs`)
- Connection protocol → Message model: serializes messages (evidence: `LANChat.Server/ClientConnection.cs`)
- TCP TLS server → LAN discovery: broadcasts UDP (evidence: `LANChat.Server/ChatServer.cs`)
- Chat user → Chat interface: uses
- Chat interface → Native backend: invokes commands (evidence: `lanchat-tauri/src/main.js`)
- Native backend → TCP TLS server: TLS JSON (evidence: `README.md`)
- Compatible clients → TCP TLS server: uses protocol (evidence: `README.md`)
