# sevinatenine/fusion architecture

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

- Interactive diagram: https://gitdiagram.com/sevinatenine/fusion
- Repository: https://github.com/sevinatenine/fusion

## Overview

Fusion is a server for a CLI trading-card game, with separate chat and trading services and a browser-side terminal proxy. The main workflow is a client connecting to the game’s TCP server, which dispatches commands; startup also loads the database and launches HTTP, authentication, and admin services. Chat authenticates tokens through the auth service before relaying messages, while trading uses the game server for collection lookups. The tree and excerpts establish these entry points and some links; internal command, shop, and HTTP routing are not fully shown, so uncertain wiring is omitted.

Main entry points: [`src/main.js`](https://github.com/sevinatenine/fusion/blob/main/src/main.js) (Service startup), [`src/server.js`](https://github.com/sevinatenine/fusion/blob/main/src/server.js) (Game TCP server), [`web_client/src/main.js`](https://github.com/sevinatenine/fusion/blob/main/web_client/src/main.js) (Web terminal proxy), [`src/authServer.js`](https://github.com/sevinatenine/fusion/blob/main/src/authServer.js) (Token authentication)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_core["Game Server"]
  node_startup["Service startup<br/>[main.js]"]
  node_tcp["Game TCP server<br/>[server.js]"]
  node_commands["Command dispatcher<br/>[commandHandler.js]"]
  node_shop["Shop and auctions<br/>[shop.js]"]
  node_cards["Card operations<br/>[cards.js]"]
end

subgraph group_support["Supporting Services"]
  node_dbload["Database loader<br/>[dbLoader.js]"]
  node_mysql[("MySQL access<br/>[mysql.js]")]
  node_http["HTTP service<br/>[httpServer.js]"]
  node_auth["Token authentication<br/>[authServer.js]"]
  node_admin["Admin panel<br/>[adminPanel.js]"]
end

subgraph group_social["Chat and Trading"]
  node_chat["Chat service<br/>[main.js]"]
  node_trading["Trading service<br/>[main.js]"]
end

subgraph group_web["Browser Access"]
  node_webclient["Web terminal proxy<br/>[main.js]"]
  node_xterm["Terminal emulator<br/>[Terminal.ts]"]
end

node_cli(("CLI client"))
node_browser(("Browser user"))

node_cli -->|"connects"| node_tcp
node_tcp -->|"dispatches"| node_commands
node_startup -->|"loads data"| node_dbload
node_startup -->|"starts"| node_tcp
node_startup -->|"starts"| node_http
node_startup -->|"starts"| node_auth
node_startup -->|"starts"| node_admin
node_trading -->|"connects"| node_tcp
node_chat -->|"checks tokens"| node_auth
node_browser -->|"opens session"| node_webclient
node_webclient -->|"forwards terminal I/O"| node_tcp
node_browser -->|"uses terminal"| node_xterm

click node_startup "https://github.com/sevinatenine/fusion/blob/main/src/main.js"
click node_tcp "https://github.com/sevinatenine/fusion/blob/main/src/server.js"
click node_commands "https://github.com/sevinatenine/fusion/blob/main/src/commandHandler.js"
click node_shop "https://github.com/sevinatenine/fusion/blob/main/src/shop.js"
click node_cards "https://github.com/sevinatenine/fusion/blob/main/src/cards.js"
click node_dbload "https://github.com/sevinatenine/fusion/blob/main/src/dbLoader.js"
click node_mysql "https://github.com/sevinatenine/fusion/blob/main/src/mysql.js"
click node_http "https://github.com/sevinatenine/fusion/blob/main/src/httpServer.js"
click node_auth "https://github.com/sevinatenine/fusion/blob/main/src/authServer.js"
click node_admin "https://github.com/sevinatenine/fusion/blob/main/src/adminPanel.js"
click node_chat "https://github.com/sevinatenine/fusion/blob/main/chat_server/src/main.js"
click node_trading "https://github.com/sevinatenine/fusion/blob/main/trading_server/src/main.js"
click node_webclient "https://github.com/sevinatenine/fusion/blob/main/web_client/src/main.js"
click node_xterm "https://github.com/sevinatenine/fusion/blob/main/web_client/public/modules/xterm/src/browser/Terminal.ts"

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_startup,node_tcp,node_commands,node_shop,node_cards,node_cli,node_browser toneBlue
class node_dbload,node_mysql,node_http,node_auth,node_admin toneAmber
class node_chat,node_trading toneMint
class node_webclient,node_xterm toneRose
```

## Components

### Game Server

- [Service startup](https://github.com/sevinatenine/fusion/blob/main/src/main.js): `src/main.js`
- [Game TCP server](https://github.com/sevinatenine/fusion/blob/main/src/server.js): `src/server.js`
- [Command dispatcher](https://github.com/sevinatenine/fusion/blob/main/src/commandHandler.js): `src/commandHandler.js`
- [Shop and auctions](https://github.com/sevinatenine/fusion/blob/main/src/shop.js): `src/shop.js`
- [Card operations](https://github.com/sevinatenine/fusion/blob/main/src/cards.js): `src/cards.js`

### Supporting Services

- [Database loader](https://github.com/sevinatenine/fusion/blob/main/src/dbLoader.js): `src/dbLoader.js`
- [MySQL access](https://github.com/sevinatenine/fusion/blob/main/src/mysql.js): `src/mysql.js`
- [HTTP service](https://github.com/sevinatenine/fusion/blob/main/src/httpServer.js): `src/httpServer.js`
- [Token authentication](https://github.com/sevinatenine/fusion/blob/main/src/authServer.js): `src/authServer.js`
- [Admin panel](https://github.com/sevinatenine/fusion/blob/main/src/adminPanel.js): `src/adminPanel.js`

### Chat and Trading

- [Chat service](https://github.com/sevinatenine/fusion/blob/main/chat_server/src/main.js): `chat_server/src/main.js`
- [Trading service](https://github.com/sevinatenine/fusion/blob/main/trading_server/src/main.js): `trading_server/src/main.js`

### Browser Access

- [Web terminal proxy](https://github.com/sevinatenine/fusion/blob/main/web_client/src/main.js): `web_client/src/main.js`
- [Terminal emulator](https://github.com/sevinatenine/fusion/blob/main/web_client/public/modules/xterm/src/browser/Terminal.ts): `web_client/public/modules/xterm/src/browser/Terminal.ts`

### Other components

- **CLI client**
- **Browser user**

## Connections

- CLI client → Game TCP server: connects
- Game TCP server → Command dispatcher: dispatches
- Service startup → Database loader: loads data
- Service startup → Game TCP server: starts
- Service startup → HTTP service: starts
- Service startup → Token authentication: starts
- Service startup → Admin panel: starts
- Trading service → Game TCP server: connects
- Chat service → Token authentication: checks tokens
- Browser user → Web terminal proxy: opens session
- Web terminal proxy → Game TCP server: forwards terminal I/O
- Browser user → Terminal emulator: uses terminal
