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.ts and src/services/chat/db.ts persist messages in IndexedDB, while src/services/chat/history/*.ts provide import/export of ZIP archives.
  • Messaging: src/services/api/client.ts sends requests to the configured DeepSeek endpoint, and src/services/api/sse.ts streams responses back to the UI.
  • Rich input: src/components/chatInput/ChatInput.tsx supports text, file drag‑drop, voice recording (useVoiceInput.ts), and a live audio spectrum (src/components/chatInput/Spectrum.tsx).
  • Markdown rendering: src/components/markdown/Markdown.tsx renders 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.tsx mounts <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 in IndexedDB via store.ts. Selecting a session loads messages through src/services/chat/view.ts.
  • Chat panel (src/components/messages/MessageList.tsx) iterates over Message objects. Each message is rendered by UserMessage.tsx or AssistantMessage.tsx.
  • Sending a message: MessageList dispatches sendMessage() from src/services/chat/reply.ts.
  • reply.ts composes the request payload, calls client.send() from src/services/api/client.ts.
  • client.ts uses fetch to POST to the API, then pipes the response to sse.ts.
  • sse.ts parses the server‑sent events via parseEvent.ts and streams text chunks back to the UI.
  • Attachments: When a file is uploaded, src/services/attachments.ts uploads it to the API, and the resulting file ID is stored in the message object.
  • State persistence: services/settings.ts stores the API key and user preferences in localStorage; store.ts writes conversation data to IndexedDB.

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 using createConfig({ apiOrigin }).
  • Running locally ``sh pnpm dev ` Open http://localhost:8090`.
  • Building a static bundle ``sh pnpm build ` The output appears in dist/. Open dist/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.ts stubs 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.