# tanish123-art/pharma-ai architecture

> Architecture diagram of the GitHub repository tanish123-art/pharma-ai, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-06). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/tanish123-art/pharma-ai
- Repository: https://github.com/tanish123-art/pharma-ai

## Overview

PharmaAI is a pharmaceutical research platform: users authenticate, submit research questions, and receive document-grounded answers or synthesized multi-agent findings and reports. Its documented RAG-first workflow searches uploaded material before broader research; the repository index also supports the backend orchestration and session-storage links shown here. Major advertised capabilities such as live progress and downloadable reports are included, but their precise runtime wiring is not established by the excerpts, so those links are documented at the product level. Several agent implementations were not excerpted; their orchestration links rely on the source index and README.

Main entry points: [`Backend/agents/orchestrator.py`](https://github.com/tanish123-art/pharma-ai/blob/main/Backend/agents/orchestrator.py) (Workflow Orchestrator), [`Backend/main.py`](https://github.com/tanish123-art/pharma-ai/blob/main/Backend/main.py) (FastAPI Entry), [`Frontend/src/App.tsx`](https://github.com/tanish123-art/pharma-ai/blob/main/Frontend/src/App.tsx) (App Shell), [`Frontend/src/components/Dashboard.tsx`](https://github.com/tanish123-art/pharma-ai/blob/main/Frontend/src/components/Dashboard.tsx) (Dashboard)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Research UI"]
  node_app["App Shell<br/>[App.tsx]"]
  node_dashboard["Dashboard<br/>[Dashboard.tsx]"]
  node_research_ui["Research Interface"]
  node_agent_outputs["Agent Outputs<br/>[AgentOutputs.tsx]"]
  node_report_ui["Report UI"]
end

subgraph group_access["Access &amp; Sessions"]
  node_auth_context["Auth Context<br/>[AuthContext.tsx]"]
  node_auth_ui["Sign-in UI<br/>[Auth.tsx]"]
  node_api["API Client<br/>[api.ts]"]
  node_auth_router["Auth API<br/>[router.py]"]
  node_user_service["User Service<br/>[user_service.py]"]
  node_mongo[("MongoDB<br/>[database.py]")]
end

subgraph group_knowledge["Document Knowledge"]
  node_documents["Document API"]
  node_embeddings["Embedding Handler"]
  node_vector_store[("Pinecone")]
end

subgraph group_research["Research Orchestration"]
  node_api_entry["FastAPI Entry<br/>[main.py]"]
  node_research_router["Research API<br/>[router.py]"]
  node_chat_router["Chat API<br/>[chat_router.py]"]
  node_orchestrator["Workflow Orchestrator<br/>[orchestrator.py]"]
  node_master["Master Agent<br/>[master_agent.py]"]
  node_clinical["Clinical Agent<br/>[clinical_agent.py]"]
  node_market["IQVIA Agent<br/>[iqvia_agent.py]"]
  node_trade["EXIM Agent<br/>[exim_agent.py]"]
  node_patents["Patent Agent<br/>[patent_agent.py]"]
  node_web["Web Agent<br/>[web_agent.py]"]
  node_llm["LLM Handler"]
end

subgraph group_outputs["Research Outputs"]
  node_research_service["Session Service"]
  node_report_agent["Report Agent<br/>[report_agent.py]"]
  node_reports_api["Reports API<br/>[reports_router.py]"]
  node_history_ui["Research History"]
end

node_analyst(("Researcher"))

node_analyst -->|"uses"| node_app
node_app -->|"provides auth"| node_auth_context
node_app -->|"shows"| node_dashboard
node_dashboard -->|"renders"| node_research_ui
node_research_ui -->|"requests"| node_api
node_research_ui -->|"renders"| node_agent_outputs
node_analyst -->|"signs in"| node_auth_ui
node_auth_ui -->|"updates"| node_auth_context
node_auth_context -->|"checks identity"| node_api
node_api -->|"calls REST"| node_api_entry
node_api_entry -->|"registers"| node_auth_router
node_auth_router -->|"authenticates"| node_user_service
node_user_service -->|"reads/writes users"| node_mongo
node_api_entry -->|"registers"| node_research_router
node_api_entry -->|"registers"| node_chat_router
node_chat_router -->|"delegates research"| node_orchestrator
node_research_router -->|"starts workflow"| node_orchestrator
node_orchestrator -->|"coordinates"| node_master
node_orchestrator -->|"dispatches"| node_clinical
node_orchestrator -->|"dispatches"| node_market
node_orchestrator -->|"dispatches"| node_trade
node_orchestrator -->|"dispatches"| node_patents
node_orchestrator -->|"dispatches"| node_web
node_orchestrator -->|"requests report"| node_report_agent
node_analyst -->|"uploads documents"| node_documents
node_documents -->|"creates embeddings"| node_embeddings
node_embeddings -->|"indexes/searches"| node_vector_store
node_chat_router -->|"searches documents"| node_embeddings
node_orchestrator -.->|"uses language model"| node_llm
node_orchestrator -->|"updates sessions"| node_research_service
node_research_service -->|"stores sessions"| node_mongo
node_api_entry -->|"registers"| node_reports_api
node_report_agent -.->|"makes reports available"| node_reports_api
node_dashboard -.->|"shows history"| node_history_ui
node_report_agent -.->|"provides reports"| node_report_ui

click node_app "https://github.com/tanish123-art/pharma-ai/blob/main/Frontend/src/App.tsx"
click node_dashboard "https://github.com/tanish123-art/pharma-ai/blob/main/Frontend/src/components/Dashboard.tsx"
click node_research_ui "https://github.com/tanish123-art/pharma-ai/blob/main/Frontend/src/components/ResearchInterface.tsx"
click node_agent_outputs "https://github.com/tanish123-art/pharma-ai/blob/main/Frontend/src/components/AgentOutputs.tsx"
click node_report_ui "https://github.com/tanish123-art/pharma-ai/blob/main/Frontend/src/components/ReportGenerator.tsx"
click node_auth_context "https://github.com/tanish123-art/pharma-ai/blob/main/Frontend/src/contexts/AuthContext.tsx"
click node_auth_ui "https://github.com/tanish123-art/pharma-ai/blob/main/Frontend/src/components/Auth.tsx"
click node_api "https://github.com/tanish123-art/pharma-ai/blob/main/Frontend/src/lib/api.ts"
click node_auth_router "https://github.com/tanish123-art/pharma-ai/blob/main/Backend/auth/router.py"
click node_user_service "https://github.com/tanish123-art/pharma-ai/blob/main/Backend/auth/user_service.py"
click node_mongo "https://github.com/tanish123-art/pharma-ai/blob/main/Backend/auth/database.py"
click node_api_entry "https://github.com/tanish123-art/pharma-ai/blob/main/Backend/main.py"
click node_research_router "https://github.com/tanish123-art/pharma-ai/blob/main/Backend/agents/router.py"
click node_chat_router "https://github.com/tanish123-art/pharma-ai/blob/main/Backend/agents/chat_router.py"
click node_orchestrator "https://github.com/tanish123-art/pharma-ai/blob/main/Backend/agents/orchestrator.py"
click node_master "https://github.com/tanish123-art/pharma-ai/blob/main/Backend/agents/master_agent.py"
click node_clinical "https://github.com/tanish123-art/pharma-ai/blob/main/Backend/agents/clinical_agent.py"
click node_market "https://github.com/tanish123-art/pharma-ai/blob/main/Backend/agents/iqvia_agent.py"
click node_trade "https://github.com/tanish123-art/pharma-ai/blob/main/Backend/agents/exim_agent.py"
click node_patents "https://github.com/tanish123-art/pharma-ai/blob/main/Backend/agents/patent_agent.py"
click node_web "https://github.com/tanish123-art/pharma-ai/blob/main/Backend/agents/web_agent.py"
click node_documents "https://github.com/tanish123-art/pharma-ai/blob/main/Backend/agents/documents_router.py"
click node_embeddings "https://github.com/tanish123-art/pharma-ai/blob/main/Backend/agents/local_embedding_handler.py"
click node_llm "https://github.com/tanish123-art/pharma-ai/blob/main/Backend/agents/local_llm_handler.py"
click node_research_service "https://github.com/tanish123-art/pharma-ai/blob/main/Backend/agents/research_service.py"
click node_report_agent "https://github.com/tanish123-art/pharma-ai/blob/main/Backend/agents/report_agent.py"
click node_reports_api "https://github.com/tanish123-art/pharma-ai/blob/main/Backend/agents/reports_router.py"
click node_history_ui "https://github.com/tanish123-art/pharma-ai/blob/main/Frontend/src/components/ResearchHistory.tsx"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_app,node_dashboard,node_research_ui,node_agent_outputs,node_report_ui toneBlue
class node_auth_context,node_auth_ui,node_api,node_auth_router,node_user_service,node_mongo toneAmber
class node_documents,node_embeddings,node_vector_store toneMint
class node_api_entry,node_research_router,node_chat_router,node_orchestrator,node_master,node_clinical,node_market,node_trade,node_patents,node_web,node_llm toneRose
class node_research_service,node_report_agent,node_reports_api,node_history_ui,node_analyst toneIndigo
```

## Components

### Research UI

- [App Shell](https://github.com/tanish123-art/pharma-ai/blob/main/Frontend/src/App.tsx): `Frontend/src/App.tsx`
- [Dashboard](https://github.com/tanish123-art/pharma-ai/blob/main/Frontend/src/components/Dashboard.tsx): `Frontend/src/components/Dashboard.tsx`
- [Research Interface](https://github.com/tanish123-art/pharma-ai/blob/main/Frontend/src/components/ResearchInterface.tsx): `Frontend/src/components/ResearchInterface.tsx`
- [Agent Outputs](https://github.com/tanish123-art/pharma-ai/blob/main/Frontend/src/components/AgentOutputs.tsx): `Frontend/src/components/AgentOutputs.tsx`
- [Report UI](https://github.com/tanish123-art/pharma-ai/blob/main/Frontend/src/components/ReportGenerator.tsx): `Frontend/src/components/ReportGenerator.tsx`

### Access & Sessions

- [Auth Context](https://github.com/tanish123-art/pharma-ai/blob/main/Frontend/src/contexts/AuthContext.tsx): `Frontend/src/contexts/AuthContext.tsx`
- [Sign-in UI](https://github.com/tanish123-art/pharma-ai/blob/main/Frontend/src/components/Auth.tsx): `Frontend/src/components/Auth.tsx`
- [API Client](https://github.com/tanish123-art/pharma-ai/blob/main/Frontend/src/lib/api.ts): `Frontend/src/lib/api.ts`
- [Auth API](https://github.com/tanish123-art/pharma-ai/blob/main/Backend/auth/router.py): `Backend/auth/router.py`
- [User Service](https://github.com/tanish123-art/pharma-ai/blob/main/Backend/auth/user_service.py): `Backend/auth/user_service.py`
- [MongoDB](https://github.com/tanish123-art/pharma-ai/blob/main/Backend/auth/database.py): `Backend/auth/database.py`

### Document Knowledge

- [Document API](https://github.com/tanish123-art/pharma-ai/blob/main/Backend/agents/documents_router.py): `Backend/agents/documents_router.py`
- [Embedding Handler](https://github.com/tanish123-art/pharma-ai/blob/main/Backend/agents/local_embedding_handler.py): `Backend/agents/local_embedding_handler.py`
- **Pinecone**

### Research Orchestration

- [FastAPI Entry](https://github.com/tanish123-art/pharma-ai/blob/main/Backend/main.py): `Backend/main.py`
- [Research API](https://github.com/tanish123-art/pharma-ai/blob/main/Backend/agents/router.py): `Backend/agents/router.py`
- [Chat API](https://github.com/tanish123-art/pharma-ai/blob/main/Backend/agents/chat_router.py): `Backend/agents/chat_router.py`
- [Workflow Orchestrator](https://github.com/tanish123-art/pharma-ai/blob/main/Backend/agents/orchestrator.py): `Backend/agents/orchestrator.py`
- [Master Agent](https://github.com/tanish123-art/pharma-ai/blob/main/Backend/agents/master_agent.py): `Backend/agents/master_agent.py`
- [Clinical Agent](https://github.com/tanish123-art/pharma-ai/blob/main/Backend/agents/clinical_agent.py): `Backend/agents/clinical_agent.py`
- [IQVIA Agent](https://github.com/tanish123-art/pharma-ai/blob/main/Backend/agents/iqvia_agent.py): `Backend/agents/iqvia_agent.py`
- [EXIM Agent](https://github.com/tanish123-art/pharma-ai/blob/main/Backend/agents/exim_agent.py): `Backend/agents/exim_agent.py`
- [Patent Agent](https://github.com/tanish123-art/pharma-ai/blob/main/Backend/agents/patent_agent.py): `Backend/agents/patent_agent.py`
- [Web Agent](https://github.com/tanish123-art/pharma-ai/blob/main/Backend/agents/web_agent.py): `Backend/agents/web_agent.py`
- [LLM Handler](https://github.com/tanish123-art/pharma-ai/blob/main/Backend/agents/local_llm_handler.py): `Backend/agents/local_llm_handler.py`

### Research Outputs

- [Session Service](https://github.com/tanish123-art/pharma-ai/blob/main/Backend/agents/research_service.py): `Backend/agents/research_service.py`
- [Report Agent](https://github.com/tanish123-art/pharma-ai/blob/main/Backend/agents/report_agent.py): `Backend/agents/report_agent.py`
- [Reports API](https://github.com/tanish123-art/pharma-ai/blob/main/Backend/agents/reports_router.py): `Backend/agents/reports_router.py`
- [Research History](https://github.com/tanish123-art/pharma-ai/blob/main/Frontend/src/components/ResearchHistory.tsx): `Frontend/src/components/ResearchHistory.tsx`

### Other components

- **Researcher**

## Connections

- Researcher → App Shell: uses
- App Shell → Auth Context: provides auth (evidence: `Frontend/src/App.tsx`)
- App Shell → Dashboard: shows (evidence: `Frontend/src/App.tsx`)
- Dashboard → Research Interface: renders (evidence: `Frontend/src/components/Dashboard.tsx`)
- Research Interface → API Client: requests (evidence: `Frontend/src/components/ResearchInterface.tsx`)
- Research Interface → Agent Outputs: renders (evidence: `Frontend/src/components/ResearchInterface.tsx`)
- Researcher → Sign-in UI: signs in
- Sign-in UI → Auth Context: updates (evidence: `Frontend/src/components/Auth.tsx`)
- Auth Context → API Client: checks identity (evidence: `Frontend/src/contexts/AuthContext.tsx`)
- API Client → FastAPI Entry: calls REST
- FastAPI Entry → Auth API: registers (evidence: `Backend/main.py`)
- Auth API → User Service: authenticates (evidence: `Backend/auth/router.py`)
- User Service → MongoDB: reads/writes users (evidence: `Backend/auth/user_service.py`)
- FastAPI Entry → Research API: registers (evidence: `Backend/main.py`)
- FastAPI Entry → Chat API: registers (evidence: `Backend/main.py`)
- Chat API → Workflow Orchestrator: delegates research (evidence: `Backend/agents/orchestrator.py`)
- Research API → Workflow Orchestrator: starts workflow (evidence: `Backend/agents/router.py`)
- Workflow Orchestrator → Master Agent: coordinates (evidence: `Backend/agents/orchestrator.py`)
- Workflow Orchestrator → Clinical Agent: dispatches (evidence: `Backend/agents/orchestrator.py`)
- Workflow Orchestrator → IQVIA Agent: dispatches (evidence: `Backend/agents/orchestrator.py`)
- Workflow Orchestrator → EXIM Agent: dispatches (evidence: `Backend/agents/orchestrator.py`)
- Workflow Orchestrator → Patent Agent: dispatches (evidence: `Backend/agents/orchestrator.py`)
- Workflow Orchestrator → Web Agent: dispatches (evidence: `Backend/agents/orchestrator.py`)
- Workflow Orchestrator → Report Agent: requests report (evidence: `Backend/agents/orchestrator.py`)
- Researcher → Document API: uploads documents
- Document API → Embedding Handler: creates embeddings (evidence: `Backend/agents/documents_router.py`)
- Embedding Handler → Pinecone: indexes/searches
- Chat API → Embedding Handler: searches documents (evidence: `Backend/agents/chat_router.py`)
- Workflow Orchestrator → LLM Handler: uses language model
- Workflow Orchestrator → Session Service: updates sessions (evidence: `Backend/agents/orchestrator.py`)
- Session Service → MongoDB: stores sessions (evidence: `Backend/agents/research_service.py`)
- FastAPI Entry → Reports API: registers (evidence: `Backend/main.py`)
- Report Agent → Reports API: makes reports available
- Dashboard → Research History: shows history
- Report Agent → Report UI: provides reports
