How victor-gabriel-barbosa/chatgpu works
ChatGPU is a browser-only conversational LLM: users select or download a model, send prompts through the React chat, and receive streamed local inference without a chat backend. The main control path runs from the page through session orchestration to local inference, while chat history persists in IndexedDB. The README documents model caching, WebGPU/WASM inference, streaming and generation controls; sampled source confirms the main UI, session, worker and storage relationships. Some inference details rely on README documentation because not all implementation files were sampled.
Main entry points: page.tsx Chat page · use-session.ts Session orchestration · use-engine.ts Engine lifecycle · worker.ts Inference worker
Components 16
Chat experience
- Chat page
app/page.tsx - Session orchestration
hooks/use-session.ts - File extraction
lib/fileToText.ts
Local inference
- Reply streaming
lib/stream-assistant-reply.ts - Engine lifecycle
hooks/use-engine.ts - Inference worker
lib/worker.ts - WebLLM runtime
- WebGPU / WASM
- Model manager
components/model-manager-modal.tsx - Model cache
hooks/use-model-cache.ts
Browser data
- Chat database
db/database.ts
UI components
- Conversation sidebar
components/app-sidebar.tsx - Message renderer
components/chat-message.tsx - Code renderer
components/code-block.tsx - Chat settings
components/settings-modal.tsx
Other components
- User
Connections 15
- User → Chat page: sends prompts
- Chat page → Session orchestration: manages chat
app/page.tsx - Chat page → Engine lifecycle: selects model
app/page.tsx - Chat page → Message renderer: renders messages
app/page.tsx - Chat page → Conversation sidebar: renders navigation
app/page.tsx - Chat page → Model manager: opens manager
app/page.tsx - Chat page → Chat settings: opens settings
app/page.tsx - Session orchestration → Chat database: reads and writes
hooks/use-session.ts - Session orchestration → File extraction: extracts attachments
hooks/use-session.ts - Session orchestration → Reply streaming: starts generation
hooks/use-session.ts - Engine lifecycle → Inference worker: creates worker
hooks/use-engine.ts - Inference worker → WebLLM runtime: runs model
- WebLLM runtime → WebGPU / WASM: infers locally
- Model manager → Model cache: manages downloads
components/model-manager-modal.tsx - Message renderer → Code renderer: renders code
components/chat-message.tsx