How tasssinclair/diagram-chat works
Diagram Chat accepts text and image prompts, streams model responses into a conversation, renders Markdown and supported diagram formats, and displays token metrics. The frontend owns conversation state and submits requests to an Express endpoint; the backend streams OpenRouter output and usage events. Diagram rendering is a distinct presentation stage, with Mermaid, D2, reladraw, and inline SVG support. The API route’s internal details are not excerpted, so its link to the OpenRouter adapter is supported by the source index; other uncertain wiring is omitted.
Main entry points: MarkdownRenderer.tsx Markdown renderer · App.tsx Conversation app · ChatInput.tsx Chat input · MessageBubble.tsx Message bubbles
Components 14
Chat experience
- Conversation app
src/App.tsx - Chat input
src/components/ChatInput.tsx - Message bubbles
src/components/MessageBubble.tsx - Token metrics
src/components/MetricsPanel.tsx - Conversation types
src/types.ts
Response rendering
- Markdown renderer
src/components/MarkdownRenderer.tsx - Mermaid renderer
src/components/MermaidBlock.tsx - D2 renderer
src/components/D2Block.tsx - Reladraw renderer
src/components/ReladrawBlock.tsx - Inline SVG
src/components/MarkdownRenderer.tsx
Model service
- Chat API route
server/index.ts - OpenRouter adapter
server/openrouter.ts
External services
- OpenRouter
Other components
- Chat user
Connections 12
- Chat user → Chat input: enters prompt
README.md - Chat input → Conversation app: submits text/images
src/components/ChatInput.tsx - Conversation app → Chat API route: posts chat
src/App.tsx - Chat API route → OpenRouter adapter: dispatches request
server/index.ts - OpenRouter adapter → OpenRouter: streams completion
server/openrouter.ts - Conversation app → Message bubbles: renders messages
src/App.tsx - Conversation app → Token metrics: renders usage
src/App.tsx - Message bubbles → Markdown renderer: renders content
src/components/MessageBubble.tsx - Markdown renderer → Mermaid renderer: renders Mermaid
src/components/MarkdownRenderer.tsx - Markdown renderer → D2 renderer: renders D2
src/components/MarkdownRenderer.tsx - Markdown renderer → Reladraw renderer: renders reladraw
src/components/MarkdownRenderer.tsx - Markdown renderer → Inline SVG: embeds SVG
src/components/MarkdownRenderer.tsx