# mihirkothari04/ai-research-assistant-network architecture

> Architecture diagram of the GitHub repository mihirkothari04/ai-research-assistant-network, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mihirkothari04/ai-research-assistant-network
- Repository: https://github.com/mihirkothari04/ai-research-assistant-network

## Overview

##### Project Type and Purpose
- This is a full-stack, containerized, multi-agent AI research system (“Research Assistant Network”).
- Purpose: accept an open-ended research question via a web UI, then execute a directed pipeline of five specialized AI agents—InfoGatherer, InsightGenerator, DataAnalyst, HypothesisTester, ReportCompiler—to autonomously collect data, analyze it, test hypotheses, and produce a report.

##### File Structure and README
- Top-level scripts: main.py, run_server.py (entry points), Dockerfile, docker-compose.yml (deployment).
- src/
- api/ (Flask REST/web layer + templates)
- agents/ (five agent modules + a BaseAgent)
- config/ (application configuration)
- orchestration.py (LangChain/LangGraph orchestration graph)
- Logs (flask.log, flask_error.log), requirements.txt, DEPLOYMENT.md, and environment config via .env.

##### Main Components
a. Client/Web browser
b. API Layer
- Flask application (src/api/api.py + index.html template)
c. Orchestration Engine
- LangChain/LangGraph directed graph (src/orchestration.py)
d. Agent Modules (five nodes in the graph)
1. InfoGathererAgent
2. InsightGeneratorAgent
3. DataAnalystAgent
4. HypothesisTesterAgent
5. ReportCompilerAgent
e. External Services
- OpenAI GPT-4 (via OpenAI API)
- Academic data sources (Semantic Scholar, arXiv, CrossRef, Bing Search)
f. Data Stores
- Vector Database (ChromaDB for embeddings in storage/vector_db/)
- File storage (storage/research_tasks/, storage/reports/)
- Logging (flask.log)
g. Containerization/Deployment
- Docker, Docker Compose

##### Relationships and Data Flows
- User → HTTP Request → Flask API
- Flask API → passes query into Orchestration Engine
- Orchestration Engine → triggers InfoGathererAgent → fetches documents from academic APIs → stores into ChromaDB → returns data to engine
- Engine → invokes InsightGeneratorAgent → summarizes and passes output downstream
- Engine → invokes DataAnalystAgent → processes data, generates visuals
- Engine → invokes HypothesisTesterAgent → proposes/tests hypotheses
- Engine → invokes ReportCompilerAgent → builds final report (Jupyter/PDF/Slides) → writes to storage/reports/
- Final Report → Flask API → user downloads via web UI

##### Architectural Patterns and Design Principles
- Pipeline/Micro-workflow: Directed Graph orchestration (LangGraph) defines ordering and data dependencies among agents.
- Modular agents conforming to BaseAgent interface for easy extension.
- Clean separation: API layer, orchestration logic, agent implementation, storage, config.
- Containerized deployment ensures environment consistency.

##### Technologies, Frameworks, and Libraries
- Python 3.11
- Flask (REST API + web UI)
- LangChain & LangGraph (orchestration)
- OpenAI API for LLM reasoning
- ChromaDB (vector store)
- Docker & Docker Compose
- Jupyter/PDF/Slides for report outputs

##### Final Advice
- Be exhaustive: include entry points (main.py/run_server.py), config (config.py), deployment (Docker).
- Directional dependencies: which agent feeds data to which.
- Both synchronous flows (web request → orchestrator → report) and asynchronous or storage interactions (vector DB reads/writes).
- Iterate: validate with a peer or the person who implemented orchestration.py to ensure agent boundaries and data contracts are accurately reflected.

## Diagram (Mermaid)

