The Problem
Developers need a ready‑made, fully‑client chat UI that can be dropped into a web page, supports multiple conversations, uploads, voice input, and rich markdown rendering, all without a custom backend. The repo delivers a self‑contained demo that can run locally or be built as a static site.
What This Does
The application is a single‑page React UI (see src/main.tsx → src/app/App.tsx).
- Conversation management:
src/services/chat/store.tsandsrc/services/chat/db.tspersist messages in IndexedDB, whilesrc/services/chat/history/*.tsprovide import/export of ZIP archives. - Messaging:
src/services/api/client.tssends requests to the configured DeepSeek endpoint, andsrc/services/api/sse.tsstreams responses back to the UI. - Rich input:
src/components/chatInput/ChatInput.tsxsupports text, file drag‑drop, voice recording (useVoiceInput.ts), and a live audio spectrum (src/components/chatInput/Spectrum.tsx). - Markdown rendering:
src/components/markdown/Markdown.tsxrenders markdown with syntax highlighting, KaTeX math, and Mermaid diagrams (src/services/markdown/*). - UX features: Themes, internationalisation (
src/i18n/*), and a collapsible sidebar (src/components/sider/*) give a polished look.
How It Is Wired
- Entry point:
src/main.tsxmounts<App />into the DOM. - App (
src/app/App.tsx) pulls global CSS (theme.css,global.css), sets up routing, and renders the main layout: sidebar, session view, and chat panel. - Session view (
src/components/session/SessionView.tsx) lists conversations stored inIndexedDBviastore.ts. Selecting a session loads messages throughsrc/services/chat/view.ts. - Chat panel (
src/components/messages/MessageList.tsx) iterates overMessageobjects. Each message is rendered byUserMessage.tsxorAssistantMessage.tsx. - Sending a message:
MessageListdispatchessendMessage()fromsrc/services/chat/reply.ts. reply.tscomposes the request payload, callsclient.send()fromsrc/services/api/client.ts.client.tsusesfetchto POST to the API, then pipes the response tosse.ts.sse.tsparses the server‑sent events viaparseEvent.tsand streams text chunks back to the UI.- Attachments: When a file is uploaded,
src/services/attachments.tsuploads it to the API, and the resulting file ID is stored in the message object. - State persistence:
services/settings.tsstores the API key and user preferences inlocalStorage;store.tswrites conversation data toIndexedDB.
The module graph shows a clear single‑entry path: main.tsx → App.tsx → SessionView.tsx / MessageList.tsx → reply.ts → client.ts → sse.ts. The only external interaction is the HTTP(S) request to the configured DeepSeek API. There are no hidden side‑effects beyond browser storage.
How To Use It
- Setup ``
sh git clone https://github.com/moses-y/chat-demo cd chat-demo pnpm install`` - Configuration The API base URL is set in
rspack.config.ts(apiOrigin: 'https://api.deepseek.com'). Override it by editing that file or usingcreateConfig({ apiOrigin }). - Running locally ``
sh pnpm dev`Openhttp://localhost:8090`. - Building a static bundle ``
sh pnpm build`The output appears indist/. Opendist/index.html` or deploy the folder. - Using the UI 1. Open Settings (icon in the top bar). 2. Enter a DeepSeek API key. 3. Start a new chat or load an existing conversation.
Real‑World Use
A team can embed the demo into an internal knowledge‑base portal. By serving dist/index.html from the same origin as the portal, the chat UI can share localStorage settings and IndexedDB data with other components. The src/components/markdown/Markdown.tsx module can be reused in tutorials or help pages, providing consistent rendering of code, math, and diagrams.
Code Health & Issues
- Tests: 3 Jest test files (
src/components/*.test.tsx), covering UI components. - CI: GitHub Actions workflow (
.github/workflows/pages.yml) runs tests, lint (oxlint), and build. - License: MIT license file present.
- Build tooling: Uses Rspack; configuration is straightforward.
- Potential pain points
- High – No server backend; all network traffic goes to the external DeepSeek service, which may impose CORS or rate limits.
- Medium – Voice input relies on
navigator.mediaDevices; not all browsers support the required APIs on file:// origins. - Low – No TypeScript declaration files for CSS modules; the repo includes
.d.tsstubs but they are not exhaustive.
The Bottom Line
The repo delivers a feature‑rich, static chat front‑end that can be built or run directly. Its architecture is clear: a React SPA that persists data in IndexedDB and communicates with a DeepSeek API via a thin client layer. The code is well organized, with a dedicated services layer and isolated UI components. For teams needing a quick, embeddable chat UI that supports attachments, voice, and markdown, this demo is a solid starting point. The main limitation is the reliance on an external API endpoint; adding a custom backend would require minimal changes to the client.ts module.