# peaz6/seng architecture

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

- Interactive diagram: https://gitdiagram.com/peaz6/seng
- Repository: https://github.com/peaz6/seng

## Overview

Seng is a Jinghpaw chat assistant grounded in a curated Kachin–English corpus. Users sign in (signup is invite-only), then send, edit, or regenerate messages in conversations; the client streams replies and supports conversation management and account settings. The backend runs chat/tool-calling and dataset-only translation against the corpus, while storing accounts and chats separately. The graph includes documented capabilities whose implementation details were not sampled; those links rely on README statements rather than inspection of every route or component.

Main entry points: [`src/App.tsx`](https://github.com/peaz6/seng/blob/main/src/App.tsx) (App routing), [`src/pages/Chat.tsx`](https://github.com/peaz6/seng/blob/main/src/pages/Chat.tsx) (Chat pages), [`server/src/index.ts`](https://github.com/peaz6/seng/blob/main/server/src/index.ts) (HTTP API routes), [`src/components/app-provider.tsx`](https://github.com/peaz6/seng/blob/main/src/components/app-provider.tsx) (Chat state and actions)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web application"]
  node_routes["App routing<br/>[App.tsx]"]
end

subgraph group_identity["Accounts and access"]
  node_authpages["Login and signup<br/>[Login.tsx]"]
  node_authstate["Auth state<br/>[auth-context.tsx]"]
  node_authhook["Auth access hook<br/>[use-auth.ts]"]
  node_settings["Account settings"]
end

subgraph group_chat["Conversation experience"]
  node_provider["Chat state and actions<br/>[app-provider.tsx]"]
  node_chatpage["Chat pages<br/>[Chat.tsx]"]
  node_chatui["Chat interface<br/>[chat-layout.tsx]"]
  node_thread["Message thread<br/>[chat-thread.tsx]"]
  node_message["Message rendering<br/>[chat-message.tsx]"]
  node_composer["Message composer"]
  node_chatapi["Chat API client<br/>[chat-api.ts]"]
  node_chattypes["Chat contracts<br/>[chat.ts]"]
end

subgraph group_api["Backend services"]
  node_server["HTTP API routes<br/>[index.ts]"]
  node_authlogic["Identity and account logic<br/>[auth.ts]"]
  node_model["Grounded chat and translation<br/>[model.ts]"]
end

subgraph group_data["Persistent data"]
  node_corpus["Corpus queries<br/>[db.ts]"]
  node_accountstore[("Account and chat database<br/>[auth.ts]")]
  node_corpusstore[("Kachin corpus database<br/>[db.ts]")]
end

node_visitor(("Visitor or user"))
node_ollama["Local Ollama model"]

node_visitor -->|"opens app"| node_routes
node_routes -->|"routes to"| node_authpages
node_routes -->|"wraps chat"| node_provider
node_routes -->|"renders"| node_chatui
node_authpages -->|"uses auth"| node_authhook
node_authhook -->|"reads context"| node_authstate
node_authstate -.->|"calls account API"| node_authlogic
node_routes -->|"routes to"| node_settings
node_settings -->|"uses auth"| node_authhook
node_settings -->|"requests account actions"| node_server
node_chatui -->|"hosts pages"| node_chatpage
node_chatpage -->|"uses chat state"| node_provider
node_chatpage -->|"renders thread"| node_thread
node_chatpage -->|"renders composer"| node_composer
node_thread -->|"renders messages"| node_message
node_composer -->|"sends actions"| node_provider
node_provider -->|"loads and streams"| node_chatapi
node_chatapi -->|"HTTP requests"| node_server
node_chatapi -->|"uses contracts"| node_chattypes
node_server -->|"routes account operations"| node_authlogic
node_server -->|"dispatches chat"| node_model
node_authlogic -->|"persists accounts and chats"| node_accountstore
node_model -->|"queries dataset"| node_corpus
node_corpus -->|"reads corpus"| node_corpusstore
node_model -->|"uses local model"| node_ollama

click node_routes "https://github.com/peaz6/seng/blob/main/src/App.tsx"
click node_authpages "https://github.com/peaz6/seng/blob/main/src/pages/Login.tsx"
click node_authstate "https://github.com/peaz6/seng/blob/main/src/context/auth-context.tsx"
click node_authhook "https://github.com/peaz6/seng/blob/main/src/hooks/use-auth.ts"
click node_settings "https://github.com/peaz6/seng/blob/main/src/pages/AccountSettings.tsx"
click node_provider "https://github.com/peaz6/seng/blob/main/src/components/app-provider.tsx"
click node_chatpage "https://github.com/peaz6/seng/blob/main/src/pages/Chat.tsx"
click node_chatui "https://github.com/peaz6/seng/blob/main/src/components/chat-layout.tsx"
click node_thread "https://github.com/peaz6/seng/blob/main/src/components/chat-thread.tsx"
click node_message "https://github.com/peaz6/seng/blob/main/src/components/chat-message.tsx"
click node_composer "https://github.com/peaz6/seng/blob/main/src/components/message-composer.tsx"
click node_chatapi "https://github.com/peaz6/seng/blob/main/src/services/chat-api.ts"
click node_chattypes "https://github.com/peaz6/seng/blob/main/src/types/chat.ts"
click node_server "https://github.com/peaz6/seng/blob/main/server/src/index.ts"
click node_authlogic "https://github.com/peaz6/seng/blob/main/server/src/auth.ts"
click node_model "https://github.com/peaz6/seng/blob/main/server/src/model.ts"
click node_corpus "https://github.com/peaz6/seng/blob/main/server/src/db.ts"
click node_accountstore "https://github.com/peaz6/seng/blob/main/server/src/auth.ts"
click node_corpusstore "https://github.com/peaz6/seng/blob/main/server/src/db.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_routes,node_visitor toneBlue
class node_authpages,node_authstate,node_authhook,node_settings toneAmber
class node_provider,node_chatpage,node_chatui,node_thread,node_message,node_composer,node_chatapi,node_chattypes toneMint
class node_server,node_authlogic,node_model toneRose
class node_corpus,node_accountstore,node_corpusstore,node_ollama toneIndigo
```

## Components

### Web application

- [App routing](https://github.com/peaz6/seng/blob/main/src/App.tsx): `src/App.tsx`

### Accounts and access

- [Login and signup](https://github.com/peaz6/seng/blob/main/src/pages/Login.tsx): `src/pages/Login.tsx`
- [Auth state](https://github.com/peaz6/seng/blob/main/src/context/auth-context.tsx): `src/context/auth-context.tsx`
- [Auth access hook](https://github.com/peaz6/seng/blob/main/src/hooks/use-auth.ts): `src/hooks/use-auth.ts`
- [Account settings](https://github.com/peaz6/seng/blob/main/src/pages/AccountSettings.tsx): `src/pages/AccountSettings.tsx`

### Conversation experience

- [Chat state and actions](https://github.com/peaz6/seng/blob/main/src/components/app-provider.tsx): `src/components/app-provider.tsx`
- [Chat pages](https://github.com/peaz6/seng/blob/main/src/pages/Chat.tsx): `src/pages/Chat.tsx`
- [Chat interface](https://github.com/peaz6/seng/blob/main/src/components/chat-layout.tsx): `src/components/chat-layout.tsx`
- [Message thread](https://github.com/peaz6/seng/blob/main/src/components/chat-thread.tsx): `src/components/chat-thread.tsx`
- [Message rendering](https://github.com/peaz6/seng/blob/main/src/components/chat-message.tsx): `src/components/chat-message.tsx`
- [Message composer](https://github.com/peaz6/seng/blob/main/src/components/message-composer.tsx): `src/components/message-composer.tsx`
- [Chat API client](https://github.com/peaz6/seng/blob/main/src/services/chat-api.ts): `src/services/chat-api.ts`
- [Chat contracts](https://github.com/peaz6/seng/blob/main/src/types/chat.ts): `src/types/chat.ts`

### Backend services

- [HTTP API routes](https://github.com/peaz6/seng/blob/main/server/src/index.ts): `server/src/index.ts`
- [Identity and account logic](https://github.com/peaz6/seng/blob/main/server/src/auth.ts): `server/src/auth.ts`
- [Grounded chat and translation](https://github.com/peaz6/seng/blob/main/server/src/model.ts): `server/src/model.ts`

### Persistent data

- [Corpus queries](https://github.com/peaz6/seng/blob/main/server/src/db.ts): `server/src/db.ts`
- [Account and chat database](https://github.com/peaz6/seng/blob/main/server/src/auth.ts): `server/src/auth.ts`
- [Kachin corpus database](https://github.com/peaz6/seng/blob/main/server/src/db.ts): `server/src/db.ts`

### Other components

- **Visitor or user**
- **Local Ollama model**

## Connections

- Visitor or user → App routing: opens app (evidence: `src/App.tsx`)
- App routing → Login and signup: routes to (evidence: `src/App.tsx`)
- App routing → Chat state and actions: wraps chat (evidence: `src/App.tsx`)
- App routing → Chat interface: renders (evidence: `src/App.tsx`)
- Login and signup → Auth access hook: uses auth (evidence: `src/pages/Login.tsx`)
- Auth access hook → Auth state: reads context (evidence: `src/hooks/use-auth.ts`)
- Auth state → Identity and account logic: calls account API
- App routing → Account settings: routes to (evidence: `src/App.tsx`)
- Account settings → Auth access hook: uses auth (evidence: `src/pages/AccountSettings.tsx`)
- Account settings → HTTP API routes: requests account actions (evidence: `src/pages/AccountSettings.tsx`)
- Chat interface → Chat pages: hosts pages (evidence: `src/components/chat-layout.tsx`)
- Chat pages → Chat state and actions: uses chat state (evidence: `src/pages/Chat.tsx`)
- Chat pages → Message thread: renders thread (evidence: `src/pages/Chat.tsx`)
- Chat pages → Message composer: renders composer (evidence: `src/pages/Chat.tsx`)
- Message thread → Message rendering: renders messages (evidence: `src/components/chat-thread.tsx`)
- Message composer → Chat state and actions: sends actions (evidence: `src/components/message-composer.tsx`)
- Chat state and actions → Chat API client: loads and streams (evidence: `src/components/app-provider.tsx`)
- Chat API client → HTTP API routes: HTTP requests (evidence: `README.md`)
- Chat API client → Chat contracts: uses contracts (evidence: `src/services/chat-api.ts`)
- HTTP API routes → Identity and account logic: routes account operations (evidence: `server/src/index.ts`)
- HTTP API routes → Grounded chat and translation: dispatches chat (evidence: `server/src/index.ts`)
- Identity and account logic → Account and chat database: persists accounts and chats (evidence: `README.md`)
- Grounded chat and translation → Corpus queries: queries dataset (evidence: `server/src/model.ts`)
- Corpus queries → Kachin corpus database: reads corpus (evidence: `README.md`)
- Grounded chat and translation → Local Ollama model: uses local model (evidence: `README.md`)
