# shaeikh/konvo architecture

> Architecture diagram of the GitHub repository shaeikh/konvo, 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/shaeikh/konvo
- Repository: https://github.com/shaeikh/konvo

## Overview

Konvo is a browser-based real-time chat application with account registration and login, switchable chat rooms, message history, online-user indicators, and theme switching. The principal workflow is: a user signs in, opens the chat workspace, selects a room, loads its history, and exchanges messages through Socket.io. Better Auth provides sessions, while a PostgreSQL-backed API serves chat history. The README documents major capabilities; some client/server wiring is not visible in the sampled excerpts, so those relationships are omitted or marked unverified.

Main entry points: [`app/(main)/chat/ChatUI.tsx`](https://github.com/shaeikh/konvo/blob/main/app/(main)/chat/ChatUI.tsx) (Chat workspace UI), [`lib/auth.ts`](https://github.com/shaeikh/konvo/blob/main/lib/auth.ts) (Better Auth), [`app/(main)/chat/page.tsx`](https://github.com/shaeikh/konvo/blob/main/app/(main)/chat/page.tsx) (Chat page), [`app/(auth)/login/LoginForm.tsx`](https://github.com/shaeikh/konvo/blob/main/app/(auth)/login/LoginForm.tsx) (Login form)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_identity["Identity"]
  node_login["Login form<br/>[LoginForm.tsx]"]
  node_signup["Registration form<br/>[RegisterForm.tsx]"]
  node_validation["Auth validation<br/>[auth.ts]"]
  node_authclient["Auth client<br/>[auth-client.ts]"]
  node_authapi["Auth API routes"]
  node_authservice["Better Auth<br/>[auth.ts]"]
end

subgraph group_workspace["Chat workspace"]
  node_chatpage["Chat page<br/>[page.tsx]"]
  node_chatui["Chat workspace UI<br/>[ChatUI.tsx]"]
  node_socketclient["Socket client<br/>[socket.ts]"]
end

subgraph group_services["Server and data"]
  node_historyapi["Room history API<br/>[route.ts]"]
  node_server["Application server<br/>[server.ts]"]
  node_database[("PostgreSQL<br/>[db.ts]")]
end

subgraph group_interface["Shared interface"]
  node_ui["UI primitives"]
  node_theme["Theme controls<br/>[ModeToggle.tsx]"]
  node_themeprovider["Theme provider<br/>[theme-provider.tsx]"]
  node_metadata["Page metadata<br/>[metadata.ts]"]
end

node_visitor(("Chat user"))
node_socketservice["Socket service"]

node_visitor -->|"submits credentials"| node_login
node_visitor -->|"creates account"| node_signup
node_login -->|"validates input"| node_validation
node_signup -->|"validates input"| node_validation
node_login -->|"signs in"| node_authclient
node_signup -->|"signs up"| node_authclient
node_authclient -.->|"uses auth endpoints"| node_authapi
node_authapi -->|"dispatches requests"| node_authservice
node_authservice -.->|"stores auth data"| node_database
node_visitor -->|"opens workspace"| node_chatpage
node_chatpage -->|"renders"| node_chatui
node_chatpage -->|"checks session"| node_authservice
node_chatui -->|"uses"| node_socketclient
node_socketclient -.->|"exchanges chat events"| node_socketservice
node_chatui -.->|"loads room history"| node_historyapi
node_historyapi -->|"checks session"| node_authservice
node_historyapi -->|"queries messages"| node_database
node_server -->|"uses connection"| node_database
node_server -->|"uses auth"| node_authservice
node_chatui -->|"renders with"| node_ui
node_chatui -->|"renders toggle"| node_theme
node_theme -->|"uses controls"| node_ui
node_chatpage -->|"uses metadata"| node_metadata
node_visitor -->|"switches theme"| node_theme
node_themeprovider -.->|"provides theme context"| node_ui

click node_login "https://github.com/shaeikh/konvo/blob/main/app/(auth)/login/LoginForm.tsx"
click node_signup "https://github.com/shaeikh/konvo/blob/main/app/(auth)/signup/RegisterForm.tsx"
click node_validation "https://github.com/shaeikh/konvo/blob/main/lib/validations/auth.ts"
click node_authclient "https://github.com/shaeikh/konvo/blob/main/lib/auth-client.ts"
click node_authapi "https://github.com/shaeikh/konvo/tree/main/app/api/auth"
click node_authservice "https://github.com/shaeikh/konvo/blob/main/lib/auth.ts"
click node_chatpage "https://github.com/shaeikh/konvo/blob/main/app/(main)/chat/page.tsx"
click node_chatui "https://github.com/shaeikh/konvo/blob/main/app/(main)/chat/ChatUI.tsx"
click node_socketclient "https://github.com/shaeikh/konvo/blob/main/lib/socket.ts"
click node_historyapi "https://github.com/shaeikh/konvo/blob/main/app/api/chat/%5Broom%5D/route.ts"
click node_server "https://github.com/shaeikh/konvo/blob/main/server.ts"
click node_database "https://github.com/shaeikh/konvo/blob/main/lib/db.ts"
click node_ui "https://github.com/shaeikh/konvo/tree/main/components/ui"
click node_theme "https://github.com/shaeikh/konvo/blob/main/components/ModeToggle.tsx"
click node_themeprovider "https://github.com/shaeikh/konvo/blob/main/components/theme-provider.tsx"
click node_metadata "https://github.com/shaeikh/konvo/blob/main/config/metadata.ts"

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_login,node_signup,node_validation,node_authclient,node_authapi,node_authservice,node_visitor toneBlue
class node_chatpage,node_chatui,node_socketclient toneAmber
class node_historyapi,node_server,node_database toneMint
class node_ui,node_theme,node_themeprovider,node_metadata toneRose
class node_socketservice toneIndigo
```

## Components

### Identity

- [Login form](https://github.com/shaeikh/konvo/blob/main/app/(auth)/login/LoginForm.tsx): `app/(auth)/login/LoginForm.tsx`
- [Registration form](https://github.com/shaeikh/konvo/blob/main/app/(auth)/signup/RegisterForm.tsx): `app/(auth)/signup/RegisterForm.tsx`
- [Auth validation](https://github.com/shaeikh/konvo/blob/main/lib/validations/auth.ts): `lib/validations/auth.ts`
- [Auth client](https://github.com/shaeikh/konvo/blob/main/lib/auth-client.ts): `lib/auth-client.ts`
- [Auth API routes](https://github.com/shaeikh/konvo/tree/main/app/api/auth): `app/api/auth`
- [Better Auth](https://github.com/shaeikh/konvo/blob/main/lib/auth.ts): `lib/auth.ts`

### Chat workspace

- [Chat page](https://github.com/shaeikh/konvo/blob/main/app/(main)/chat/page.tsx): `app/(main)/chat/page.tsx`
- [Chat workspace UI](https://github.com/shaeikh/konvo/blob/main/app/(main)/chat/ChatUI.tsx): `app/(main)/chat/ChatUI.tsx`
- [Socket client](https://github.com/shaeikh/konvo/blob/main/lib/socket.ts): `lib/socket.ts`

### Server and data

- [Room history API](https://github.com/shaeikh/konvo/blob/main/app/api/chat/%5Broom%5D/route.ts): `app/api/chat/[room]/route.ts`
- [Application server](https://github.com/shaeikh/konvo/blob/main/server.ts): `server.ts`
- [PostgreSQL](https://github.com/shaeikh/konvo/blob/main/lib/db.ts): `lib/db.ts`

### Shared interface

- [UI primitives](https://github.com/shaeikh/konvo/tree/main/components/ui): `components/ui`
- [Theme controls](https://github.com/shaeikh/konvo/blob/main/components/ModeToggle.tsx): `components/ModeToggle.tsx`
- [Theme provider](https://github.com/shaeikh/konvo/blob/main/components/theme-provider.tsx): `components/theme-provider.tsx`
- [Page metadata](https://github.com/shaeikh/konvo/blob/main/config/metadata.ts): `config/metadata.ts`

### Other components

- **Chat user**
- **Socket service**

## Connections

- Chat user → Login form: submits credentials (evidence: `app/(auth)/login/LoginForm.tsx`)
- Chat user → Registration form: creates account (evidence: `app/(auth)/signup/RegisterForm.tsx`)
- Login form → Auth validation: validates input (evidence: `app/(auth)/login/LoginForm.tsx`)
- Registration form → Auth validation: validates input (evidence: `app/(auth)/signup/RegisterForm.tsx`)
- Login form → Auth client: signs in (evidence: `app/(auth)/login/LoginForm.tsx`)
- Registration form → Auth client: signs up (evidence: `app/(auth)/signup/RegisterForm.tsx`)
- Auth client → Auth API routes: uses auth endpoints
- Auth API routes → Better Auth: dispatches requests (evidence: `app/api/auth/[...all]/route.ts`)
- Better Auth → PostgreSQL: stores auth data (evidence: `lib/auth.ts`)
- Chat user → Chat page: opens workspace (evidence: `README.md`)
- Chat page → Chat workspace UI: renders (evidence: `app/(main)/chat/page.tsx`)
- Chat page → Better Auth: checks session (evidence: `app/(main)/chat/page.tsx`)
- Chat workspace UI → Socket client: uses (evidence: `app/(main)/chat/ChatUI.tsx`)
- Socket client → Socket service: exchanges chat events
- Chat workspace UI → Room history API: loads room history
- Room history API → Better Auth: checks session (evidence: `app/api/chat/[room]/route.ts`)
- Room history API → PostgreSQL: queries messages (evidence: `app/api/chat/[room]/route.ts`)
- Application server → PostgreSQL: uses connection (evidence: `server.ts`)
- Application server → Better Auth: uses auth (evidence: `server.ts`)
- Chat workspace UI → UI primitives: renders with (evidence: `app/(main)/chat/ChatUI.tsx`)
- Chat workspace UI → Theme controls: renders toggle (evidence: `app/(main)/chat/ChatUI.tsx`)
- Theme controls → UI primitives: uses controls (evidence: `components/ModeToggle.tsx`)
- Chat page → Page metadata: uses metadata (evidence: `app/(main)/chat/page.tsx`)
- Chat user → Theme controls: switches theme (evidence: `README.md`)
- Theme provider → UI primitives: provides theme context
