How dwisusanto29/llm-chat-app-template works
This is a Cloudflare Workers AI chat template. A user enters a message in the browser UI; the client adds it to local conversation history and POSTs that history to the Worker. The Worker routes the request, adds a system prompt when needed, invokes Workers AI, and returns its streaming response for the client to render and retain. The README also documents optional AI Gateway integration and observability; Gateway wiring is commented out in the sampled handler. The graph reflects the available source excerpts and documented capabilities.
Main entry points: index.ts Chat handler · chat.js Chat client · index.html Chat page
Components 10
Browser chat
- Chat page
public/index.html - Chat client
public/chat.js
Worker API
- Request router
src/index.ts - Chat handler
src/index.ts - Message types
src/types.ts - Static assets
- Worker logs
AI services
- Workers AI
- AI Gateway
Other components
- Chat user
Connections 12
- Chat user → Chat page: uses
- Chat page → Chat client: loads script
- Chat client → Chat user: renders replies
- Request router → Static assets: fetches assets
- Chat client → Request router: POSTs chat
- Request router → Chat handler: dispatches
- Chat handler → Workers AI: runs model
- Chat handler → AI Gateway: can route via
- Workers AI → Chat handler: streams response
- Chat handler → Chat client: returns stream
- Chat client → Chat client: updates history
- Chat handler → Worker logs: logs errors