How todap/multiagent-research works
Project type and overall purpose
• This is a full-stack, single-process Python application with a Streamlit frontend and a LangChain/LangGraph-based backend orchestrator.
• Purpose: Provide an AI-driven “Company Research Assistant” that runs through multiple specialized AI agents to generate reports, interactive dashboards, and PDF exports.
File structure
• Top level:
• app1.py – Streamlit entry point and UI definitions
• workflow.py – LangGraph workflow orchestration code
• state.py – Shared data models (e.g., ResearchState, session info)
• Tools/ – Directory containing one Python file per AI “agent” (industryResearchTool.py, useCaseGeneratorTool.py, etc.)
• No separate “frontend”/“backend” folders, but app1.py contains UI logic, workflow.py + Tools/ contain backend logic.
• Presence of SQLite DB (via sqlite3 in code), caching logic (24-hour validity), PDF export libs, Plotly for charts, and external API integration scripts.
Extract architecture details from the README
• Multi-Agent Workflow broken into seven specialized agents
• Streamlit handles UI, user auth, session management
• LangGraph orchestrates agents in workflow.py
• SQLite for user and cache persistence
• External services: OpenRouter/Local LM Studio for LLM; Tavily for web search
• Output channels: Streamlit charts (Plotly) and PDF reports (FPDF/ReportLab)
Main components
a. Frontend (Streamlit)
• UI Layers: Login/Register, Sidebar Navigation, Tabbed Results, Interactive Charts
• “Start Research” button → triggers backend
b. Session/Auth Layer
• Session manager with “Remember Me”
• SQLite user table + SHA-256 hashing
c. Workflow Orchestrator
• workflow.py orchestrating LangGraph graph
• Coordinates sequence of AI agents
d. AI Agent Modules (Tools/)
• IndustryResearchAgent
• UseCaseGeneratorAgent
• AIRecommendationAgent
• ResourceCollectorAgent
• CompetitorAnalysisAgent
• ImplementationPlanningAgent
• CostBenefitAgent
e. Data Storage & Caching
• SQLite database: user info, cached reports
• Cache validity logic (24h)
f. External Services
• OpenRouter API or Local LM Studio (LLM calls)
• Tavily API (web search for agent data)
g. Visualization & Reporting
• Plotly for in-UI charts
• FPDF/ReportLab for PDF export
Relationships and data flow
1. User clicks “Start Research” in Streamlit UI
2. UI passes parameters (company names, industry) to workflow orchestrator
3. workflow.py instantiates each agent in turn:
– Industry Research → LLM + Tavily → writes to state
– Use Case Generator → LLM → state
– … and so on for all agents
4. After each agent run, results appended to shared ResearchState
5. Results stored/cached in SQLite
6. Streamlit UI reads state to render interactive tabs and charts (Plotly)
7. On “Download PDF,” PDF exporter reads state and generates report
Architectural patterns & design principles
• Modular multi-agent pipeline (each tool is an independent module adhering to a common interface)
• Separation of concerns: UI vs. orchestration vs. agent implementations vs. persistence
• Cache-aside pattern for avoiding duplicate work
• Layered architecture: Presentation → Orchestration → Domain/Agents → External Dependencies → Persistence
• Rounded rectangles for UI components
• Rectangles for backend modules (orchestrator, agents)
• Clouds for external APIs
• User → UI → Orchestrator
• Orchestrator → Agent → External Service
• Agent → State/DB → UI
• UI → PDF Export