# dimassdwiiorg/qwertybot architecture

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

- Interactive diagram: https://gitdiagram.com/dimassdwiiorg/qwertybot
- Repository: https://github.com/dimassdwiiorg/qwertybot

## Overview

qwertybot is a multimodal conversational assistant: users create or reopen a session, submit text and attachments, and receive streamed Gemini responses that are retained in session history. The React client also supports audio recording/playback, speech, artifacts, exports, themes, and session search; the Express backend exposes chat, session, quota, and owner-control routes. The graph preserves these documented capabilities, while source excerpts and the index provide stronger evidence for selected server and client calls. Several UI-to-UI render relationships and unsampled integrations are therefore omitted.

Main entry points: [`server/src/index.ts`](https://github.com/dimassdwiiorg/qwertybot/blob/main/server/src/index.ts) (Express routes), [`server/src/controllers/chatController.ts`](https://github.com/dimassdwiiorg/qwertybot/blob/main/server/src/controllers/chatController.ts) (Chat handler), [`client/src/App.tsx`](https://github.com/dimassdwiiorg/qwertybot/blob/main/client/src/App.tsx) (Chat application), [`server/src/services/geminiService.ts`](https://github.com/dimassdwiiorg/qwertybot/blob/main/server/src/services/geminiService.ts) (Gemini service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Client experience"]
  node_app["Chat application<br/>[App.tsx]"]
  node_api["API URL helper<br/>[api.ts]"]
  node_feed["Chat feed<br/>[ChatFeed.tsx]"]
  node_input["Message input<br/>[MessageInput.tsx]"]
  node_recorder["Audio recorder"]
  node_audio["Audio player<br/>[AudioPlayer.tsx]"]
  node_speech["Text-to-speech<br/>[useTextToSpeech.ts]"]
  node_artifact["Artifact preview<br/>[ArtifactModal.tsx]"]
  node_sidebar["Session sidebar<br/>[Sidebar.tsx]"]
  node_export["Conversation export<br/>[exportUtils.ts]"]
  node_vpsmodal["VPS access modal<br/>[VpsAuthModal.tsx]"]
end

subgraph group_chat["Conversation services"]
  node_express["Express routes<br/>[index.ts]"]
  node_chatctl["Chat handler<br/>[chatController.ts]"]
  node_gemini["Gemini service<br/>[geminiService.ts]"]
  node_search["Web search<br/>[searchService.ts]"]
end

subgraph group_sessions["Session and quota"]
  node_sessionctl["Session handler"]
  node_store["Session store<br/>[sessionStore.ts]"]
  node_database[("SQLite database<br/>[db.ts]")]
  node_quotactl["Quota handler<br/>[quotaController.ts]"]
  node_quota["Quota service<br/>[quotaService.ts]"]
end

subgraph group_operations["Owner controls"]
  node_adminctl["Admin handler<br/>[adminController.ts]"]
  node_admin["Admin service<br/>[adminService.ts]"]
  node_config["Runtime configuration<br/>[config.ts]"]
end

node_user(("User"))
node_web["DuckDuckGo"]

node_user -->|"uses"| node_app
node_app -->|"formats API paths"| node_api
node_app -->|"requests chat and sessions"| node_express
node_express -->|"routes chat"| node_chatctl
node_express -->|"routes sessions"| node_sessionctl
node_express -->|"routes quota"| node_quotactl
node_express -->|"routes admin"| node_adminctl
node_chatctl -->|"requests response"| node_gemini
node_chatctl -->|"reads and saves messages"| node_store
node_chatctl -->|"consumes quota"| node_quota
node_chatctl -->|"resolves identity"| node_quotactl
node_gemini -->|"invokes tools"| node_search
node_search -->|"fetches search results"| node_web
node_sessionctl -->|"manages sessions"| node_store
node_store -->|"persists sessions"| node_database
node_quotactl -->|"reads quota"| node_quota
node_quota -->|"reads and writes usage"| node_database
node_adminctl -->|"verifies and executes"| node_admin
node_adminctl -->|"checks owner settings"| node_config
node_gemini -->|"uses owner operations"| node_admin
node_vpsmodal -->|"uses API paths"| node_api
node_user -->|"enters text and files"| node_input
node_input -->|"records voice notes"| node_recorder
node_feed -->|"speaks responses"| node_speech
node_user -->|"plays voice notes"| node_audio
node_user -->|"previews generated code"| node_artifact
node_user -->|"searches session history"| node_sidebar
node_user -->|"exports conversations"| node_export

click node_app "https://github.com/dimassdwiiorg/qwertybot/blob/main/client/src/App.tsx"
click node_api "https://github.com/dimassdwiiorg/qwertybot/blob/main/client/src/utils/api.ts"
click node_feed "https://github.com/dimassdwiiorg/qwertybot/blob/main/client/src/components/ChatFeed.tsx"
click node_input "https://github.com/dimassdwiiorg/qwertybot/blob/main/client/src/components/MessageInput.tsx"
click node_recorder "https://github.com/dimassdwiiorg/qwertybot/blob/main/client/src/hooks/useAudioRecorder.ts"
click node_audio "https://github.com/dimassdwiiorg/qwertybot/blob/main/client/src/components/AudioPlayer.tsx"
click node_speech "https://github.com/dimassdwiiorg/qwertybot/blob/main/client/src/hooks/useTextToSpeech.ts"
click node_artifact "https://github.com/dimassdwiiorg/qwertybot/blob/main/client/src/components/ArtifactModal.tsx"
click node_sidebar "https://github.com/dimassdwiiorg/qwertybot/blob/main/client/src/components/Sidebar.tsx"
click node_export "https://github.com/dimassdwiiorg/qwertybot/blob/main/client/src/utils/exportUtils.ts"
click node_express "https://github.com/dimassdwiiorg/qwertybot/blob/main/server/src/index.ts"
click node_chatctl "https://github.com/dimassdwiiorg/qwertybot/blob/main/server/src/controllers/chatController.ts"
click node_gemini "https://github.com/dimassdwiiorg/qwertybot/blob/main/server/src/services/geminiService.ts"
click node_search "https://github.com/dimassdwiiorg/qwertybot/blob/main/server/src/services/searchService.ts"
click node_sessionctl "https://github.com/dimassdwiiorg/qwertybot/blob/main/server/src/controllers/sessionController.ts"
click node_store "https://github.com/dimassdwiiorg/qwertybot/blob/main/server/src/services/sessionStore.ts"
click node_database "https://github.com/dimassdwiiorg/qwertybot/blob/main/server/src/services/db.ts"
click node_quotactl "https://github.com/dimassdwiiorg/qwertybot/blob/main/server/src/controllers/quotaController.ts"
click node_quota "https://github.com/dimassdwiiorg/qwertybot/blob/main/server/src/services/quotaService.ts"
click node_adminctl "https://github.com/dimassdwiiorg/qwertybot/blob/main/server/src/controllers/adminController.ts"
click node_admin "https://github.com/dimassdwiiorg/qwertybot/blob/main/server/src/services/adminService.ts"
click node_config "https://github.com/dimassdwiiorg/qwertybot/blob/main/server/src/config.ts"
click node_vpsmodal "https://github.com/dimassdwiiorg/qwertybot/blob/main/client/src/components/VpsAuthModal.tsx"

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_api,node_feed,node_input,node_recorder,node_audio,node_speech,node_artifact,node_sidebar,node_export,node_vpsmodal,node_user toneBlue
class node_express,node_chatctl,node_gemini,node_search toneAmber
class node_sessionctl,node_store,node_database,node_quotactl,node_quota toneMint
class node_adminctl,node_admin,node_config toneRose
class node_web toneIndigo
```

## Components

### Client experience

- [Chat application](https://github.com/dimassdwiiorg/qwertybot/blob/main/client/src/App.tsx): `client/src/App.tsx`
- [API URL helper](https://github.com/dimassdwiiorg/qwertybot/blob/main/client/src/utils/api.ts): `client/src/utils/api.ts`
- [Chat feed](https://github.com/dimassdwiiorg/qwertybot/blob/main/client/src/components/ChatFeed.tsx): `client/src/components/ChatFeed.tsx`
- [Message input](https://github.com/dimassdwiiorg/qwertybot/blob/main/client/src/components/MessageInput.tsx): `client/src/components/MessageInput.tsx`
- [Audio recorder](https://github.com/dimassdwiiorg/qwertybot/blob/main/client/src/hooks/useAudioRecorder.ts): `client/src/hooks/useAudioRecorder.ts`
- [Audio player](https://github.com/dimassdwiiorg/qwertybot/blob/main/client/src/components/AudioPlayer.tsx): `client/src/components/AudioPlayer.tsx`
- [Text-to-speech](https://github.com/dimassdwiiorg/qwertybot/blob/main/client/src/hooks/useTextToSpeech.ts): `client/src/hooks/useTextToSpeech.ts`
- [Artifact preview](https://github.com/dimassdwiiorg/qwertybot/blob/main/client/src/components/ArtifactModal.tsx): `client/src/components/ArtifactModal.tsx`
- [Session sidebar](https://github.com/dimassdwiiorg/qwertybot/blob/main/client/src/components/Sidebar.tsx): `client/src/components/Sidebar.tsx`
- [Conversation export](https://github.com/dimassdwiiorg/qwertybot/blob/main/client/src/utils/exportUtils.ts): `client/src/utils/exportUtils.ts`
- [VPS access modal](https://github.com/dimassdwiiorg/qwertybot/blob/main/client/src/components/VpsAuthModal.tsx): `client/src/components/VpsAuthModal.tsx`

### Conversation services

- [Express routes](https://github.com/dimassdwiiorg/qwertybot/blob/main/server/src/index.ts): `server/src/index.ts`
- [Chat handler](https://github.com/dimassdwiiorg/qwertybot/blob/main/server/src/controllers/chatController.ts): `server/src/controllers/chatController.ts`
- [Gemini service](https://github.com/dimassdwiiorg/qwertybot/blob/main/server/src/services/geminiService.ts): `server/src/services/geminiService.ts`
- [Web search](https://github.com/dimassdwiiorg/qwertybot/blob/main/server/src/services/searchService.ts): `server/src/services/searchService.ts`

### Session and quota

- [Session handler](https://github.com/dimassdwiiorg/qwertybot/blob/main/server/src/controllers/sessionController.ts): `server/src/controllers/sessionController.ts`
- [Session store](https://github.com/dimassdwiiorg/qwertybot/blob/main/server/src/services/sessionStore.ts): `server/src/services/sessionStore.ts`
- [SQLite database](https://github.com/dimassdwiiorg/qwertybot/blob/main/server/src/services/db.ts): `server/src/services/db.ts`
- [Quota handler](https://github.com/dimassdwiiorg/qwertybot/blob/main/server/src/controllers/quotaController.ts): `server/src/controllers/quotaController.ts`
- [Quota service](https://github.com/dimassdwiiorg/qwertybot/blob/main/server/src/services/quotaService.ts): `server/src/services/quotaService.ts`

### Owner controls

- [Admin handler](https://github.com/dimassdwiiorg/qwertybot/blob/main/server/src/controllers/adminController.ts): `server/src/controllers/adminController.ts`
- [Admin service](https://github.com/dimassdwiiorg/qwertybot/blob/main/server/src/services/adminService.ts): `server/src/services/adminService.ts`
- [Runtime configuration](https://github.com/dimassdwiiorg/qwertybot/blob/main/server/src/config.ts): `server/src/config.ts`

### Other components

- **User**
- **DuckDuckGo**

## Connections

- User → Chat application: uses (evidence: `README.md`)
- Chat application → API URL helper: formats API paths (evidence: `client/src/App.tsx`)
- Chat application → Express routes: requests chat and sessions (evidence: `client/src/App.tsx`)
- Express routes → Chat handler: routes chat (evidence: `server/src/index.ts`)
- Express routes → Session handler: routes sessions (evidence: `server/src/index.ts`)
- Express routes → Quota handler: routes quota (evidence: `server/src/index.ts`)
- Express routes → Admin handler: routes admin (evidence: `server/src/index.ts`)
- Chat handler → Gemini service: requests response (evidence: `server/src/controllers/chatController.ts`)
- Chat handler → Session store: reads and saves messages (evidence: `server/src/controllers/chatController.ts`)
- Chat handler → Quota service: consumes quota (evidence: `server/src/controllers/chatController.ts`)
- Chat handler → Quota handler: resolves identity (evidence: `server/src/controllers/chatController.ts`)
- Gemini service → Web search: invokes tools (evidence: `server/src/services/geminiService.ts`)
- Web search → DuckDuckGo: fetches search results (evidence: `server/src/services/searchService.ts`)
- Session handler → Session store: manages sessions (evidence: `server/src/controllers/sessionController.ts`)
- Session store → SQLite database: persists sessions (evidence: `server/src/services/sessionStore.ts`)
- Quota handler → Quota service: reads quota (evidence: `server/src/controllers/quotaController.ts`)
- Quota service → SQLite database: reads and writes usage (evidence: `server/src/services/quotaService.ts`)
- Admin handler → Admin service: verifies and executes (evidence: `server/src/controllers/adminController.ts`)
- Admin handler → Runtime configuration: checks owner settings (evidence: `server/src/controllers/adminController.ts`)
- Gemini service → Admin service: uses owner operations (evidence: `server/src/services/geminiService.ts`)
- VPS access modal → API URL helper: uses API paths (evidence: `client/src/utils/api.ts`)
- User → Message input: enters text and files (evidence: `README.md`)
- Message input → Audio recorder: records voice notes (evidence: `client/src/components/MessageInput.tsx`)
- Chat feed → Text-to-speech: speaks responses (evidence: `client/src/components/ChatFeed.tsx`)
- User → Audio player: plays voice notes (evidence: `README.md`)
- User → Artifact preview: previews generated code (evidence: `README.md`)
- User → Session sidebar: searches session history (evidence: `README.md`)
- User → Conversation export: exports conversations (evidence: `README.md`)
