# karthikks26/ciper-chat architecture

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

- Interactive diagram: https://gitdiagram.com/karthikks26/ciper-chat
- Repository: https://github.com/karthikks26/ciper-chat

## Overview

CipherChat is a browser-based encrypted room chat with protected attachments and live audio/video. The main workflow is create or open a room, obtain its fragment-held encryption key, authenticate a room identity, then exchange encrypted messages and files; the browser decrypts content for display. Separate branches cover file-access auditing, live discussion and recording, and standalone screen recording. API, authentication and persistence relationships are included where the excerpts or README support them; unsampled client wiring is not inferred.

Main entry points: [`components/ChatShell.js`](https://github.com/karthikks26/ciper-chat/blob/main/components/ChatShell.js) (Chat and realtime), [`components/RoomClient.js`](https://github.com/karthikks26/ciper-chat/blob/main/components/RoomClient.js) (Room access), [`lib/prisma.js`](https://github.com/karthikks26/ciper-chat/blob/main/lib/prisma.js) (PostgreSQL), [`app/api/rooms/[slug]/messages/route.js`](https://github.com/karthikks26/ciper-chat/blob/main/app/api/rooms/%5Bslug%5D/messages/route.js) (Message API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Room entry"]
  node_landing["Landing page<br/>[Landing.js]"]
  node_room_create["Room creation<br/>[route.js]"]
  node_room_client["Room access<br/>[RoomClient.js]"]
  node_join["Join room<br/>[JoinRoom.js]"]
end

subgraph group_chat["Encrypted chat"]
  node_chat_shell["Chat and realtime<br/>[ChatShell.js]"]
  node_crypto["Browser encryption<br/>[client-crypto.js]"]
  node_key_storage["Room key storage<br/>[client-storage.js]"]
  node_composer["Message composer<br/>[Composer.js]"]
  node_message_view["Message display<br/>[MessageBubble.js]"]
  node_message_api["Message API<br/>[route.js]"]
  node_serializer["Message serialization<br/>[serializers.js]"]
end

subgraph group_security["Identity and files"]
  node_room_api["Room management<br/>[route.js]"]
  node_session_api["Session endpoint<br/>[route.js]"]
  node_join_api["Identity and session<br/>[route.js]"]
  node_auth["Signed sessions<br/>[server-auth.js]"]
  node_session_core["Session tokens<br/>[session-core.js]"]
  node_validators["Request validation<br/>[validators.js]"]
  node_secure_viewer["Protected viewer<br/>[SecureViewer.js]"]
  node_db[("PostgreSQL<br/>[prisma.js]")]
  node_upload_api["Encrypted upload API<br/>[route.js]"]
  node_cloudinary["Encrypted file storage<br/>[cloudinary.js]"]
  node_file_access["File access policy<br/>[route.js]"]
  node_audit_api["Access audit<br/>[route.js]"]
  node_audit_panel["Access log panel<br/>[AccessLogPanel.js]"]
end

subgraph group_media["Live media"]
  node_call_panel["Live discussion<br/>[CallPanel.js]"]
  node_recording["Media recording<br/>[media-recording.js]"]
  node_camera["Camera capture<br/>[CameraCapture.js]"]
  node_standalone_recorder["Standalone recorder"]
  node_socket_server["Realtime server<br/>[server.js]"]
end

node_visitor(("Visitor"))

node_visitor -->|"opens"| node_landing
node_landing -.->|"creates room"| node_room_create
node_visitor -->|"opens room link"| node_room_client
node_room_client -->|"reads key"| node_key_storage
node_room_client -->|"requests identity"| node_join
node_join -.->|"joins room"| node_join_api
node_room_create -->|"creates records"| node_db
node_room_create -->|"sets session"| node_auth
node_join_api -->|"reads and writes"| node_db
node_join_api -->|"sets session"| node_auth
node_auth -->|"signs tokens"| node_session_core
node_room_client -->|"loads room"| node_room_api
node_room_client -->|"checks session"| node_session_api
node_room_client -->|"opens chat"| node_chat_shell
node_chat_shell -->|"encrypts and decrypts"| node_crypto
node_chat_shell -->|"builds share link"| node_key_storage
node_chat_shell -->|"renders composer"| node_composer
node_chat_shell -->|"renders messages"| node_message_view
node_chat_shell -->|"opens discussion"| node_call_panel
node_chat_shell -->|"opens audit"| node_audit_panel
node_chat_shell -->|"posts messages"| node_message_api
node_message_api -->|"reads and writes"| node_db
node_message_api -->|"serializes messages"| node_serializer
node_message_api -->|"emits message event"| node_socket_server
node_message_view -->|"decrypts content"| node_crypto
node_message_view -->|"opens attachment"| node_secure_viewer
node_composer -->|"captures media"| node_camera
node_composer -.->|"encrypts files"| node_crypto
node_chat_shell -.->|"uploads ciphertext"| node_upload_api
node_upload_api -->|"stores encrypted blobs"| node_cloudinary
node_upload_api -->|"checks session"| node_auth
node_file_access -->|"records access"| node_db
node_audit_api -->|"reads activity"| node_db
node_audit_panel -.->|"loads audit"| node_audit_api
node_call_panel -->|"records discussion"| node_recording
node_call_panel -.->|"signals peers"| node_socket_server
node_landing -.->|"opens recorder"| node_standalone_recorder
node_room_api -->|"removes room files"| node_cloudinary
node_room_api -->|"destroys room records"| node_db
node_message_api -->|"validates input"| node_validators
node_join_api -->|"validates input"| node_validators

click node_landing "https://github.com/karthikks26/ciper-chat/blob/main/components/Landing.js"
click node_room_create "https://github.com/karthikks26/ciper-chat/blob/main/app/api/rooms/route.js"
click node_room_client "https://github.com/karthikks26/ciper-chat/blob/main/components/RoomClient.js"
click node_join "https://github.com/karthikks26/ciper-chat/blob/main/components/JoinRoom.js"
click node_room_api "https://github.com/karthikks26/ciper-chat/blob/main/app/api/rooms/%5Bslug%5D/route.js"
click node_session_api "https://github.com/karthikks26/ciper-chat/blob/main/app/api/rooms/%5Bslug%5D/session/route.js"
click node_join_api "https://github.com/karthikks26/ciper-chat/blob/main/app/api/rooms/%5Bslug%5D/join/route.js"
click node_auth "https://github.com/karthikks26/ciper-chat/blob/main/lib/server-auth.js"
click node_session_core "https://github.com/karthikks26/ciper-chat/blob/main/lib/session-core.js"
click node_validators "https://github.com/karthikks26/ciper-chat/blob/main/lib/validators.js"
click node_chat_shell "https://github.com/karthikks26/ciper-chat/blob/main/components/ChatShell.js"
click node_crypto "https://github.com/karthikks26/ciper-chat/blob/main/lib/client-crypto.js"
click node_key_storage "https://github.com/karthikks26/ciper-chat/blob/main/lib/client-storage.js"
click node_composer "https://github.com/karthikks26/ciper-chat/blob/main/components/Composer.js"
click node_message_view "https://github.com/karthikks26/ciper-chat/blob/main/components/MessageBubble.js"
click node_secure_viewer "https://github.com/karthikks26/ciper-chat/blob/main/components/SecureViewer.js"
click node_message_api "https://github.com/karthikks26/ciper-chat/blob/main/app/api/rooms/%5Bslug%5D/messages/route.js"
click node_serializer "https://github.com/karthikks26/ciper-chat/blob/main/lib/serializers.js"
click node_db "https://github.com/karthikks26/ciper-chat/blob/main/lib/prisma.js"
click node_upload_api "https://github.com/karthikks26/ciper-chat/blob/main/app/api/rooms/%5Bslug%5D/upload/route.js"
click node_cloudinary "https://github.com/karthikks26/ciper-chat/blob/main/lib/cloudinary.js"
click node_file_access "https://github.com/karthikks26/ciper-chat/blob/main/app/api/rooms/%5Bslug%5D/files/%5BmessageId%5D/access/route.js"
click node_audit_api "https://github.com/karthikks26/ciper-chat/blob/main/app/api/rooms/%5Bslug%5D/audit/route.js"
click node_audit_panel "https://github.com/karthikks26/ciper-chat/blob/main/components/AccessLogPanel.js"
click node_call_panel "https://github.com/karthikks26/ciper-chat/blob/main/components/CallPanel.js"
click node_recording "https://github.com/karthikks26/ciper-chat/blob/main/lib/media-recording.js"
click node_camera "https://github.com/karthikks26/ciper-chat/blob/main/components/CameraCapture.js"
click node_standalone_recorder "https://github.com/karthikks26/ciper-chat/blob/main/components/StandaloneRecorder.js"
click node_socket_server "https://github.com/karthikks26/ciper-chat/blob/main/server.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_landing,node_room_create,node_room_client,node_join toneBlue
class node_chat_shell,node_crypto,node_key_storage,node_composer,node_message_view,node_message_api,node_serializer toneAmber
class node_room_api,node_session_api,node_join_api,node_auth,node_session_core,node_validators,node_secure_viewer,node_db,node_upload_api,node_cloudinary,node_file_access,node_audit_api,node_audit_panel toneMint
class node_call_panel,node_recording,node_camera,node_standalone_recorder,node_socket_server toneRose
class node_visitor toneIndigo
```

## Components

### Room entry

- [Landing page](https://github.com/karthikks26/ciper-chat/blob/main/components/Landing.js): `components/Landing.js`
- [Room creation](https://github.com/karthikks26/ciper-chat/blob/main/app/api/rooms/route.js): `app/api/rooms/route.js`
- [Room access](https://github.com/karthikks26/ciper-chat/blob/main/components/RoomClient.js): `components/RoomClient.js`
- [Join room](https://github.com/karthikks26/ciper-chat/blob/main/components/JoinRoom.js): `components/JoinRoom.js`

### Encrypted chat

- [Chat and realtime](https://github.com/karthikks26/ciper-chat/blob/main/components/ChatShell.js): `components/ChatShell.js`
- [Browser encryption](https://github.com/karthikks26/ciper-chat/blob/main/lib/client-crypto.js): `lib/client-crypto.js`
- [Room key storage](https://github.com/karthikks26/ciper-chat/blob/main/lib/client-storage.js): `lib/client-storage.js`
- [Message composer](https://github.com/karthikks26/ciper-chat/blob/main/components/Composer.js): `components/Composer.js`
- [Message display](https://github.com/karthikks26/ciper-chat/blob/main/components/MessageBubble.js): `components/MessageBubble.js`
- [Message API](https://github.com/karthikks26/ciper-chat/blob/main/app/api/rooms/%5Bslug%5D/messages/route.js): `app/api/rooms/[slug]/messages/route.js`
- [Message serialization](https://github.com/karthikks26/ciper-chat/blob/main/lib/serializers.js): `lib/serializers.js`

### Identity and files

- [Room management](https://github.com/karthikks26/ciper-chat/blob/main/app/api/rooms/%5Bslug%5D/route.js): `app/api/rooms/[slug]/route.js`
- [Session endpoint](https://github.com/karthikks26/ciper-chat/blob/main/app/api/rooms/%5Bslug%5D/session/route.js): `app/api/rooms/[slug]/session/route.js`
- [Identity and session](https://github.com/karthikks26/ciper-chat/blob/main/app/api/rooms/%5Bslug%5D/join/route.js): `app/api/rooms/[slug]/join/route.js`
- [Signed sessions](https://github.com/karthikks26/ciper-chat/blob/main/lib/server-auth.js): `lib/server-auth.js`
- [Session tokens](https://github.com/karthikks26/ciper-chat/blob/main/lib/session-core.js): `lib/session-core.js`
- [Request validation](https://github.com/karthikks26/ciper-chat/blob/main/lib/validators.js): `lib/validators.js`
- [Protected viewer](https://github.com/karthikks26/ciper-chat/blob/main/components/SecureViewer.js): `components/SecureViewer.js`
- [PostgreSQL](https://github.com/karthikks26/ciper-chat/blob/main/lib/prisma.js): `lib/prisma.js`
- [Encrypted upload API](https://github.com/karthikks26/ciper-chat/blob/main/app/api/rooms/%5Bslug%5D/upload/route.js): `app/api/rooms/[slug]/upload/route.js`
- [Encrypted file storage](https://github.com/karthikks26/ciper-chat/blob/main/lib/cloudinary.js): `lib/cloudinary.js`
- [File access policy](https://github.com/karthikks26/ciper-chat/blob/main/app/api/rooms/%5Bslug%5D/files/%5BmessageId%5D/access/route.js): `app/api/rooms/[slug]/files/[messageId]/access/route.js`
- [Access audit](https://github.com/karthikks26/ciper-chat/blob/main/app/api/rooms/%5Bslug%5D/audit/route.js): `app/api/rooms/[slug]/audit/route.js`
- [Access log panel](https://github.com/karthikks26/ciper-chat/blob/main/components/AccessLogPanel.js): `components/AccessLogPanel.js`

### Live media

- [Live discussion](https://github.com/karthikks26/ciper-chat/blob/main/components/CallPanel.js): `components/CallPanel.js`
- [Media recording](https://github.com/karthikks26/ciper-chat/blob/main/lib/media-recording.js): `lib/media-recording.js`
- [Camera capture](https://github.com/karthikks26/ciper-chat/blob/main/components/CameraCapture.js): `components/CameraCapture.js`
- [Standalone recorder](https://github.com/karthikks26/ciper-chat/blob/main/components/StandaloneRecorder.js): `components/StandaloneRecorder.js`
- [Realtime server](https://github.com/karthikks26/ciper-chat/blob/main/server.js): `server.js`

### Other components

- **Visitor**

## Connections

- Visitor → Landing page: opens (evidence: `README.md`)
- Landing page → Room creation: creates room
- Visitor → Room access: opens room link (evidence: `README.md`)
- Room access → Room key storage: reads key (evidence: `components/RoomClient.js`)
- Room access → Join room: requests identity (evidence: `components/RoomClient.js`)
- Join room → Identity and session: joins room
- Room creation → PostgreSQL: creates records (evidence: `app/api/rooms/route.js`)
- Room creation → Signed sessions: sets session (evidence: `app/api/rooms/route.js`)
- Identity and session → PostgreSQL: reads and writes (evidence: `app/api/rooms/[slug]/join/route.js`)
- Identity and session → Signed sessions: sets session (evidence: `app/api/rooms/[slug]/join/route.js`)
- Signed sessions → Session tokens: signs tokens (evidence: `lib/server-auth.js`)
- Room access → Room management: loads room (evidence: `components/RoomClient.js`)
- Room access → Session endpoint: checks session (evidence: `components/RoomClient.js`)
- Room access → Chat and realtime: opens chat (evidence: `components/RoomClient.js`)
- Chat and realtime → Browser encryption: encrypts and decrypts (evidence: `components/ChatShell.js`)
- Chat and realtime → Room key storage: builds share link (evidence: `components/ChatShell.js`)
- Chat and realtime → Message composer: renders composer (evidence: `components/ChatShell.js`)
- Chat and realtime → Message display: renders messages (evidence: `components/ChatShell.js`)
- Chat and realtime → Live discussion: opens discussion (evidence: `components/ChatShell.js`)
- Chat and realtime → Access log panel: opens audit (evidence: `components/ChatShell.js`)
- Chat and realtime → Message API: posts messages (evidence: `components/ChatShell.js`)
- Message API → PostgreSQL: reads and writes (evidence: `app/api/rooms/[slug]/messages/route.js`)
- Message API → Message serialization: serializes messages (evidence: `app/api/rooms/[slug]/messages/route.js`)
- Message API → Realtime server: emits message event (evidence: `app/api/rooms/[slug]/messages/route.js`)
- Message display → Browser encryption: decrypts content (evidence: `components/MessageBubble.js`)
- Message display → Protected viewer: opens attachment (evidence: `components/MessageBubble.js`)
- Message composer → Camera capture: captures media (evidence: `components/Composer.js`)
- Message composer → Browser encryption: encrypts files
- Chat and realtime → Encrypted upload API: uploads ciphertext
- Encrypted upload API → Encrypted file storage: stores encrypted blobs (evidence: `README.md`)
- Encrypted upload API → Signed sessions: checks session (evidence: `app/api/rooms/[slug]/upload/route.js`)
- File access policy → PostgreSQL: records access (evidence: `app/api/rooms/[slug]/files/[messageId]/access/route.js`)
- Access audit → PostgreSQL: reads activity (evidence: `app/api/rooms/[slug]/audit/route.js`)
- Access log panel → Access audit: loads audit
- Live discussion → Media recording: records discussion (evidence: `components/CallPanel.js`)
- Live discussion → Realtime server: signals peers (evidence: `README.md`)
- Landing page → Standalone recorder: opens recorder (evidence: `README.md`)
- Room management → Encrypted file storage: removes room files (evidence: `app/api/rooms/[slug]/route.js`)
- Room management → PostgreSQL: destroys room records (evidence: `app/api/rooms/[slug]/route.js`)
- Message API → Request validation: validates input (evidence: `app/api/rooms/[slug]/messages/route.js`)
- Identity and session → Request validation: validates input (evidence: `app/api/rooms/[slug]/join/route.js`)
