# ferrdxd/regex architecture

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

- Interactive diagram: https://gitdiagram.com/ferrdxd/regex
- Repository: https://github.com/ferrdxd/regex

## Overview

Regex is a browser-based peer-to-peer sharing product: its core modules support peer discovery/signaling, WebRTC connections, text drops, and chunked file transfer. The intended user flow is to identify a device, join a local or named room, establish a peer connection, then exchange text or files. The sampled App is only a placeholder and does not yet wire these capabilities into a visible workflow. No README content was provided; product relationships beyond shown calls are left unverified.

Main entry points: [`src/App.tsx`](https://github.com/ferrdxd/regex/blob/main/src/App.tsx) (App shell), [`src/core/signaling.ts`](https://github.com/ferrdxd/regex/blob/main/src/core/signaling.ts) (Signaling client), [`worker/signaling-server.ts`](https://github.com/ferrdxd/regex/blob/main/worker/signaling-server.ts) (Room peers), [`src/core/webrtc.ts`](https://github.com/ferrdxd/regex/blob/main/src/core/webrtc.ts) (WebRTC connections)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["Browser interface"]
  node_app["App shell<br/>[App.tsx]"]
  node_entry["React entry<br/>[main.tsx]"]
end

subgraph group_discovery["Peer discovery"]
  node_identity["Device identity<br/>[identity.ts]"]
  node_signaling_client["Signaling client<br/>[signaling.ts]"]
  node_signaling_worker["Signaling routes"]
  node_room["Room peers"]
  node_protocol_types["Protocol types<br/>[types.ts]"]
end

subgraph group_connection["Peer connection"]
  node_webrtc["WebRTC connections<br/>[webrtc.ts]"]
end

subgraph group_sharing["Sharing features"]
  node_control["Control messages<br/>[controlProtocol.ts]"]
  node_file_transfer["File transfer<br/>[fileTransfer.ts]"]
  node_zip["ZIP utilities<br/>[zipUtils.ts]"]
end

node_user(("User"))
node_stun{{"STUN servers"}}
node_data_channel{{"WebRTC data channel"}}
node_durable_objects[("Durable Objects")]
node_websocket{{"WebSocket transport"}}

node_entry -->|"renders"| node_app
node_signaling_client -->|"uses types"| node_protocol_types
node_control -->|"uses types"| node_protocol_types
node_signaling_worker -->|"uses types"| node_protocol_types
node_signaling_worker -->|"routes requests"| node_room
node_room -->|"runs as"| node_durable_objects
node_signaling_client -->|"opens connection"| node_websocket
node_room -->|"handles messages"| node_websocket
node_webrtc -->|"configures servers"| node_stun
node_webrtc -->|"creates channel"| node_data_channel
node_file_transfer -->|"sends chunks"| node_data_channel
node_user -.->|"uses"| node_app
node_app -.->|"would obtain identity"| node_identity
node_app -.->|"would join peers"| node_signaling_client
node_signaling_client -.->|"would signal"| node_signaling_worker
node_signaling_client -.->|"would exchange setup"| node_webrtc
node_app -.->|"would exchange text"| node_control
node_app -.->|"would transfer files"| node_file_transfer

click node_app "https://github.com/ferrdxd/regex/blob/main/src/App.tsx"
click node_entry "https://github.com/ferrdxd/regex/blob/main/src/main.tsx"
click node_identity "https://github.com/ferrdxd/regex/blob/main/src/utils/identity.ts"
click node_signaling_client "https://github.com/ferrdxd/regex/blob/main/src/core/signaling.ts"
click node_signaling_worker "https://github.com/ferrdxd/regex/blob/main/worker/signaling-server.ts"
click node_room "https://github.com/ferrdxd/regex/blob/main/worker/signaling-server.ts"
click node_protocol_types "https://github.com/ferrdxd/regex/blob/main/src/core/types.ts"
click node_webrtc "https://github.com/ferrdxd/regex/blob/main/src/core/webrtc.ts"
click node_control "https://github.com/ferrdxd/regex/blob/main/src/core/controlProtocol.ts"
click node_file_transfer "https://github.com/ferrdxd/regex/blob/main/src/core/fileTransfer.ts"
click node_zip "https://github.com/ferrdxd/regex/blob/main/src/core/zipUtils.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_app,node_entry,node_user toneBlue
class node_identity,node_signaling_client,node_signaling_worker,node_room,node_protocol_types,node_durable_objects toneAmber
class node_webrtc,node_stun toneMint
class node_control,node_file_transfer,node_zip toneRose
class node_data_channel,node_websocket toneIndigo
```

## Components

### Browser interface

- [App shell](https://github.com/ferrdxd/regex/blob/main/src/App.tsx): `src/App.tsx`
- [React entry](https://github.com/ferrdxd/regex/blob/main/src/main.tsx): `src/main.tsx`

### Peer discovery

- [Device identity](https://github.com/ferrdxd/regex/blob/main/src/utils/identity.ts): `src/utils/identity.ts`
- [Signaling client](https://github.com/ferrdxd/regex/blob/main/src/core/signaling.ts): `src/core/signaling.ts`
- [Signaling routes](https://github.com/ferrdxd/regex/blob/main/worker/signaling-server.ts): `worker/signaling-server.ts`
- [Room peers](https://github.com/ferrdxd/regex/blob/main/worker/signaling-server.ts): `worker/signaling-server.ts`
- [Protocol types](https://github.com/ferrdxd/regex/blob/main/src/core/types.ts): `src/core/types.ts`

### Peer connection

- [WebRTC connections](https://github.com/ferrdxd/regex/blob/main/src/core/webrtc.ts): `src/core/webrtc.ts`

### Sharing features

- [Control messages](https://github.com/ferrdxd/regex/blob/main/src/core/controlProtocol.ts): `src/core/controlProtocol.ts`
- [File transfer](https://github.com/ferrdxd/regex/blob/main/src/core/fileTransfer.ts): `src/core/fileTransfer.ts`
- [ZIP utilities](https://github.com/ferrdxd/regex/blob/main/src/core/zipUtils.ts): `src/core/zipUtils.ts`

### Other components

- **User**
- **STUN servers**
- **WebRTC data channel**
- **Durable Objects**
- **WebSocket transport**

## Connections

- React entry → App shell: renders (evidence: `src/main.tsx`)
- Signaling client → Protocol types: uses types (evidence: `src/core/signaling.ts`)
- Control messages → Protocol types: uses types (evidence: `src/core/controlProtocol.ts`)
- Signaling routes → Protocol types: uses types (evidence: `worker/signaling-server.ts`)
- Signaling routes → Room peers: routes requests (evidence: `worker/signaling-server.ts`)
- Room peers → Durable Objects: runs as (evidence: `worker/signaling-server.ts`)
- Signaling client → WebSocket transport: opens connection (evidence: `src/core/signaling.ts`)
- Room peers → WebSocket transport: handles messages (evidence: `worker/signaling-server.ts`)
- WebRTC connections → STUN servers: configures servers (evidence: `src/core/webrtc.ts`)
- WebRTC connections → WebRTC data channel: creates channel (evidence: `src/core/webrtc.ts`)
- File transfer → WebRTC data channel: sends chunks (evidence: `src/core/fileTransfer.ts`)
- User → App shell: uses
- App shell → Device identity: would obtain identity
- App shell → Signaling client: would join peers
- Signaling client → Signaling routes: would signal
- Signaling client → WebRTC connections: would exchange setup
- App shell → Control messages: would exchange text
- App shell → File transfer: would transfer files
