# adiorany3/chatsecrets architecture

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

- Interactive diagram: https://gitdiagram.com/adiorany3/chatsecrets
- Repository: https://github.com/adiorany3/chatsecrets

## Overview

ChatSecrets is a Streamlit app for password-protected chat rooms, encrypted messages, and validated attachments. A user creates or joins a room with a shared password, then chats during a fixed 30-minute session; members can see presence, clear messages, or destroy the room. The UI delegates room and message state to transactional SQLite storage, while attachments are validated before storage and display. The README documents key provisioning, legacy-file archiving, and room cooldowns. Some UI-to-storage paths are not shown in the excerpts, so those links are omitted.

Main entry points: [`app.py`](https://github.com/adiorany3/chatsecrets/blob/main/app.py) (Streamlit chat UI), [`storage.py`](https://github.com/adiorany3/chatsecrets/blob/main/storage.py) (Active SQLite data), [`attachments.py`](https://github.com/adiorany3/chatsecrets/blob/main/attachments.py) (Attachment validation), [`static/composer-focus.js`](https://github.com/adiorany3/chatsecrets/blob/main/static/composer-focus.js) (Composer focus helper)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["Chat interface"]
  node_streamlit_ui["Streamlit chat UI<br/>[app.py]"]
  node_chat_display["Message display<br/>[app.py]"]
  node_composer["Message composer<br/>[app.py]"]
  node_presence_ui["Presence and refresh<br/>[app.py]"]
  node_sound_ui["Sound feedback<br/>[app.py]"]
  node_focus_helper["Composer focus helper<br/>[composer-focus.js]"]
end

subgraph group_room_services["Room services"]
  node_room_sessions["Room and session management<br/>[storage.py]"]
  node_presence_service["Presence tracking<br/>[storage.py]"]
  node_room_controls["Clear and destroy<br/>[storage.py]"]
end

subgraph group_secure_storage["Secure storage"]
  node_key_setup["Key provisioning<br/>[storage.py]"]
  node_message_store["Encrypted message store<br/>[storage.py]"]
  node_sqlite[("Active SQLite data<br/>[storage.py]")]
  node_legacy_archive["Legacy file archive<br/>[storage.py]"]
end

subgraph group_attachment_support["Attachment support"]
  node_attachment_validation["Attachment validation<br/>[attachments.py]"]
  node_attachment_display["Attachment display<br/>[app.py]"]
end

node_user(("Chat participant"))

node_user -->|"uses"| node_streamlit_ui
node_streamlit_ui -->|"provisions key"| node_key_setup
node_streamlit_ui -->|"joins room"| node_room_sessions
node_streamlit_ui -->|"updates presence"| node_presence_service
node_streamlit_ui -->|"clears or destroys"| node_room_controls
node_streamlit_ui -->|"loads script"| node_focus_helper
node_streamlit_ui -->|"renders"| node_chat_display
node_streamlit_ui -->|"renders"| node_composer
node_streamlit_ui -->|"renders"| node_presence_ui
node_streamlit_ui -->|"renders"| node_sound_ui
node_chat_display -.->|"displays messages"| node_message_store
node_composer -.->|"submits messages"| node_message_store
node_presence_ui -->|"requests presence"| node_presence_service
node_room_sessions -->|"reads and writes"| node_sqlite
node_presence_service -->|"reads and writes"| node_sqlite
node_room_controls -->|"deletes data"| node_sqlite
node_key_setup -->|"checks existing data"| node_sqlite
node_message_store -->|"stores encrypted messages"| node_sqlite
node_message_store -->|"validates attachments"| node_attachment_validation
node_legacy_archive -->|"archives original bytes"| node_sqlite
node_streamlit_ui -->|"validates uploads"| node_attachment_validation
node_streamlit_ui -->|"renders attachments"| node_attachment_display
node_attachment_display -->|"checks file data"| node_attachment_validation

click node_streamlit_ui "https://github.com/adiorany3/chatsecrets/blob/main/app.py"
click node_chat_display "https://github.com/adiorany3/chatsecrets/blob/main/app.py"
click node_composer "https://github.com/adiorany3/chatsecrets/blob/main/app.py"
click node_presence_ui "https://github.com/adiorany3/chatsecrets/blob/main/app.py"
click node_sound_ui "https://github.com/adiorany3/chatsecrets/blob/main/app.py"
click node_focus_helper "https://github.com/adiorany3/chatsecrets/blob/main/static/composer-focus.js"
click node_room_sessions "https://github.com/adiorany3/chatsecrets/blob/main/storage.py"
click node_presence_service "https://github.com/adiorany3/chatsecrets/blob/main/storage.py"
click node_room_controls "https://github.com/adiorany3/chatsecrets/blob/main/storage.py"
click node_key_setup "https://github.com/adiorany3/chatsecrets/blob/main/storage.py"
click node_message_store "https://github.com/adiorany3/chatsecrets/blob/main/storage.py"
click node_sqlite "https://github.com/adiorany3/chatsecrets/blob/main/storage.py"
click node_legacy_archive "https://github.com/adiorany3/chatsecrets/blob/main/storage.py"
click node_attachment_validation "https://github.com/adiorany3/chatsecrets/blob/main/attachments.py"
click node_attachment_display "https://github.com/adiorany3/chatsecrets/blob/main/app.py"

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_streamlit_ui,node_chat_display,node_composer,node_presence_ui,node_sound_ui,node_focus_helper toneBlue
class node_room_sessions,node_presence_service,node_room_controls toneAmber
class node_key_setup,node_message_store,node_sqlite,node_legacy_archive toneMint
class node_attachment_validation,node_attachment_display toneRose
class node_user toneIndigo
```

## Components

### Chat interface

- [Streamlit chat UI](https://github.com/adiorany3/chatsecrets/blob/main/app.py): `app.py`
- [Message display](https://github.com/adiorany3/chatsecrets/blob/main/app.py): `app.py`
- [Message composer](https://github.com/adiorany3/chatsecrets/blob/main/app.py): `app.py`
- [Presence and refresh](https://github.com/adiorany3/chatsecrets/blob/main/app.py): `app.py`
- [Sound feedback](https://github.com/adiorany3/chatsecrets/blob/main/app.py): `app.py`
- [Composer focus helper](https://github.com/adiorany3/chatsecrets/blob/main/static/composer-focus.js): `static/composer-focus.js`

### Room services

- [Room and session management](https://github.com/adiorany3/chatsecrets/blob/main/storage.py): `storage.py`
- [Presence tracking](https://github.com/adiorany3/chatsecrets/blob/main/storage.py): `storage.py`
- [Clear and destroy](https://github.com/adiorany3/chatsecrets/blob/main/storage.py): `storage.py`

### Secure storage

- [Key provisioning](https://github.com/adiorany3/chatsecrets/blob/main/storage.py): `storage.py`
- [Encrypted message store](https://github.com/adiorany3/chatsecrets/blob/main/storage.py): `storage.py`
- [Active SQLite data](https://github.com/adiorany3/chatsecrets/blob/main/storage.py): `storage.py`
- [Legacy file archive](https://github.com/adiorany3/chatsecrets/blob/main/storage.py): `storage.py`

### Attachment support

- [Attachment validation](https://github.com/adiorany3/chatsecrets/blob/main/attachments.py): `attachments.py`
- [Attachment display](https://github.com/adiorany3/chatsecrets/blob/main/app.py): `app.py`

### Other components

- **Chat participant**

## Connections

- Chat participant → Streamlit chat UI: uses (evidence: `README.md`)
- Streamlit chat UI → Key provisioning: provisions key (evidence: `app.py`)
- Streamlit chat UI → Room and session management: joins room (evidence: `app.py`)
- Streamlit chat UI → Presence tracking: updates presence (evidence: `app.py`)
- Streamlit chat UI → Clear and destroy: clears or destroys (evidence: `app.py`)
- Streamlit chat UI → Composer focus helper: loads script (evidence: `app.py`)
- Streamlit chat UI → Message display: renders (evidence: `app.py`)
- Streamlit chat UI → Message composer: renders (evidence: `app.py`)
- Streamlit chat UI → Presence and refresh: renders (evidence: `app.py`)
- Streamlit chat UI → Sound feedback: renders (evidence: `app.py`)
- Message display → Encrypted message store: displays messages (evidence: `app.py`)
- Message composer → Encrypted message store: submits messages (evidence: `app.py`)
- Presence and refresh → Presence tracking: requests presence (evidence: `app.py`)
- Room and session management → Active SQLite data: reads and writes (evidence: `storage.py`)
- Presence tracking → Active SQLite data: reads and writes (evidence: `storage.py`)
- Clear and destroy → Active SQLite data: deletes data (evidence: `README.md`)
- Key provisioning → Active SQLite data: checks existing data (evidence: `storage.py`)
- Encrypted message store → Active SQLite data: stores encrypted messages (evidence: `storage.py`)
- Encrypted message store → Attachment validation: validates attachments (evidence: `storage.py`)
- Legacy file archive → Active SQLite data: archives original bytes (evidence: `storage.py`)
- Streamlit chat UI → Attachment validation: validates uploads (evidence: `app.py`)
- Streamlit chat UI → Attachment display: renders attachments (evidence: `app.py`)
- Attachment display → Attachment validation: checks file data (evidence: `app.py`)
