How moumit-b/bu-senior-design-emd-serono works
1. Overall shape
This repo is a multi-agent research platform for pharma competitive intelligence. It has two major runtime halves:
- a Python Streamlit application in streamlit-app/ for chat, reports, governance, persistence, and orchestration
- a set of MCP tool servers in servers/ that expose external biomedical and knowledge data sources
2. Primary user-facing entry point
The main application is the Streamlit UI (streamlit-app/app.py). It provides:
- conversational research chat
- report generation
- governance/audit views
- tool usage metrics
- session history and saved reports
3. Agent orchestration layer
The application routes user requests through an agent orchestrator stack in streamlit-app/orchestration/ and streamlit-app/agents/.
- MCPAgent-style chat loops select tools, execute them, and iterate with LLM feedback
- ReportAgent coordinates the structured CI report workflow
- specialized domain agents split responsibilities across chemical, clinical, literature, gene, data, and report tasks
4. Data acquisition boundary: MCP servers
External data access is intentionally isolated behind MCP servers in servers/. These are the system’s main integration boundary to biomedical sources:
- pubchem-augmented / pubchem: chemistry and properties
- bio / biomcp-related tooling: PubMed, ClinicalTrials.gov, OpenFDA, gene/variant sources
- literature, medrxiv, biorxiv: publication and preprint search
- opentargets, stringdb: target biology and interaction networks
- web_knowledge: general biomedical knowledge sources
- data_analysis: analysis and derived computations
5. Report-generation pipeline
Report creation is a distinct subsystem under streamlit-app/reporting/.
- The app infers the target drug/asset from chat context
- ReportAgent generates an 18-section EMD-format CI report
- Sections are built in parallel batches, with domain agents gathering evidence first
- The report is then compiled and exported as Markdown or PDF
6. Governance and control plane
All tool use passes through a governance layer in streamlit-app/governance/.
This layer enforces:
- rate limiting
- compliance checks
- audit logging
- service registry / controlled access
- gateway mediation for tool calls
This is the main architectural boundary between LLM-driven requests and external execution.
7. Persistence and session state
Persistent state is managed in streamlit-app/context/ and related models.
- chat sessions and messages are stored per user
- generated reports are saved and tied to sessions
- the default persistent backend is Supabase
- there is a SQLite fallback for local operation when Supabase is unavailable
8. Context and retrieval support
The app includes a separate context subsystem for maintaining continuity across sessions:
- session database handling
- vector store / chat vector store
- memory retriever
This suggests the chat system is not stateless; it can reuse prior conversation and session knowledge.
9. LLM abstraction
streamlit-app/utils/llm_factory.py and config files indicate a provider abstraction for multiple model backends:
- Anthropic Claude as default
- Azure OpenAI or AWS Bedrock for enterprise environments
- local Ollama for offline or no-key setups
This makes the orchestration layer model-agnostic.
10. Metrics and observability
streamlit-app/metrics/ tracks tool usage, which feeds the UI’s metrics tab.
This is important for architecture because the system isn’t just generating answers; it also records which MCP tools were invoked during a session, making the workflow auditable and analyzable.
11. Supporting scripts and platform-specific setup
The repository includes deployment and startup aids:
- install.py
- run.sh / run.bat
- environment templates and setup docs
- SSL certificates and Merck-specific startup guidance
These indicate the app is designed to run in both local and enterprise network contexts.
12. Legacy/advanced orchestration material
The docs/ and streamlit-app/demo_dual_orchestration.py files show that the repo contains documentation and examples for dual orchestration and context forge concepts. Those are relevant as architectural references, but the live system is centered on the Streamlit app plus MCP tool servers.
13. Key architectural flow
A practical architecture diagram should show this data path:
User → Streamlit UI → agent/orchestration layer → governance gateway → MCP servers / external data sources → synthesized answer or report → persistent storage and metrics
The report path is similar, but fans out to multiple specialized agents before compilation and export.
14. Important boundaries to draw
The clearest diagram boundaries are:
- presentation layer: Streamlit UI
- orchestration layer: agents, report assembly, session management
- control plane: governance, audit, rate limits
- tool layer: MCP servers
- storage layer: Supabase / SQLite / vector store
- output layer: chat responses, markdown/PDF reports, metrics views
Main entry points: chemical_agent.py Domain Agents · app.py Streamlit App · gateway.py Gateway · session_manager.py Session Manager
Components 28
Presentation
Streamlit user interface and visible app surfaces
- Streamlit App · Primary chat and reporting interface
streamlit-app/app.py - Chat History · Session and conversation browsing
streamlit-app/ui/chat_history.py - Report Panel · Report viewing and export controls
streamlit-app/ui/report_panel.py - Metrics Tab · Tool usage and observability views
streamlit-app/ui/tool_metrics_tab.py - Governance Tab · Audit and compliance visibility
streamlit-app/ui/governance_tab.py
Orchestration
Agent routing, report assembly, and session coordination
- Agent Router · Routes chat requests into agent workflows
streamlit-app/orchestration/agent_orchestrator.py - MCP Orchestrator · Composes and dispatches tool calls
streamlit-app/orchestration/mcp_orchestrator.py - Session Manager · Coordinates session lifecycle and continuity
streamlit-app/orchestration/session_manager.py - Tool Composer · Builds composed tool workflows
streamlit-app/orchestration/tool_composer.py - Report Agent · Drives structured CI report generation
streamlit-app/agents/report_agent.py - Base Agent · Shared agent behavior and common loop
streamlit-app/agents/base_agent.py - Domain Agents · Chemical, clinical, literature, gene, and data specialists
streamlit-app/agents/chemical_agent.py
Control Plane
Governance, compliance, and tool access control
- Gateway · Mediates all tool execution
streamlit-app/governance/gateway.py - Rate Limiter · Controls request and tool-call throughput
streamlit-app/governance/rate_limiter.py - Compliance · Checks requests against policy rules
streamlit-app/governance/compliance_engine.py - Audit Log · Records governed tool use and actions
streamlit-app/governance/audit_logger.py - Service Registry · Controlled catalog of available services
streamlit-app/governance/service_registry.py
State
Persistence, memory, and retrieval support
- Session DB · Stores chats, sessions, and report state
streamlit-app/context/session_db.py - Vector Store · Persistent semantic memory for chat continuity
streamlit-app/context/vector_store.py - Memory Retriever · Fetches prior context and related session memory
streamlit-app/context/memory_retriever.py - Data Models · Shared session and storage schema objects
streamlit-app/context/db_models.py
MCP Tools
External data and analysis servers exposed through MCP
- PubChem · Chemical properties and compound lookup
servers/pubchem/index.js - Bio MCP · PubMed, clinical, and biomedical retrieval tools
servers/bio/run_biomcp.py - Literature · Publication search and literature access
servers/literature/index.js - Target Biology · OpenTargets and STRING-based target context
servers/opentargets/index.js - Web Knowledge · General biomedical knowledge retrieval
servers/web_knowledge/index.js - Data Analysis · Derived computations and analysis tools
servers/data_analysis/index.js - Preprints · bioRxiv and medRxiv search services
servers/biorxiv/index.js
Connections 33
- Streamlit App → Agent Router: chat requests · User prompts enter the agent routing layer
- Streamlit App → Report Agent: report action · Report generation is initiated from the UI
- Streamlit App → Chat History: browse history · UI surfaces prior sessions and messages
- Streamlit App → Report Panel: view reports · UI displays generated reports and exports
- Streamlit App → Metrics Tab: view metrics · UI shows tool usage and observability data
- Streamlit App → Governance Tab: view governance · UI exposes audit and compliance status
- Agent Router → Base Agent: agent loop · Orchestration shares common agent behavior
- Agent Router → Domain Agents: delegate tasks · Specialized agents handle domain-specific evidence gathering
- Agent Router → MCP Orchestrator: tool planning · Agent workflows invoke composed tool execution
- MCP Orchestrator → Tool Composer: compose calls · Tool sequences are assembled before dispatch
- MCP Orchestrator → Gateway: execute via gateway · All external execution passes through governance
- Report Agent → Domain Agents: evidence sweep · Report sections gather evidence from specialist agents
- Report Agent → MCP Orchestrator: research tools · Report generation uses the same governed tool path
- Gateway → Rate Limiter: limit · Governance enforces throughput controls
- Gateway → Compliance: check · Requests are screened for policy compliance
- Gateway → Audit Log: log · Tool access and actions are recorded
- Gateway → Service Registry: resolve · Only registered services are reachable
- Session Manager → Session DB: persist · Sessions and messages are stored durably
- Session Manager → Vector Store: remember · Conversation memory is embedded for retrieval
- Memory Retriever → Vector Store: query memory · Retrieval pulls prior context from the store
- Session Manager → Memory Retriever: context fetch · Session handling can restore prior context
- Session Manager → Data Models: map state · Persistence uses shared data models
- Domain Agents → PubChem: chemistry · Chemical analysis uses PubChem data
- Domain Agents → Bio MCP: biomed search · Clinical and biomedical queries use Bio MCP
- Domain Agents → Literature: literature · Evidence gathering reaches literature search services
- Domain Agents → Target Biology: targets · Target biology and interaction data support research
- Domain Agents → Web Knowledge: knowledge · General knowledge sources supplement research
- Domain Agents → Data Analysis: analysis · Derived computations support synthesis
- Domain Agents → Preprints: preprints · Preprint sources feed literature review
- Report Agent → Session DB: save report · Generated reports are tied back to sessions
- Report Panel → Session DB: load report · Saved reports are retrieved for display
- Metrics Tab → Audit Log: usage data · Tool tracking feeds observability views
- Governance Tab → Audit Log: audit view · Governance tab surfaces audit records