Project 2 — Streaming AI chatbot
Practice this questionRequirements
Show progress/text incrementally, allow cancellation, and distinguish completion from stream failure. Preserve final message state.
Architecture
Provider events → Node public-event adapter → streamed fetch/SSE → React. The adapter filters internals; React maintains partial text and terminal status.
Technologies
Provider streaming SDK, Web Streams or Node response streams, abort signals, React incremental state.
Database design
Add message state generating/completed/failed/cancelled; use stable request/run IDs. Partial drafts must not appear as final messages.
API design
Stream events with bounded payloads and an explicit terminal event. Define how a client retrieves final status after disconnect.
AI design
Same task as project 1; expose only approved text/progress. Buffer content if output policy requires validation before display.
Security
Authenticate before opening the stream; do not stream raw state, tool args, or private traces. Enforce connection and rate limits.
Evaluation
Midstream failure, disconnected browser, cancellation, provider refusal, proxy buffering, and incomplete generation.
Observability
Time to first public token, total completion, active connections, aborts, stream errors, and usage.
Deployment
Verify hosting/proxy streaming support, buffering, idle/request limits, and safe reconnection behavior.
Interview questions
- “Does streaming reduce cost?” Answer: it mainly improves perceived latency; cost falls only if less work is done.
- “Can you execute streamed JSON?” Answer: wait for completion and validation.
Acceptance: The UI never confuses a partial response with a successful complete result.