Skip to content

Commit 67dce8d

Browse files
committed
add: include architecture diagram in README.md for better understanding
1 parent 65ffede commit 67dce8d

1 file changed

Lines changed: 209 additions & 0 deletions

File tree

README.md

Lines changed: 209 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,215 @@ docker run -p 2333:2333 nodelink
8686

8787
---
8888

89+
### Diagram
90+
91+
```mermaid
92+
flowchart TD
93+
%% =========================
94+
%% NODELINK / LAVALINK STACK
95+
%% Detailed, GitHub-compatible
96+
%% =========================
97+
98+
subgraph L1["Layer 1: Client Access"]
99+
direction LR
100+
Bot["Discord Bot\nCommands/Events"]
101+
Lib["Lavalink Client\nWS + REST"]
102+
API["API Gateway\nHTTP + WS termination"]
103+
RecvClient["Voice Receive Client\n(Recorder)"]
104+
PCMClient["Direct PCM Client\n(HTTP PCM)"]
105+
106+
Bot -- "control + intents" --> Lib
107+
Lib -- "REST: /loadtracks /sessions /players" --> API
108+
Lib -- "WS: opcodes (play/pause/seek/filters)" --> API
109+
RecvClient -- "WS voice receive" --> API
110+
PCMClient -- "HTTP POST PCM" --> API
111+
end
112+
113+
subgraph L2["Layer 2: Master Orchestrator"]
114+
direction TB
115+
116+
API_In["REST Handlers\nValidation + streaming limits"]
117+
WS_GW["WebSocket Gateway\nClient Control"]
118+
VoiceWS["Voice Receive WS Router\nIngest frames/events"]
119+
120+
SessionMgr["Session Manager\nPlayer/session lifecycle"]
121+
122+
subgraph Managers["Resource & Control Managers"]
123+
direction LR
124+
WorkerMgr["Worker Manager\nVoice workers"]
125+
SourceMgr["Source Worker Manager\nSearch/Resolve/Decrypt"]
126+
StatsMgr["Stats Manager\nPrometheus/Metrics"]
127+
PluginMgr["Plugin Manager\nHooks/Providers"]
128+
end
129+
130+
API --> API_In
131+
API --> WS_GW
132+
API --> VoiceWS
133+
134+
API_In --> SessionMgr
135+
WS_GW --> SessionMgr
136+
VoiceWS --> SessionMgr
137+
138+
SessionMgr --> WorkerMgr
139+
SessionMgr --> SourceMgr
140+
SessionMgr -. "metrics/logs" .-> StatsMgr
141+
SessionMgr -. "plugin hooks" .-> PluginMgr
142+
143+
API_In -. "task delegation" .-> Managers
144+
end
145+
146+
subgraph BUS["Binary Socket Bus"]
147+
direction LR
148+
VCmd["Command Pipe\nv8 serialization"]
149+
VEvt["Event Pipe\nbinary stream"]
150+
SMeta["Metadata Pipe\ncustom framing"]
151+
end
152+
153+
subgraph L3["Layer 3: Execution Plane"]
154+
direction TB
155+
156+
subgraph SrcCluster["Source Worker Cluster"]
157+
direction TB
158+
SW_IPC["IPC Task In\nprocess.send()"]
159+
SW_Q["Priority Task Queue\nresolve/search/decrypt"]
160+
161+
subgraph SWPool["Micro-Worker Thread Pool"]
162+
direction LR
163+
T1["Thread 1"]
164+
T2["Thread 2"]
165+
TN["Thread 32"]
166+
end
167+
168+
SW_Net["Source Network Interface\nHTTP(S) fetch / CDN"]
169+
SW_Sock["Socket Client\nmetadata out"]
170+
171+
SW_IPC --> SW_Q
172+
SW_Q -- "dispatch" --> SWPool
173+
SWPool -- "network I/O" --> SW_Net
174+
SW_Net -- "metadata + timing + headers" --> SW_Sock
175+
end
176+
177+
subgraph VoiceCluster["Voice Worker Cluster"]
178+
direction TB
179+
180+
VW_Sock["Socket Listener\ncommands in"]
181+
InternalMgr["Internal Source Manager\nper-player stream control"]
182+
183+
subgraph DSP["DSP Pipeline"]
184+
direction TB
185+
PipeIn["StreamProcessor\npull stream"]
186+
Demux["Demux / Decode"]
187+
Resample["Resampler\n48 kHz"]
188+
Ring["RingBuffer"]
189+
MixLayers["Mix Layers"]
190+
Mixer["AudioMixer"]
191+
BPool["BufferPool"]
192+
Filters["Filters / Volume"]
193+
Encoder["Opus Encoder\n20ms frames"]
194+
195+
PipeIn --> Demux --> Resample --> Ring
196+
MixLayers -.-> Ring
197+
Ring --> Mixer
198+
BPool -.-> Mixer
199+
Mixer --> Filters --> Encoder
200+
end
201+
202+
subgraph DAVE["DAVE Security Engine"]
203+
direction LR
204+
UDPIn["UDP Socket In\nDiscord voice recv"]
205+
DDec["DAVE AEAD Decryptor"]
206+
VRelay["Voice Receive Bus\nframes/events"]
207+
DEnc["DAVE AEAD Encryptor"]
208+
209+
UDPIn --> DDec --> VRelay
210+
end
211+
212+
VW_Sock --> InternalMgr
213+
InternalMgr -- "stream url / seek / stop" --> PipeIn
214+
Encoder --> DEnc
215+
end
216+
end
217+
218+
subgraph L4["Layer 4: Output Plane"]
219+
direction LR
220+
Discord["Discord Voice Gateway"]
221+
end
222+
223+
subgraph SUP["Infrastructure & Support Services"]
224+
direction LR
225+
Route["RoutePlanner\nIP rotation/bind"]
226+
Creds["CredentialManager\nAES-256-GCM storage"]
227+
Log["Logger / Audit"]
228+
Err["ErrorHandler\nsendErrorResponse"]
229+
end
230+
231+
%% Inter-layer connections
232+
Lib -- "WS control" --> WS_GW
233+
Lib -- "REST control" --> API_In
234+
235+
RecvClient -- "WS voice frames/events" --> VoiceWS
236+
VRelay -- "voice frames/events" --> VoiceWS
237+
238+
PCMClient -- "HTTP PCM stream" --> API_In
239+
240+
SourceMgr -- "IPC tasks: resolve/search/decrypt" --> SW_IPC
241+
242+
SW_Sock -- "metadata packet" --> SMeta
243+
SMeta -- "track metadata, duration, headers, hints" --> SourceMgr
244+
245+
WorkerMgr -- "net.write(command)" --> VCmd
246+
VCmd -- "command" --> VW_Sock
247+
248+
VRelay -- "internal feedback (health/seq/rtp)" --> VEvt
249+
VEvt -- "events" --> WorkerMgr
250+
251+
DEnc == "Encrypted Opus (AEAD)" ==> Discord
252+
253+
API_In -. "warn/error" .-> Log
254+
WS_GW -. "warn/error" .-> Log
255+
VoiceWS -. "warn/error" .-> Log
256+
257+
API_In -. "413/400/etc" .-> Err
258+
WS_GW -. "close codes" .-> Err
259+
260+
Creds -. "inject credentials" .-> Managers
261+
Creds -. "inject keys (DAVE/ARL/etc)" .-> SrcCluster
262+
Creds -. "inject voice keys/session" .-> VoiceCluster
263+
264+
Route -. "bind outbound ip" .-> SW_Net
265+
Route -. "bind outbound ip" .-> PipeIn
266+
267+
PluginMgr -. "source hooks" .-> SourceMgr
268+
PluginMgr -. "voice hooks" .-> WorkerMgr
269+
PluginMgr -. "rest/ws hooks" .-> API_In
270+
271+
StatsMgr -. "record metrics" .-> Managers
272+
StatsMgr -. "record metrics" .-> SrcCluster
273+
StatsMgr -. "record metrics" .-> VoiceCluster
274+
275+
%% Layout anchors
276+
L1 ~~~ L2
277+
L2 ~~~ BUS
278+
BUS ~~~ L3
279+
L3 ~~~ L4
280+
L4 ~~~ SUP
281+
282+
%% Styling (GitHub supports classDef/class)
283+
classDef layer fill:#0f172a,stroke:#334155,color:#cbd5e1
284+
classDef component fill:#1e293b,stroke:#475569,color:#f1f5f9
285+
classDef focus fill:#1e1b4b,stroke:#818cf8,color:#e0e7ff
286+
classDef critical fill:#064e3b,stroke:#34d399,color:#ecfdf5
287+
classDef infra fill:#312e81,stroke:#6366f1,color:#e0e7ff,stroke-dasharray: 5 5
288+
classDef manager fill:#1e3a8a,stroke:#3b82f6,color:#ffffff
289+
290+
class L1,L2,L3,L4,SUP layer
291+
class Bot,API,API_In,WS_GW,VoiceWS,StatsMgr,PluginMgr,SW_Q,SW_Net,UDPIn,VRelay,Log,Err,T1,T2,TN,RecvClient,PCMClient,Demux,Resample,Ring,MixLayers,Filters component
292+
class Lib,SW_IPC,SW_Sock,VW_Sock,PipeIn,Encoder,Mixer focus
293+
class DDec,DEnc,Discord critical
294+
class BUS,VCmd,VEvt,SMeta,Route,Creds,BPool infra
295+
class SessionMgr,WorkerMgr,SourceMgr manager
296+
```
297+
89298
## Usage
90299

91300
NodeLink is compatible with most Lavalink clients, as it implements nearly the entire original API.

0 commit comments

Comments
 (0)