# smabbashussain/inklink architecture

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

- Interactive diagram: https://gitdiagram.com/smabbashussain/inklink
- Repository: https://github.com/smabbashussain/inklink

## Overview

InkLink is a collaborative whiteboard product with a Flutter client, Firebase callable backend, and Socket.IO relay. Its principal documented workflow is clients synchronizing board activity through the relay, with version history reconstructed and reverted from live and archived operations; callable functions handle access, collaboration, and AI-related operations. The supplied tree omits the Flutter source, and the relay excerpt is partial, so client internals and several runtime connections are represented only where the README or shown references support them.

Main entry points: [`functions/index.js`](https://github.com/smabbashussain/inklink/blob/main/functions/index.js) (Callable dispatcher), [`server/src/index.js`](https://github.com/smabbashussain/inklink/blob/main/server/src/index.js) (Socket relay), [`functions/src/utils/notification_sender.js`](https://github.com/smabbashussain/inklink/blob/main/functions/src/utils/notification_sender.js) (Notification sender), [`server/src/history/timeline.js`](https://github.com/smabbashussain/inklink/blob/main/server/src/history/timeline.js) (History timeline)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_realtime["Realtime collaboration"]
  node_relay["Socket relay<br/>[index.js]"]
  node_boardchat["Board chat<br/>[index.js]"]
  node_voice["Voice signaling<br/>[index.js]"]
end

subgraph group_history["History and recovery"]
  node_historyapi["History relay handlers<br/>[index.js]"]
  node_reconstruct["State reconstruction<br/>[reconstruct.js]"]
  node_timeline["History timeline<br/>[timeline.js]"]
  node_revert["Revert engine<br/>[revert.js]"]
  node_describe["Change descriptions<br/>[describe.js]"]
end

subgraph group_functions["Callable backend"]
  node_callables["Callable dispatcher<br/>[index.js]"]
  node_boards["Board access"]
  node_workspaces["Workspace access"]
  node_friends["Friend relations"]
  node_invitations["Board invitations"]
  node_notifications["Notifications"]
  node_ai["AI image tools"]
  node_profile["Profile and accounts"]
end

subgraph group_shared["Shared infrastructure"]
  node_redis[("Redis sync buffer<br/>[redis.js]")]
  node_firestore[("Firestore")]
  node_r2[("History archive<br/>[r2.js]")]
  node_admin["Firebase Admin<br/>[firebase-admin.js]"]
  node_paths["Firestore paths<br/>[firestore_paths.js]"]
  node_notifyutil["Notification sender"]
  node_r2util["R2 history utility<br/>[r2_history.js]"]
end

node_members(("Collaborators"))

node_members -->|"syncs boards"| node_relay
node_members -->|"requests operations"| node_callables
node_relay -.->|"buffers sync"| node_redis
node_relay -->|"reads board state"| node_firestore
node_relay -->|"relays chat"| node_boardchat
node_relay -->|"signals calls"| node_voice
node_relay -->|"routes history"| node_historyapi
node_historyapi -->|"reconstructs state"| node_reconstruct
node_historyapi -->|"builds timeline"| node_timeline
node_historyapi -->|"applies reverts"| node_revert
node_historyapi -->|"archives operations"| node_r2
node_reconstruct -->|"loads archived blocks"| node_r2
node_timeline -->|"replays operations"| node_reconstruct
node_timeline -->|"uses revert logic"| node_revert
node_timeline -->|"describes changes"| node_describe
node_revert -->|"replays state"| node_reconstruct
node_revert -->|"reads archived ops"| node_r2
node_callables -->|"loads handlers"| node_boards
node_callables -->|"loads handlers"| node_workspaces
node_callables -->|"loads handlers"| node_friends
node_callables -->|"loads handlers"| node_invitations
node_callables -->|"loads handlers"| node_notifications
node_callables -->|"loads handlers"| node_ai
node_callables -->|"loads handlers"| node_profile
node_friends -->|"uses Firebase"| node_admin
node_friends -->|"uses path constants"| node_paths
node_friends -->|"sends notifications"| node_notifyutil
node_boards -->|"sends notifications"| node_notifyutil
node_boards -->|"updates board cache"| node_redis
node_invitations -->|"sends notifications"| node_notifyutil
node_notifications -->|"sends notifications"| node_notifyutil
node_notifyutil -->|"sends push"| node_admin
node_notifyutil -->|"uses path constants"| node_paths
node_profile -->|"purges archived data"| node_r2util
node_profile -->|"clears board state"| node_redis
node_profile -->|"uses path constants"| node_paths
node_ai -.->|"stores generated images"| node_r2util

click node_relay "https://github.com/smabbashussain/inklink/blob/main/server/src/index.js"
click node_boardchat "https://github.com/smabbashussain/inklink/blob/main/server/src/index.js"
click node_voice "https://github.com/smabbashussain/inklink/blob/main/server/src/index.js"
click node_redis "https://github.com/smabbashussain/inklink/blob/main/functions/src/utils/redis.js"
click node_r2 "https://github.com/smabbashussain/inklink/blob/main/server/src/history/r2.js"
click node_historyapi "https://github.com/smabbashussain/inklink/blob/main/server/src/index.js"
click node_reconstruct "https://github.com/smabbashussain/inklink/blob/main/server/src/history/reconstruct.js"
click node_timeline "https://github.com/smabbashussain/inklink/blob/main/server/src/history/timeline.js"
click node_revert "https://github.com/smabbashussain/inklink/blob/main/server/src/history/revert.js"
click node_describe "https://github.com/smabbashussain/inklink/blob/main/server/src/history/describe.js"
click node_callables "https://github.com/smabbashussain/inklink/blob/main/functions/index.js"
click node_boards "https://github.com/smabbashussain/inklink/tree/main/functions/src/boards"
click node_workspaces "https://github.com/smabbashussain/inklink/tree/main/functions/src/workspaces"
click node_friends "https://github.com/smabbashussain/inklink/tree/main/functions/src/friends"
click node_invitations "https://github.com/smabbashussain/inklink/tree/main/functions/src/invitations"
click node_notifications "https://github.com/smabbashussain/inklink/tree/main/functions/src/notifications"
click node_ai "https://github.com/smabbashussain/inklink/tree/main/functions/src/ai"
click node_profile "https://github.com/smabbashussain/inklink/tree/main/functions/src/profile"
click node_admin "https://github.com/smabbashussain/inklink/blob/main/functions/server/firebase-admin.js"
click node_paths "https://github.com/smabbashussain/inklink/blob/main/functions/src/utils/firestore_paths.js"
click node_notifyutil "https://github.com/smabbashussain/inklink/blob/main/functions/src/utils/notification_sender.js"
click node_r2util "https://github.com/smabbashussain/inklink/blob/main/functions/src/utils/r2_history.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_relay,node_boardchat,node_voice toneBlue
class node_historyapi,node_reconstruct,node_timeline,node_revert,node_describe toneAmber
class node_callables,node_boards,node_workspaces,node_friends,node_invitations,node_notifications,node_ai,node_profile toneMint
class node_redis,node_firestore,node_r2,node_admin,node_paths,node_notifyutil,node_r2util toneRose
class node_members toneIndigo
```

## Components

### Realtime collaboration

- [Socket relay](https://github.com/smabbashussain/inklink/blob/main/server/src/index.js): `server/src/index.js`
- [Board chat](https://github.com/smabbashussain/inklink/blob/main/server/src/index.js): `server/src/index.js`
- [Voice signaling](https://github.com/smabbashussain/inklink/blob/main/server/src/index.js): `server/src/index.js`

### History and recovery

- [History relay handlers](https://github.com/smabbashussain/inklink/blob/main/server/src/index.js): `server/src/index.js`
- [State reconstruction](https://github.com/smabbashussain/inklink/blob/main/server/src/history/reconstruct.js): `server/src/history/reconstruct.js`
- [History timeline](https://github.com/smabbashussain/inklink/blob/main/server/src/history/timeline.js): `server/src/history/timeline.js`
- [Revert engine](https://github.com/smabbashussain/inklink/blob/main/server/src/history/revert.js): `server/src/history/revert.js`
- [Change descriptions](https://github.com/smabbashussain/inklink/blob/main/server/src/history/describe.js): `server/src/history/describe.js`

### Callable backend

- [Callable dispatcher](https://github.com/smabbashussain/inklink/blob/main/functions/index.js): `functions/index.js`
- [Board access](https://github.com/smabbashussain/inklink/tree/main/functions/src/boards): `functions/src/boards`
- [Workspace access](https://github.com/smabbashussain/inklink/tree/main/functions/src/workspaces): `functions/src/workspaces`
- [Friend relations](https://github.com/smabbashussain/inklink/tree/main/functions/src/friends): `functions/src/friends`
- [Board invitations](https://github.com/smabbashussain/inklink/tree/main/functions/src/invitations): `functions/src/invitations`
- [Notifications](https://github.com/smabbashussain/inklink/tree/main/functions/src/notifications): `functions/src/notifications`
- [AI image tools](https://github.com/smabbashussain/inklink/tree/main/functions/src/ai): `functions/src/ai`
- [Profile and accounts](https://github.com/smabbashussain/inklink/tree/main/functions/src/profile): `functions/src/profile`

### Shared infrastructure

- [Redis sync buffer](https://github.com/smabbashussain/inklink/blob/main/functions/src/utils/redis.js): `functions/src/utils/redis.js`
- **Firestore**
- [History archive](https://github.com/smabbashussain/inklink/blob/main/server/src/history/r2.js): `server/src/history/r2.js`
- [Firebase Admin](https://github.com/smabbashussain/inklink/blob/main/functions/server/firebase-admin.js): `functions/server/firebase-admin.js`
- [Firestore paths](https://github.com/smabbashussain/inklink/blob/main/functions/src/utils/firestore_paths.js): `functions/src/utils/firestore_paths.js`
- [Notification sender](https://github.com/smabbashussain/inklink/blob/main/functions/src/utils/notification_sender.js): `functions/src/utils/notification_sender.js`
- [R2 history utility](https://github.com/smabbashussain/inklink/blob/main/functions/src/utils/r2_history.js): `functions/src/utils/r2_history.js`

### Other components

- **Collaborators**

## Connections

- Collaborators → Socket relay: syncs boards
- Collaborators → Callable dispatcher: requests operations
- Socket relay → Redis sync buffer: buffers sync
- Socket relay → Firestore: reads board state (evidence: `server/src/index.js`)
- Socket relay → Board chat: relays chat (evidence: `server/src/index.js`)
- Socket relay → Voice signaling: signals calls (evidence: `server/src/index.js`)
- Socket relay → History relay handlers: routes history (evidence: `server/src/index.js`)
- History relay handlers → State reconstruction: reconstructs state (evidence: `server/src/index.js`)
- History relay handlers → History timeline: builds timeline (evidence: `server/src/index.js`)
- History relay handlers → Revert engine: applies reverts (evidence: `server/src/index.js`)
- History relay handlers → History archive: archives operations (evidence: `server/src/index.js`)
- State reconstruction → History archive: loads archived blocks (evidence: `server/src/history/reconstruct.js`)
- History timeline → State reconstruction: replays operations (evidence: `server/src/history/timeline.js`)
- History timeline → Revert engine: uses revert logic (evidence: `server/src/history/timeline.js`)
- History timeline → Change descriptions: describes changes (evidence: `server/src/history/timeline.js`)
- Revert engine → State reconstruction: replays state (evidence: `server/src/history/revert.js`)
- Revert engine → History archive: reads archived ops (evidence: `server/src/history/revert.js`)
- Callable dispatcher → Board access: loads handlers (evidence: `functions/index.js`)
- Callable dispatcher → Workspace access: loads handlers (evidence: `functions/index.js`)
- Callable dispatcher → Friend relations: loads handlers (evidence: `functions/index.js`)
- Callable dispatcher → Board invitations: loads handlers (evidence: `functions/index.js`)
- Callable dispatcher → Notifications: loads handlers (evidence: `functions/index.js`)
- Callable dispatcher → AI image tools: loads handlers (evidence: `functions/index.js`)
- Callable dispatcher → Profile and accounts: loads handlers (evidence: `functions/index.js`)
- Friend relations → Firebase Admin: uses Firebase (evidence: `functions/src/friends/accept_friend_request.js`)
- Friend relations → Firestore paths: uses path constants (evidence: `functions/src/friends/accept_friend_request.js`)
- Friend relations → Notification sender: sends notifications (evidence: `functions/src/friends/accept_friend_request.js`)
- Board access → Notification sender: sends notifications (evidence: `functions/src/boards/respond_to_board_access_request.js`)
- Board access → Redis sync buffer: updates board cache (evidence: `functions/src/boards/respond_to_board_access_request.js`)
- Board invitations → Notification sender: sends notifications (evidence: `functions/src/invitations/accept_board_invite.js`)
- Notifications → Notification sender: sends notifications (evidence: `functions/src/notifications/send_board_invite.js`)
- Notification sender → Firebase Admin: sends push (evidence: `functions/src/utils/notification_sender.js`)
- Notification sender → Firestore paths: uses path constants (evidence: `functions/src/utils/notification_sender.js`)
- Profile and accounts → R2 history utility: purges archived data (evidence: `functions/src/profile/delete_user_account.js`)
- Profile and accounts → Redis sync buffer: clears board state (evidence: `functions/src/profile/delete_user_account.js`)
- Profile and accounts → Firestore paths: uses path constants (evidence: `functions/src/profile/delete_user_account.js`)
- AI image tools → R2 history utility: stores generated images
