How bodanlabs/deepagents-showcase works
1. Repository shape
- This is a two-app monorepo: apps/api is the Python backend, and apps/web is the React frontend.
- The root-level pnpm workspace and docker-compose.yml exist to coordinate local development and containerized runs across both apps.
2. Backend boundary
- apps/api is a FastAPI service that owns all agent execution and conversation orchestration.
- It exposes a chat API and a streaming chat endpoint, plus a lightweight health check for readiness/liveness.
3. Agent runtime
- The backend’s core responsibility is to wrap a LangChain Deep Agents setup backed by OpenAI.
- app/services/agent.py is the agent-facing layer; app/services/chat_service.py likely sits above it to convert HTTP chat requests into agent invocations and streaming events.
4. API contract
- app/schemas/chat.py defines the request/response models that separate the frontend contract from internal agent logic.
- This is the main boundary for the chat protocol: user messages go in, assistant/tool/reasoning events come back, with streaming as a first-class path.
5. Backend configuration and observability
- app/core/config.py centralizes runtime settings such as OpenAI model selection, CORS, and log level.
- app/core/logging.py handles service logging, which is important because streaming agent runs are otherwise hard to debug.
6. Backend delivery model
- The important transport detail is Server-Sent Events: /api/chat/stream streams incremental agent output instead of waiting for a single response.
- The non-streaming endpoint likely exists for simpler request/response usage or compatibility, while SSE is what powers the live UI experience.
7. Frontend boundary
- apps/web is a Vite + React + TypeScript app that renders the chat experience.
- It does not run the agent itself; its job is to connect to the backend stream, translate events into assistant-ui state, and render them interactively.
8. Frontend runtime and streaming adapter
- src/runtime/LocalRuntimeProvider.tsx suggests the app uses assistant-ui’s local runtime abstraction rather than a remote SDK-specific runtime.
- src/lib/sse.ts is the key integration point: it adapts the backend’s SSE stream into the event format the UI runtime expects.
9. UI composition
- src/components/assistant-ui/* contains custom rendering for assistant messages, reasoning traces, tool-call cards/groups, and file previews.
- These components indicate the backend emits structured agent metadata, not just plain text, and the frontend preserves that structure in the conversation view.
10. Deployment and environment model
- The repo is designed to run either with local processes or with Docker Compose.
- The backend depends on environment variables for OpenAI credentials and allowed CORS origins; the frontend can optionally override the API base URL through its own env file.
11. Testing and validation
- apps/api/tests contains health and chat tests, which implies the backend is the main unit-tested surface.
- There is no separate backend worker or database layer in this tree, so the architecture is intentionally stateless aside from request/session context and external OpenAI calls.
12. What to draw in an architecture diagram
- Show one user-facing React UI, one FastAPI API, one streaming SSE channel between them, and one external dependency on OpenAI via the Deep Agents/LangChain stack.
- The main flow is: user message in the web app → SSE request to FastAPI → agent execution in the API → streamed tool/reasoning/message events back to the UI.
Main entry points: main.py API app · main.tsx Web app · chat_service.py Chat service · docker-compose.yml Compose
Components 18
Monorepo
Workspace and deployment glue for both apps
- pnpm workspace · Root package management and shared dev orchestration
pnpm-workspace.yaml - Compose · Local multi-service runtime for API and web
docker-compose.yml
Backend
FastAPI service that runs the agent and chat API
- API app · Bootstraps the FastAPI service and routes
apps/api/app/main.py - Settings · Runtime configuration for model, CORS, and logging
apps/api/app/core/config.py - Logging · Service logging for agent and request runs
apps/api/app/core/logging.py - Chat schema · Request and response models for the chat protocol
apps/api/app/schemas/chat.py - Chat service · Converts HTTP chat calls into agent execution and stream events
apps/api/app/services/chat_service.py - Agent runtime · Deep Agents and OpenAI-backed agent execution layer
apps/api/app/services/agent.py - Health check · Lightweight readiness and liveness surface
apps/api/app/main.py - Chat API · Non-streaming chat request-response endpoint
apps/api/app/main.py - SSE stream · Streaming chat endpoint that emits incremental events
apps/api/app/main.py - API tests · Health and chat validation coverage
apps/api/tests/test_chat.py
Frontend
React chat UI that consumes the streaming API
- Web app · Bootstraps the React chat experience
apps/web/src/main.tsx - Local runtime · Assistant UI local runtime wrapper for the conversation
apps/web/src/runtime/LocalRuntimeProvider.tsx - SSE adapter · Maps backend SSE events into UI runtime events
apps/web/src/lib/sse.ts - UI components · Custom rendering for messages, reasoning, tools, and files
apps/web/src/components/assistant-ui/assistant-message.tsx - Chat UI · Conversation interface for sending messages and rendering streamed assistant output
apps/web/src/App.tsx
Other components
- OpenAI · External model and tool execution backend used by the agent
Connections 21
- pnpm workspace → Compose: coordinates · Workspace and compose config orchestrate local runs
- Compose → API app: starts · Compose launches the backend service
- Compose → Web app: starts · Compose launches the frontend service
- API app → Settings: loads · API entrypoint reads runtime settings
- API app → Logging: initializes · Service boot sets up logging
- API app → Chat API: exposes · Non-streaming chat route
- API app → SSE stream: exposes · Streaming SSE chat route
- API app → Health check: exposes · Health/readiness route
- Chat API → Chat service: delegates · Chat requests are handed to orchestration layer
- SSE stream → Chat service: delegates · SSE requests are converted into agent streams
- Chat service → Chat schema: validates · HTTP boundary uses chat request/response models
- Chat service → Agent runtime: invokes · Orchestrates agent execution
- Agent runtime → OpenAI: calls · Agent runtime depends on external model API
- API tests → Health check: covers · Health behavior is tested
- API tests → Chat API: covers · Chat behavior is tested
- Web app → Local runtime: uses · React app is wrapped in the assistant runtime
- Local runtime → SSE adapter: streams via · Runtime receives backend events through SSE adapter
- SSE adapter → SSE stream: connects to · Frontend opens the backend SSE chat endpoint
- Web app → UI components: renders with · Conversation UI uses custom assistant message components
- Web app → Chat API: fallbacks to · Frontend can also use non-streaming chat path
- UI components → Local runtime: displays · Structured agent events are rendered into UI state