How anikpal-code/multiagent-research-system works
1. Two main boundaries
- The repo is split into a backend AI service and a single Expo frontend codebase.
- The frontend runs as web, iOS, and Android from mobile/.
- The backend is a FastAPI app in the repo root, intended to be deployed separately.
2. User-facing flow
- A user enters a research topic in the mobile/web UI.
- The frontend sends that topic to the backend.
- The backend executes a four-stage research pipeline and streams intermediate progress back live.
- The UI updates incrementally instead of waiting for a final response.
3. Frontend subsystem
- mobile/App.tsx bootstraps the Expo app.
- mobile/src/screens/HomeScreen.tsx is the main interaction screen.
- mobile/src/components/StepTracker.tsx and LogCard.tsx render stage progress and event logs.
- mobile/src/api.ts is the client-side SSE/API bridge.
- mobile/src/theme.ts holds UI styling tokens.
4. Frontend architecture style
- The Expo app is a presentation layer plus a small networking layer.
- It does not implement the research logic locally.
- Its job is to collect input, subscribe to streamed backend events, and render status/output.
5. Backend entrypoint and transport
- main.py is the server entrypoint and FastAPI application.
- It exposes at least a health endpoint and the research execution endpoint.
- Progress is delivered through Server-Sent Events, which matches the “live progress” UI design.
6. Core AI orchestration
- agents.py contains the LangChain-based orchestration.
- The system is explicitly structured as four sequential agents/chains:
search → read → write → critique.
- The model referenced in the README is Mistral (mistral-small-latest) via LangChain create_agent.
7. Tooling and data access
- tools.py provides the external-data layer.
- It includes a web search tool and a URL scraping tool.
- Scraping uses requests and BeautifulSoup, so the backend depends on raw HTTP fetches plus HTML parsing rather than a browser automation stack.
8. Pipeline behavior and state flow
- The research pipeline is stateful across stages: search results feed the reader, reader output feeds the writer, and the written report feeds the critic.
- The backend emits progress as each stage completes, which is what the UI visualizes.
- This makes the system a streaming workflow engine rather than a simple request/response API.
9. Legacy/alternate execution path
- pipeline.py is the original CLI version of the same research workflow.
- It likely reuses the same core agent/tool logic but without the web/mobile streaming layer.
- In architecture terms, it is a secondary entrypoint for running the pipeline outside the UI.
10. External dependencies that matter architecturally
- The system depends on an LLM provider for generation and critique.
- It depends on web pages/search results as source material.
- Hosting is split between Render for the backend and Vercel for the frontend.
11. Operational characteristics
- The backend is on a free tier and can cold-start after inactivity, so initial latency may be significant.
- There is no evident auth or rate limiting in the repo, so the backend is meant for demo/internal use rather than open public traffic.
- The README notes the web search is currently a stub, so the search stage is an integration point rather than a fully productionized dependency.
12. What to show in an architecture diagram
- Draw a client boundary for the Expo app.
- Draw a backend boundary for FastAPI.
- Inside the backend, show a linear pipeline of four stages with shared state.
- Show SSE streaming from backend to client.
- Show external arrows to LLM provider and web/search + scraped pages.
Main entry points: HomeScreen.tsx Home screen · main.py FastAPI app · api.ts API bridge · agents.py Orchestrator
Components 16
Expo client
Mobile/web presentation layer in the Expo app
- App bootstrap · Starts the Expo application and wires the root UI
mobile/App.tsx - Home screen · Main input and results screen for research requests
mobile/src/screens/HomeScreen.tsx - API bridge · Client-side API and Server-Sent Events connection
mobile/src/api.ts - Step tracker · Renders stage progress in the research workflow
mobile/src/components/StepTracker.tsx - Log card · Displays streamed event logs and updates
mobile/src/components/LogCard.tsx - Theme tokens · Shared styling and design tokens for the Expo app
mobile/src/theme.ts
FastAPI backend
Streaming research service and orchestration pipeline
- FastAPI app · Backend entrypoint exposing health and research endpoints
main.py - Orchestrator · Coordinates the sequential research workflow and streaming events
agents.py - Search · Finds relevant sources and prepares initial evidence
- Read · Extracts and interprets content from discovered sources
- Write · Drafts the research report from gathered evidence
- Critique · Reviews and refines the drafted report
- Tools · Web search and URL scraping utilities
tools.py
CLI pipeline
Legacy non-UI execution path
- CLI pipeline · Standalone non-web entrypoint for running the workflow
pipeline.py
External systems
LLM and web data sources
- LLM provider · Hosted model used for generation and critique
- Web sources · Search results and scraped pages used as research input
Connections 18
- App bootstrap → Home screen: boots · Root app renders the main screen
- Home screen → API bridge: submits topic · User input is sent to the streaming API layer
- Home screen → Step tracker: shows progress · Main screen displays current workflow stage
- Home screen → Log card: shows logs · Main screen renders streamed events and messages
- Home screen → Theme tokens: uses theme · UI styling is shared through theme tokens
- API bridge → FastAPI app: SSE request · Client connects to backend research endpoint over streaming transport
- FastAPI app → Orchestrator: starts run · FastAPI hands each request to the research workflow
- Orchestrator → Search: stage 1 · Workflow begins with discovery of sources
- Search → Read: feeds evidence · Search output becomes input to reading
- Read → Write: feeds notes · Extracted content drives report drafting
- Write → Critique: feeds draft · Draft is reviewed and improved in the final stage
- Search → Tools: searches · Search stage uses external lookup tools
- Read → Tools: scrapes · Reading stage fetches and parses source pages
- Write → LLM provider: generates · LLM is used to write the report
- Critique → LLM provider: reviews · LLM is used for critique and refinement
- Tools → Web sources: queries · Tools access search results and page content
- FastAPI app → API bridge: streams events · Backend sends progress updates back to the client
- CLI pipeline → Orchestrator: reuses core · Legacy CLI path invokes the same workflow core