```mermaid
flowchart TB
  %% Presentation Layer
  subgraph "Presentation Layer"
    BROWSER["Web Browser"]:::presentation
    FLASK["Flask API"]:::api
    TEMPLATE["index.html"]:::api
  end

  %% Orchestration Layer
  subgraph "Orchestration Layer"
    ORCH["Orchestration Engine"]:::orchestration
  end

  %% Agent Layer
  subgraph "Agent Layer"
    BASE["BaseAgent"]:::agent
    INFO["InfoGathererAgent"]:::agent
    INSIGHT["InsightGeneratorAgent"]:::agent
    ANALYST["DataAnalystAgent"]:::agent
    HYPOTHESIS["HypothesisTesterAgent"]:::agent
    REPORT["ReportCompilerAgent"]:::agent
  end

  %% Integration Layer
  subgraph "Integration Layer"
    GPT4["OpenAI GPT-4"]:::external
    APIS["Academic Data Sources"]:::external
    VECTOR["ChromaDB (Vector DB)"]:::external
  end

  %% Persistence Layer
  subgraph "Persistence Layer"
    TASKS["Research Tasks Storage"]:::storage
    REPORTS["Reports Storage"]:::storage
    LOGS["Flask Logs"]:::storage
  end

  %% Deployment Layer
  subgraph "Deployment"
    MAIN["main.py"]:::deploy
    RUN["run_server.py"]:::deploy
    DOCKERFILE["Dockerfile"]:::deploy
    COMPOSE["docker-compose.yml"]:::deploy
    DEPLOYMD["DEPLOYMENT.md"]:::deploy
  end

  %% Connections
  BROWSER -->|"HTTP Request"| FLASK
  FLASK -->|"Renders"| TEMPLATE
  FLASK -->|"Forwards Query"| ORCH
  ORCH -->|"Implements Graph"| BASE
  ORCH -->|"Triggers"| INFO
  INFO -->|"Fetches Data"| APIS
  INFO -->|"Stores Embeddings"| VECTOR
  ORCH -->|"Passes Data"| INSIGHT
  ORCH -->|"Passes Data"| ANALYST
  ORCH -->|"Passes Data"| HYPOTHESIS
  ORCH -->|"Passes Data"| REPORT
  REPORT -->|"Writes Report"| REPORTS
  REPORT -->|"Uses Jupyter/PDF"| REPORTS
  REPORT -->|"Returns Report"| FLASK
  FLASK -->|"Serves Download"| BROWSER
  ORCH -->|"Reads/Writes"| VECTOR
  FLASK -->|"Logs To"| LOGS

  %% Deployment Flows
  MAIN --> RUN
  RUN --> FLASK
  MAIN --> ORCH
  DOCKERFILE --> MAIN
  DOCKERFILE --> RUN
  DOCKERFILE --> FLASK
  COMPOSE --> DOCKERFILE
  COMPOSE --> RUN
  COMPOSE --> MAIN
  COMPOSE --> FLASK
  COMPOSE --> ORCH

  %% Click Events
  click BROWSER "https://github.com/mihirkothari04/ai-research-assistant-network/tree/main/N/A"
  click FLASK "https://github.com/mihirkothari04/ai-research-assistant-network/blob/main/src/api/api.py"
  click TEMPLATE "https://github.com/mihirkothari04/ai-research-assistant-network/blob/main/src/api/templates/index.html"
  click ORCH "https://github.com/mihirkothari04/ai-research-assistant-network/blob/main/src/orchestration.py"
  click BASE "https://github.com/mihirkothari04/ai-research-assistant-network/blob/main/src/agents/base_agent.py"
  click INFO "https://github.com/mihirkothari04/ai-research-assistant-network/blob/main/src/agents/info_gatherer_agent.py"
  click INSIGHT "https://github.com/mihirkothari04/ai-research-assistant-network/blob/main/src/agents/insight_generator_agent.py"
  click ANALYST "https://github.com/mihirkothari04/ai-research-assistant-network/blob/main/src/agents/data_analyst_agent.py"
  click HYPOTHESIS "https://github.com/mihirkothari04/ai-research-assistant-network/blob/main/src/agents/hypothesis_tester_agent.py"
  click REPORT "https://github.com/mihirkothari04/ai-research-assistant-network/blob/main/src/agents/report_compiler_agent.py"
  click MAIN "https://github.com/mihirkothari04/ai-research-assistant-network/blob/main/./main.py"
  click RUN "https://github.com/mihirkothari04/ai-research-assistant-network/blob/main/./run_server.py"
  click DOCKERFILE "https://github.com/mihirkothari04/ai-research-assistant-network/tree/main/./Dockerfile"
  click COMPOSE "https://github.com/mihirkothari04/ai-research-assistant-network/blob/main/./docker-compose.yml"
  click DEPLOYMD "https://github.com/mihirkothari04/ai-research-assistant-network/blob/main/DEPLOYMENT.md"
  click TASKS "https://github.com/mihirkothari04/ai-research-assistant-network/tree/main/storage/research_tasks/"
  click REPORTS "https://github.com/mihirkothari04/ai-research-assistant-network/tree/main/storage/reports/"

  %% Styles
  classDef presentation fill:#D6E9FE,stroke:#2196F3;
  classDef api fill:#E3F2FD,stroke:#42A5F5;
  classDef orchestration fill:#E8F5E9,stroke:#66BB6A;
  classDef agent fill:#C8E6C9,stroke:#43A047;
  classDef external fill:#FFF3E0,stroke:#FB8C00;
  classDef storage fill:#ECEFF1,stroke:#78909C;
  classDef deploy fill:#F3E5F5,stroke:#AB47BC
```
