# hatimc/p2p-call architecture

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

- Interactive diagram: https://gitdiagram.com/hatimc/p2p-call
- Repository: https://github.com/hatimc/p2p-call

## Overview

This is a browser-based peer-to-peer video-calling application. Users establish a session, exchange call setup messages through the server’s authenticated signaling API, then communicate directly over WebRTC; the server also maintains user presence in SQLite. The browser client includes chat, file transfer, screen sharing, whiteboard, and collaborative-document features. The README is empty, and the source excerpts are partial, so the graph includes only relationships visible in those excerpts; some detailed call setup and UI wiring are not shown.

Main entry points: [`public/js/app.js`](https://github.com/hatimc/p2p-call/blob/main/public/js/app.js) (Peer connection), [`server.js`](https://github.com/hatimc/p2p-call/blob/main/server.js) (HTTP API), [`db/database.js`](https://github.com/hatimc/p2p-call/blob/main/db/database.js) (User registry operations)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Browser client"]
  node_client["Calling client<br/>[app.js]"]
  node_rtc["Peer connection<br/>[app.js]"]
  node_media["Media and screen share<br/>[app.js]"]
  node_chat["Peer chat<br/>[app.js]"]
  node_whiteboard["Peer whiteboard<br/>[app.js]"]
  node_documents["Peer documents<br/>[app.js]"]
  node_files["Peer file transfer<br/>[app.js]"]
end

subgraph group_server["Call coordination"]
  node_api["HTTP API<br/>[server.js]"]
  node_signalqueue["Signal queue and waiters<br/>[server.js]"]
end

subgraph group_persistence["User persistence"]
  node_registry["User registry operations<br/>[database.js]"]
  node_usersdb[("SQLite user store<br/>[database.js]")]
end

node_user(("Caller or callee"))

node_user -.->|"uses"| node_client
node_client -->|"posts signals"| node_api
node_client -->|"polls signals"| node_api
node_api -->|"queues signals"| node_signalqueue
node_signalqueue -->|"returns signals"| node_api
node_api -->|"reads and updates"| node_registry
node_registry -->|"queries and writes"| node_usersdb
node_client -.->|"sets up calls"| node_rtc
node_rtc -.->|"carries media"| node_media
node_rtc -->|"opens data channel"| node_chat
node_rtc -->|"opens data channel"| node_whiteboard
node_rtc -->|"opens data channel"| node_documents
node_rtc -->|"opens data channel"| node_files

click node_client "https://github.com/hatimc/p2p-call/blob/main/public/js/app.js"
click node_rtc "https://github.com/hatimc/p2p-call/blob/main/public/js/app.js"
click node_media "https://github.com/hatimc/p2p-call/blob/main/public/js/app.js"
click node_chat "https://github.com/hatimc/p2p-call/blob/main/public/js/app.js"
click node_whiteboard "https://github.com/hatimc/p2p-call/blob/main/public/js/app.js"
click node_documents "https://github.com/hatimc/p2p-call/blob/main/public/js/app.js"
click node_files "https://github.com/hatimc/p2p-call/blob/main/public/js/app.js"
click node_api "https://github.com/hatimc/p2p-call/blob/main/server.js"
click node_signalqueue "https://github.com/hatimc/p2p-call/blob/main/server.js"
click node_registry "https://github.com/hatimc/p2p-call/blob/main/db/database.js"
click node_usersdb "https://github.com/hatimc/p2p-call/blob/main/db/database.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_client,node_rtc,node_media,node_chat,node_whiteboard,node_documents,node_files toneBlue
class node_api,node_signalqueue toneAmber
class node_registry,node_usersdb toneMint
class node_user toneIndigo
```

## Components

### Browser client

- [Calling client](https://github.com/hatimc/p2p-call/blob/main/public/js/app.js): `public/js/app.js`
- [Peer connection](https://github.com/hatimc/p2p-call/blob/main/public/js/app.js): `public/js/app.js`
- [Media and screen share](https://github.com/hatimc/p2p-call/blob/main/public/js/app.js): `public/js/app.js`
- [Peer chat](https://github.com/hatimc/p2p-call/blob/main/public/js/app.js): `public/js/app.js`
- [Peer whiteboard](https://github.com/hatimc/p2p-call/blob/main/public/js/app.js): `public/js/app.js`
- [Peer documents](https://github.com/hatimc/p2p-call/blob/main/public/js/app.js): `public/js/app.js`
- [Peer file transfer](https://github.com/hatimc/p2p-call/blob/main/public/js/app.js): `public/js/app.js`

### Call coordination

- [HTTP API](https://github.com/hatimc/p2p-call/blob/main/server.js): `server.js`
- [Signal queue and waiters](https://github.com/hatimc/p2p-call/blob/main/server.js): `server.js`

### User persistence

- [User registry operations](https://github.com/hatimc/p2p-call/blob/main/db/database.js): `db/database.js`
- [SQLite user store](https://github.com/hatimc/p2p-call/blob/main/db/database.js): `db/database.js`

### Other components

- **Caller or callee**

## Connections

- Caller or callee → Calling client: uses
- Calling client → HTTP API: posts signals (evidence: `public/js/app.js`)
- Calling client → HTTP API: polls signals (evidence: `public/js/app.js`)
- HTTP API → Signal queue and waiters: queues signals (evidence: `server.js`)
- Signal queue and waiters → HTTP API: returns signals (evidence: `server.js`)
- HTTP API → User registry operations: reads and updates (evidence: `server.js`)
- User registry operations → SQLite user store: queries and writes (evidence: `db/database.js`)
- Calling client → Peer connection: sets up calls (evidence: `public/js/app.js`)
- Peer connection → Media and screen share: carries media (evidence: `public/js/app.js`)
- Peer connection → Peer chat: opens data channel (evidence: `public/js/app.js`)
- Peer connection → Peer whiteboard: opens data channel (evidence: `public/js/app.js`)
- Peer connection → Peer documents: opens data channel (evidence: `public/js/app.js`)
- Peer connection → Peer file transfer: opens data channel (evidence: `public/js/app.js`)
