# root-ilyas/rootshare architecture

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

- Interactive diagram: https://gitdiagram.com/root-ilyas/rootshare
- Repository: https://github.com/root-ilyas/rootshare

## Overview

RootShare is a self-hosted file and clipboard sharing app. Users create or join password-optional rooms in a browser, then share files and clipboard updates with connected devices; they can use LAN links or, when available, a temporary Cloudflare Tunnel. The CLI and desktop app can start a server and create sharing links automatically. Room data is process-local and uploaded files use temporary disk storage. The sampled server and client code shows the main API and realtime flows; some UI behavior and HTML are unsampled, so those details are represented only where the README documents them.

Main entry points: [`server/index.js`](https://github.com/root-ilyas/rootshare/blob/main/server/index.js) (HTTP and realtime API), [`bin/share.js`](https://github.com/root-ilyas/rootshare/blob/main/bin/share.js) (CLI launcher), [`electron/main.js`](https://github.com/root-ilyas/rootshare/blob/main/electron/main.js) (Desktop launcher), [`server/tunnel.js`](https://github.com/root-ilyas/rootshare/blob/main/server/tunnel.js) (Tunnel manager)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Browser experience"]
  node_home["Room entry<br/>[home.js]"]
  node_roomui["Room workspace<br/>[room.js]"]
end

subgraph group_runtime["Sharing runtime"]
  node_server["HTTP and realtime API<br/>[index.js]"]
  node_roomstate[("Room state<br/>[rooms.js]")]
  node_filedisk[("Temporary file storage<br/>[index.js]")]
end

subgraph group_launch["App launchers"]
  node_cli["CLI launcher<br/>[share.js]"]
  node_desktop["Desktop launcher<br/>[main.js]"]
  node_electronview["Desktop webview bridge<br/>[preload.js]"]
end

subgraph group_integrations["Network access"]
  node_network["LAN discovery<br/>[network.js]"]
  node_tunnel["Tunnel manager<br/>[tunnel.js]"]
end

node_user(("User"))
node_cloudflare{{"Cloudflare Tunnel"}}

node_user -->|"creates or joins"| node_home
node_home -->|"requests room"| node_server
node_user -->|"shares in room"| node_roomui
node_roomui -->|"uploads and syncs"| node_server
node_server -->|"reads and updates"| node_roomstate
node_server -->|"writes and serves"| node_filedisk
node_server -->|"gets LAN address"| node_network
node_server -->|"imports tunnel controls"| node_tunnel
node_roomui -->|"requests QR data"| node_server
node_cli -->|"starts server"| node_server
node_cli -->|"creates room"| node_roomstate
node_cli -->|"gets LAN address"| node_network
node_cli -->|"starts tunnel"| node_tunnel
node_desktop -->|"starts server"| node_server
node_desktop -->|"gets LAN address"| node_network
node_desktop -->|"starts tunnel"| node_tunnel
node_tunnel -->|"spawns binary"| node_cloudflare
node_desktop -->|"loads preload bridge"| node_electronview

click node_home "https://github.com/root-ilyas/rootshare/blob/main/public/js/home.js"
click node_roomui "https://github.com/root-ilyas/rootshare/blob/main/public/js/room.js"
click node_server "https://github.com/root-ilyas/rootshare/blob/main/server/index.js"
click node_roomstate "https://github.com/root-ilyas/rootshare/blob/main/server/rooms.js"
click node_filedisk "https://github.com/root-ilyas/rootshare/blob/main/server/index.js"
click node_network "https://github.com/root-ilyas/rootshare/blob/main/server/network.js"
click node_tunnel "https://github.com/root-ilyas/rootshare/blob/main/server/tunnel.js"
click node_cli "https://github.com/root-ilyas/rootshare/blob/main/bin/share.js"
click node_desktop "https://github.com/root-ilyas/rootshare/blob/main/electron/main.js"
click node_electronview "https://github.com/root-ilyas/rootshare/blob/main/electron/preload.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_home,node_roomui,node_user toneBlue
class node_server,node_roomstate,node_filedisk toneAmber
class node_cli,node_desktop,node_electronview toneMint
class node_network,node_tunnel toneRose
class node_cloudflare toneIndigo
```

## Components

### Browser experience

- [Room entry](https://github.com/root-ilyas/rootshare/blob/main/public/js/home.js): `public/js/home.js`
- [Room workspace](https://github.com/root-ilyas/rootshare/blob/main/public/js/room.js): `public/js/room.js`

### Sharing runtime

- [HTTP and realtime API](https://github.com/root-ilyas/rootshare/blob/main/server/index.js): `server/index.js`
- [Room state](https://github.com/root-ilyas/rootshare/blob/main/server/rooms.js): `server/rooms.js`
- [Temporary file storage](https://github.com/root-ilyas/rootshare/blob/main/server/index.js): `server/index.js`

### App launchers

- [CLI launcher](https://github.com/root-ilyas/rootshare/blob/main/bin/share.js): `bin/share.js`
- [Desktop launcher](https://github.com/root-ilyas/rootshare/blob/main/electron/main.js): `electron/main.js`
- [Desktop webview bridge](https://github.com/root-ilyas/rootshare/blob/main/electron/preload.js): `electron/preload.js`

### Network access

- [LAN discovery](https://github.com/root-ilyas/rootshare/blob/main/server/network.js): `server/network.js`
- [Tunnel manager](https://github.com/root-ilyas/rootshare/blob/main/server/tunnel.js): `server/tunnel.js`

### Other components

- **User**
- **Cloudflare Tunnel**

## Connections

- User → Room entry: creates or joins (evidence: `README.md`)
- Room entry → HTTP and realtime API: requests room (evidence: `public/js/home.js`)
- User → Room workspace: shares in room (evidence: `README.md`)
- Room workspace → HTTP and realtime API: uploads and syncs (evidence: `public/js/room.js`)
- HTTP and realtime API → Room state: reads and updates (evidence: `server/index.js`)
- HTTP and realtime API → Temporary file storage: writes and serves (evidence: `server/index.js`)
- HTTP and realtime API → LAN discovery: gets LAN address (evidence: `server/index.js`)
- HTTP and realtime API → Tunnel manager: imports tunnel controls (evidence: `server/index.js`)
- Room workspace → HTTP and realtime API: requests QR data (evidence: `public/js/room.js`)
- CLI launcher → HTTP and realtime API: starts server (evidence: `bin/share.js`)
- CLI launcher → Room state: creates room (evidence: `bin/share.js`)
- CLI launcher → LAN discovery: gets LAN address (evidence: `bin/share.js`)
- CLI launcher → Tunnel manager: starts tunnel (evidence: `bin/share.js`)
- Desktop launcher → HTTP and realtime API: starts server (evidence: `electron/main.js`)
- Desktop launcher → LAN discovery: gets LAN address (evidence: `electron/main.js`)
- Desktop launcher → Tunnel manager: starts tunnel (evidence: `electron/main.js`)
- Tunnel manager → Cloudflare Tunnel: spawns binary (evidence: `server/tunnel.js`)
- Desktop launcher → Desktop webview bridge: loads preload bridge (evidence: `electron/main.js`)
