# mayeraasingh/scholarlens architecture

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

- Interactive diagram: https://gitdiagram.com/mayeraasingh/scholarlens
- Repository: https://github.com/mayeraasingh/scholarlens

## Overview

ScholarLens analyzes research-paper PDFs and produces structured JSON and Markdown reports. The principal workflow is CLI or API submission, document extraction, specialized analyses, report aggregation, and session-backed retrieval. The graph preserves the documented analysis stages plus evaluation, code execution, chunking, formatting, and observability. Several source excerpts are partial; documented workflow links are cited to the README, while uncertain internal wiring is omitted.

Main entry points: [`src/orchestrator.py`](https://github.com/mayeraasingh/scholarlens/blob/main/src/orchestrator.py) (Orchestrator), [`src/main.py`](https://github.com/mayeraasingh/scholarlens/blob/main/src/main.py) (CLI), [`api/server.py`](https://github.com/mayeraasingh/scholarlens/blob/main/api/server.py) (REST API), [`src/memory/session_manager.py`](https://github.com/mayeraasingh/scholarlens/blob/main/src/memory/session_manager.py) (Session manager)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["User interfaces"]
  node_cli["CLI<br/>[main.py]"]
  node_api["REST API<br/>[server.py]"]
end

subgraph group_analysis["Analysis pipeline"]
  node_orchestrator["Orchestrator<br/>[orchestrator.py]"]
  node_extractor["PDF extractor<br/>[document_agent.py]"]
  node_summary["Summary analysis<br/>[summary_agent.py]"]
  node_method["Methodology analysis<br/>[method_agent.py]"]
  node_math["Equation interpretation<br/>[math_agent.py]"]
  node_critique["Critical analysis<br/>[critique_agent.py]"]
  node_implementation["Implementation guidance"]
  node_aggregator["Report aggregator"]
end

subgraph group_tools["Document tools"]
  node_pdf["PDF parsing<br/>[pdf_parser.py]"]
  node_cleaner["Text cleaning<br/>[text_cleaner.py]"]
  node_codeexec["Safe code execution<br/>[code_exec.py]"]
end

subgraph group_state["Sessions and quality"]
  node_sessions[("Session manager<br/>[session_manager.py]")]
  node_evaluator["Report evaluation<br/>[evaluator.py]"]
end

subgraph group_platform["Shared services"]
  node_chunking["Text chunking<br/>[chunking.py]"]
  node_formatting["Report formatting<br/>[formatting.py]"]
  node_config["Configuration<br/>[config.py]"]
  node_logger["Structured logging<br/>[logger.py]"]
end

node_user(("Researcher"))
node_reports["JSON and Markdown reports"]

node_user -->|"submits paper"| node_cli
node_user -->|"uploads paper"| node_api
node_cli -->|"starts analysis"| node_orchestrator
node_api -->|"starts analysis"| node_orchestrator
node_orchestrator -->|"extracts document"| node_extractor
node_extractor -->|"parses PDF"| node_pdf
node_orchestrator -->|"analyzes summary"| node_summary
node_orchestrator -->|"analyzes method"| node_method
node_orchestrator -->|"interprets equations"| node_math
node_orchestrator -->|"critiques research"| node_critique
node_orchestrator -->|"generates guidance"| node_implementation
node_orchestrator -->|"synthesizes results"| node_aggregator
node_math -->|"cleans text"| node_cleaner
node_orchestrator -->|"stores session data"| node_sessions
node_api -->|"retrieves reports"| node_sessions
node_orchestrator -->|"saves reports"| node_reports
node_cli -->|"lists sessions"| node_sessions
node_evaluator -.->|"evaluates quality"| node_reports

click node_cli "https://github.com/mayeraasingh/scholarlens/blob/main/src/main.py"
click node_api "https://github.com/mayeraasingh/scholarlens/blob/main/api/server.py"
click node_orchestrator "https://github.com/mayeraasingh/scholarlens/blob/main/src/orchestrator.py"
click node_extractor "https://github.com/mayeraasingh/scholarlens/blob/main/src/agents/document_agent.py"
click node_summary "https://github.com/mayeraasingh/scholarlens/blob/main/src/agents/summary_agent.py"
click node_method "https://github.com/mayeraasingh/scholarlens/blob/main/src/agents/method_agent.py"
click node_math "https://github.com/mayeraasingh/scholarlens/blob/main/src/agents/math_agent.py"
click node_critique "https://github.com/mayeraasingh/scholarlens/blob/main/src/agents/critique_agent.py"
click node_implementation "https://github.com/mayeraasingh/scholarlens/blob/main/src/agents/implementation_agent.py"
click node_aggregator "https://github.com/mayeraasingh/scholarlens/blob/main/src/agents/aggregator_agent.py"
click node_pdf "https://github.com/mayeraasingh/scholarlens/blob/main/src/tools/pdf_parser.py"
click node_cleaner "https://github.com/mayeraasingh/scholarlens/blob/main/src/tools/text_cleaner.py"
click node_codeexec "https://github.com/mayeraasingh/scholarlens/blob/main/src/tools/code_exec.py"
click node_sessions "https://github.com/mayeraasingh/scholarlens/blob/main/src/memory/session_manager.py"
click node_evaluator "https://github.com/mayeraasingh/scholarlens/blob/main/src/evaluation/evaluator.py"
click node_chunking "https://github.com/mayeraasingh/scholarlens/blob/main/src/utils/chunking.py"
click node_formatting "https://github.com/mayeraasingh/scholarlens/blob/main/src/utils/formatting.py"
click node_config "https://github.com/mayeraasingh/scholarlens/blob/main/src/utils/config.py"
click node_logger "https://github.com/mayeraasingh/scholarlens/blob/main/src/utils/logger.py"

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_cli,node_api toneBlue
class node_orchestrator,node_extractor,node_summary,node_method,node_math,node_critique,node_implementation,node_aggregator toneAmber
class node_pdf,node_cleaner,node_codeexec toneMint
class node_sessions,node_evaluator toneRose
class node_chunking,node_formatting,node_config,node_logger,node_user,node_reports toneIndigo
```

## Components

### User interfaces

- [CLI](https://github.com/mayeraasingh/scholarlens/blob/main/src/main.py): `src/main.py`
- [REST API](https://github.com/mayeraasingh/scholarlens/blob/main/api/server.py): `api/server.py`

### Analysis pipeline

- [Orchestrator](https://github.com/mayeraasingh/scholarlens/blob/main/src/orchestrator.py): `src/orchestrator.py`
- [PDF extractor](https://github.com/mayeraasingh/scholarlens/blob/main/src/agents/document_agent.py): `src/agents/document_agent.py`
- [Summary analysis](https://github.com/mayeraasingh/scholarlens/blob/main/src/agents/summary_agent.py): `src/agents/summary_agent.py`
- [Methodology analysis](https://github.com/mayeraasingh/scholarlens/blob/main/src/agents/method_agent.py): `src/agents/method_agent.py`
- [Equation interpretation](https://github.com/mayeraasingh/scholarlens/blob/main/src/agents/math_agent.py): `src/agents/math_agent.py`
- [Critical analysis](https://github.com/mayeraasingh/scholarlens/blob/main/src/agents/critique_agent.py): `src/agents/critique_agent.py`
- [Implementation guidance](https://github.com/mayeraasingh/scholarlens/blob/main/src/agents/implementation_agent.py): `src/agents/implementation_agent.py`
- [Report aggregator](https://github.com/mayeraasingh/scholarlens/blob/main/src/agents/aggregator_agent.py): `src/agents/aggregator_agent.py`

### Document tools

- [PDF parsing](https://github.com/mayeraasingh/scholarlens/blob/main/src/tools/pdf_parser.py): `src/tools/pdf_parser.py`
- [Text cleaning](https://github.com/mayeraasingh/scholarlens/blob/main/src/tools/text_cleaner.py): `src/tools/text_cleaner.py`
- [Safe code execution](https://github.com/mayeraasingh/scholarlens/blob/main/src/tools/code_exec.py): `src/tools/code_exec.py`

### Sessions and quality

- [Session manager](https://github.com/mayeraasingh/scholarlens/blob/main/src/memory/session_manager.py): `src/memory/session_manager.py`
- [Report evaluation](https://github.com/mayeraasingh/scholarlens/blob/main/src/evaluation/evaluator.py): `src/evaluation/evaluator.py`

### Shared services

- [Text chunking](https://github.com/mayeraasingh/scholarlens/blob/main/src/utils/chunking.py): `src/utils/chunking.py`
- [Report formatting](https://github.com/mayeraasingh/scholarlens/blob/main/src/utils/formatting.py): `src/utils/formatting.py`
- [Configuration](https://github.com/mayeraasingh/scholarlens/blob/main/src/utils/config.py): `src/utils/config.py`
- [Structured logging](https://github.com/mayeraasingh/scholarlens/blob/main/src/utils/logger.py): `src/utils/logger.py`

### Other components

- **Researcher**
- **JSON and Markdown reports**

## Connections

- Researcher → CLI: submits paper (evidence: `README.MD`)
- Researcher → REST API: uploads paper (evidence: `api/server.py`)
- CLI → Orchestrator: starts analysis (evidence: `README.MD`)
- REST API → Orchestrator: starts analysis (evidence: `api/server.py`)
- Orchestrator → PDF extractor: extracts document (evidence: `README.MD`)
- PDF extractor → PDF parsing: parses PDF (evidence: `src/agents/document_agent.py`)
- Orchestrator → Summary analysis: analyzes summary (evidence: `README.MD`)
- Orchestrator → Methodology analysis: analyzes method (evidence: `README.MD`)
- Orchestrator → Equation interpretation: interprets equations (evidence: `README.MD`)
- Orchestrator → Critical analysis: critiques research (evidence: `README.MD`)
- Orchestrator → Implementation guidance: generates guidance (evidence: `README.MD`)
- Orchestrator → Report aggregator: synthesizes results (evidence: `README.MD`)
- Equation interpretation → Text cleaning: cleans text (evidence: `src/agents/math_agent.py`)
- Orchestrator → Session manager: stores session data (evidence: `src/orchestrator.py`)
- REST API → Session manager: retrieves reports (evidence: `api/server.py`)
- Orchestrator → JSON and Markdown reports: saves reports (evidence: `README.MD`)
- CLI → Session manager: lists sessions (evidence: `src/main.py`)
- Report evaluation → JSON and Markdown reports: evaluates quality (evidence: `README.MD`)
