# arijit-006/ai-scientific-research-analyzer architecture

> Architecture diagram of the GitHub repository arijit-006/ai-scientific-research-analyzer, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/arijit-006/ai-scientific-research-analyzer
- Repository: https://github.com/arijit-006/ai-scientific-research-analyzer

## Overview

This is a Streamlit research-paper analyzer: a user uploads a PDF or JPG/JPEG, the app selects an extraction path, sends readable text to Gemini, and displays the generated summary, keywords, results, and methods. The supplied source implements the app in p2.py, while the README describes app.py; the graph follows the actual tree and sampled source. The workflow is well supported, though all application responsibilities reside in one file, so nodes represent distinct functions rather than separate modules.

Main entry points: [`p2.py`](https://github.com/arijit-006/ai-scientific-research-analyzer/blob/main/p2.py) (Image OCR)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["Upload and display"]
  node_streamlit_app["Streamlit interface<br/>[p2.py]"]
  node_file_router["File type routing<br/>[p2.py]"]
  node_display["Results display<br/>[p2.py]"]
end

subgraph group_extraction["Text extraction"]
  node_pdf_extractor["PDF extraction<br/>[p2.py]"]
  node_pdfplumber["pdfplumber"]
  node_image_extractor["Image OCR<br/>[p2.py]"]
  node_pillow["Pillow image loading"]
  node_tesseract["Tesseract OCR"]
  node_text_content["Extracted text"]
end

subgraph group_analysis["AI analysis"]
  node_analysis_prompt["Analysis prompt<br/>[p2.py]"]
  node_gemini["Gemini model"]
  node_analysis_result["Structured analysis<br/>[p2.py]"]
end

node_user(("Researcher"))

node_user -->|"uploads document"| node_streamlit_app
node_streamlit_app -->|"checks extension"| node_file_router
node_file_router -->|"routes PDF"| node_pdf_extractor
node_file_router -->|"routes image"| node_image_extractor
node_pdf_extractor -->|"extracts pages"| node_pdfplumber
node_image_extractor -->|"opens image"| node_pillow
node_image_extractor -->|"runs OCR"| node_tesseract
node_pdf_extractor -->|"returns text"| node_text_content
node_image_extractor -->|"returns text"| node_text_content
node_text_content -->|"supplies content"| node_analysis_prompt
node_analysis_prompt -->|"requests analysis"| node_gemini
node_gemini -->|"returns response"| node_analysis_result
node_analysis_result -->|"renders Markdown"| node_display
node_display -->|"shows results"| node_user

click node_streamlit_app "https://github.com/arijit-006/ai-scientific-research-analyzer/blob/main/p2.py"
click node_file_router "https://github.com/arijit-006/ai-scientific-research-analyzer/blob/main/p2.py"
click node_pdf_extractor "https://github.com/arijit-006/ai-scientific-research-analyzer/blob/main/p2.py"
click node_image_extractor "https://github.com/arijit-006/ai-scientific-research-analyzer/blob/main/p2.py"
click node_analysis_prompt "https://github.com/arijit-006/ai-scientific-research-analyzer/blob/main/p2.py"
click node_analysis_result "https://github.com/arijit-006/ai-scientific-research-analyzer/blob/main/p2.py"
click node_display "https://github.com/arijit-006/ai-scientific-research-analyzer/blob/main/p2.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_streamlit_app,node_file_router,node_display toneBlue
class node_pdf_extractor,node_pdfplumber,node_image_extractor,node_pillow,node_tesseract,node_text_content toneAmber
class node_analysis_prompt,node_gemini,node_analysis_result toneMint
class node_user toneIndigo
```

## Components

### Upload and display

- [Streamlit interface](https://github.com/arijit-006/ai-scientific-research-analyzer/blob/main/p2.py): `p2.py`
- [File type routing](https://github.com/arijit-006/ai-scientific-research-analyzer/blob/main/p2.py): `p2.py`
- [Results display](https://github.com/arijit-006/ai-scientific-research-analyzer/blob/main/p2.py): `p2.py`

### Text extraction

- [PDF extraction](https://github.com/arijit-006/ai-scientific-research-analyzer/blob/main/p2.py): `p2.py`
- **pdfplumber**
- [Image OCR](https://github.com/arijit-006/ai-scientific-research-analyzer/blob/main/p2.py): `p2.py`
- **Pillow image loading**
- **Tesseract OCR**
- **Extracted text**

### AI analysis

- [Analysis prompt](https://github.com/arijit-006/ai-scientific-research-analyzer/blob/main/p2.py): `p2.py`
- **Gemini model**
- [Structured analysis](https://github.com/arijit-006/ai-scientific-research-analyzer/blob/main/p2.py): `p2.py`

### Other components

- **Researcher**

## Connections

- Researcher → Streamlit interface: uploads document (evidence: `p2.py`)
- Streamlit interface → File type routing: checks extension (evidence: `p2.py`)
- File type routing → PDF extraction: routes PDF (evidence: `p2.py`)
- File type routing → Image OCR: routes image (evidence: `p2.py`)
- PDF extraction → pdfplumber: extracts pages (evidence: `p2.py`)
- Image OCR → Pillow image loading: opens image (evidence: `p2.py`)
- Image OCR → Tesseract OCR: runs OCR (evidence: `p2.py`)
- PDF extraction → Extracted text: returns text (evidence: `p2.py`)
- Image OCR → Extracted text: returns text (evidence: `p2.py`)
- Extracted text → Analysis prompt: supplies content (evidence: `p2.py`)
- Analysis prompt → Gemini model: requests analysis (evidence: `p2.py`)
- Gemini model → Structured analysis: returns response (evidence: `p2.py`)
- Structured analysis → Results display: renders Markdown (evidence: `p2.py`)
- Results display → Researcher: shows results (evidence: `p2.py`)
