# priyan-19/research_paper_analysis architecture

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

- Interactive diagram: https://gitdiagram.com/priyan-19/research_paper_analysis
- Repository: https://github.com/priyan-19/research_paper_analysis

## Overview

This is a research-paper assistant: users upload academic PDFs, which are parsed, enriched with metadata, chunked, embedded, and indexed for later search and question answering. Its hybrid RAG path combines vector retrieval with graph traversal, fuses evidence, and generates cited answers. Other documented capabilities include graph construction and link prediction, paper analysis, evaluation, and a Streamlit dashboard alongside the REST API. Edges reflect shown calls, imports, or README-level architecture; some endpoint and analysis internals were not sampled.

Main entry points: [`backend/app/services/paper_service.py`](https://github.com/priyan-19/research_paper_analysis/blob/main/backend/app/services/paper_service.py) (Paper management), [`backend/app/embeddings/vector_store.py`](https://github.com/priyan-19/research_paper_analysis/blob/main/backend/app/embeddings/vector_store.py) (Vector search and index), [`backend/app/rag/hybrid_retriever.py`](https://github.com/priyan-19/research_paper_analysis/blob/main/backend/app/rag/hybrid_retriever.py) (Hybrid retrieval and RRF), [`backend/app/rag/chat_service.py`](https://github.com/priyan-19/research_paper_analysis/blob/main/backend/app/rag/chat_service.py) (Grounded chat)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interfaces["User interfaces"]
  node_dashboard["Streamlit dashboard<br/>[streamlit_app.py]"]
  node_api["REST API"]
  node_router["API router<br/>[router.py]"]
end

subgraph group_papers["Paper processing"]
  node_paper_service["Paper management<br/>[paper_service.py]"]
  node_pdf_loader["PDF extraction<br/>[pdf_loader.py]"]
  node_metadata["Metadata extraction"]
  node_chunker["Semantic chunking<br/>[chunker.py]"]
  node_worker["Paper processing worker"]
end

subgraph group_retrieval["Search and answers"]
  node_embedding["Embedding service"]
  node_vector_store["Vector search and index<br/>[vector_store.py]"]
  node_graph_retriever["Graph retrieval<br/>[graph_retriever.py]"]
  node_hybrid["Hybrid retrieval and RRF"]
  node_chat["Grounded chat<br/>[chat_service.py]"]
  node_vector_rag["Vector RAG"]
  node_llm["LLM providers"]
end

subgraph group_knowledge["Knowledge and analysis"]
  node_graph_build["Graph extraction and building"]
  node_canonicalizer["Entity canonicalization<br/>[canonicalizer.py]"]
  node_gnn["Link prediction"]
  node_analysis["Research analysis"]
  node_evaluation["RAG evaluation<br/>[metrics.py]"]
end

subgraph group_platform["Runtime and storage"]
  node_postgres[("PostgreSQL and pgvector<br/>[postgres.py]")]
  node_neo4j[("Neo4j graph store<br/>[neo4j.py]")]
  node_redis[("Redis<br/>[redis.py]")]
  node_main["Application runtime<br/>[main.py]"]
end

node_user(("Researcher"))

node_user -->|"uses"| node_dashboard
node_user -->|"requests"| node_api
node_dashboard -->|"manages papers"| node_paper_service
node_dashboard -->|"asks questions"| node_chat
node_dashboard -->|"searches evidence"| node_hybrid
node_dashboard -->|"runs predictions"| node_gnn
node_main -->|"mounts routes"| node_router
node_router -->|"registers endpoints"| node_api
node_api -.->|"manages papers"| node_paper_service
node_api -.->|"searches"| node_hybrid
node_api -.->|"answers questions"| node_chat
node_paper_service -->|"loads PDF"| node_pdf_loader
node_paper_service -->|"extracts metadata"| node_metadata
node_paper_service -->|"creates chunks"| node_chunker
node_paper_service -.->|"persists papers"| node_postgres
node_paper_service -->|"embeds chunks"| node_vector_store
node_worker -->|"loads PDF"| node_pdf_loader
node_worker -->|"chunks text"| node_chunker
node_worker -->|"stores embeddings"| node_vector_store
node_worker -->|"extracts graph"| node_graph_build
node_embedding -->|"creates vectors"| node_vector_store
node_vector_store -->|"searches and stores vectors"| node_postgres
node_hybrid -->|"retrieves vectors"| node_vector_store
node_hybrid -->|"retrieves graph context"| node_graph_retriever
node_hybrid -->|"fuses ranked results"| node_graph_retriever
node_graph_retriever -->|"traverses graph"| node_neo4j
node_graph_retriever -->|"canonicalizes entities"| node_canonicalizer
node_chat -->|"retrieves evidence"| node_hybrid
node_chat -->|"uses vector results"| node_vector_store
node_chat -->|"generates answer"| node_llm
node_vector_rag -->|"retrieves passages"| node_vector_store
node_vector_rag -->|"generates answer"| node_llm
node_graph_build -->|"builds graph"| node_neo4j
node_gnn -->|"uses canonical entities"| node_canonicalizer
node_analysis -->|"uses paper records"| node_paper_service
node_analysis -->|"checks similarity"| node_vector_store
node_main -->|"initializes"| node_postgres
node_main -->|"connects"| node_neo4j
node_main -->|"connects"| node_redis
node_evaluation -.->|"evaluates retrieval"| node_hybrid
node_chat -.->|"measured by"| node_evaluation

click node_dashboard "https://github.com/priyan-19/research_paper_analysis/blob/main/backend/streamlit_app.py"
click node_api "https://github.com/priyan-19/research_paper_analysis/tree/main/backend/app/api/v1"
click node_router "https://github.com/priyan-19/research_paper_analysis/blob/main/backend/app/api/v1/router.py"
click node_paper_service "https://github.com/priyan-19/research_paper_analysis/blob/main/backend/app/services/paper_service.py"
click node_pdf_loader "https://github.com/priyan-19/research_paper_analysis/blob/main/backend/app/ingestion/pdf_loader.py"
click node_metadata "https://github.com/priyan-19/research_paper_analysis/blob/main/backend/app/ingestion/metadata_extractor.py"
click node_chunker "https://github.com/priyan-19/research_paper_analysis/blob/main/backend/app/ingestion/chunker.py"
click node_worker "https://github.com/priyan-19/research_paper_analysis/blob/main/backend/app/workers/paper_processing.py"
click node_embedding "https://github.com/priyan-19/research_paper_analysis/blob/main/backend/app/embeddings/embedding_service.py"
click node_vector_store "https://github.com/priyan-19/research_paper_analysis/blob/main/backend/app/embeddings/vector_store.py"
click node_graph_retriever "https://github.com/priyan-19/research_paper_analysis/blob/main/backend/app/rag/graph_retriever.py"
click node_hybrid "https://github.com/priyan-19/research_paper_analysis/blob/main/backend/app/rag/hybrid_retriever.py"
click node_chat "https://github.com/priyan-19/research_paper_analysis/blob/main/backend/app/rag/chat_service.py"
click node_vector_rag "https://github.com/priyan-19/research_paper_analysis/blob/main/backend/app/rag/vector_rag_service.py"
click node_llm "https://github.com/priyan-19/research_paper_analysis/tree/main/backend/app/llm"
click node_graph_build "https://github.com/priyan-19/research_paper_analysis/tree/main/backend/app/graph"
click node_canonicalizer "https://github.com/priyan-19/research_paper_analysis/blob/main/backend/app/graph/canonicalizer.py"
click node_gnn "https://github.com/priyan-19/research_paper_analysis/blob/main/backend/app/graph/gnn_link_predictor.py"
click node_analysis "https://github.com/priyan-19/research_paper_analysis/tree/main/backend/app/analysis"
click node_evaluation "https://github.com/priyan-19/research_paper_analysis/blob/main/backend/app/evaluation/metrics.py"
click node_postgres "https://github.com/priyan-19/research_paper_analysis/blob/main/backend/app/database/postgres.py"
click node_neo4j "https://github.com/priyan-19/research_paper_analysis/blob/main/backend/app/database/neo4j.py"
click node_redis "https://github.com/priyan-19/research_paper_analysis/blob/main/backend/app/database/redis.py"
click node_main "https://github.com/priyan-19/research_paper_analysis/blob/main/backend/app/main.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_dashboard,node_api,node_router toneBlue
class node_paper_service,node_pdf_loader,node_metadata,node_chunker,node_worker toneAmber
class node_embedding,node_vector_store,node_graph_retriever,node_hybrid,node_chat,node_vector_rag,node_llm toneMint
class node_graph_build,node_canonicalizer,node_gnn,node_analysis,node_evaluation toneRose
class node_postgres,node_neo4j,node_redis,node_main,node_user toneIndigo
```

## Components

### User interfaces

- [Streamlit dashboard](https://github.com/priyan-19/research_paper_analysis/blob/main/backend/streamlit_app.py): `backend/streamlit_app.py`
- [REST API](https://github.com/priyan-19/research_paper_analysis/tree/main/backend/app/api/v1): `backend/app/api/v1`
- [API router](https://github.com/priyan-19/research_paper_analysis/blob/main/backend/app/api/v1/router.py): `backend/app/api/v1/router.py`

### Paper processing

- [Paper management](https://github.com/priyan-19/research_paper_analysis/blob/main/backend/app/services/paper_service.py): `backend/app/services/paper_service.py`
- [PDF extraction](https://github.com/priyan-19/research_paper_analysis/blob/main/backend/app/ingestion/pdf_loader.py): `backend/app/ingestion/pdf_loader.py`
- [Metadata extraction](https://github.com/priyan-19/research_paper_analysis/blob/main/backend/app/ingestion/metadata_extractor.py): `backend/app/ingestion/metadata_extractor.py`
- [Semantic chunking](https://github.com/priyan-19/research_paper_analysis/blob/main/backend/app/ingestion/chunker.py): `backend/app/ingestion/chunker.py`
- [Paper processing worker](https://github.com/priyan-19/research_paper_analysis/blob/main/backend/app/workers/paper_processing.py): `backend/app/workers/paper_processing.py`

### Search and answers

- [Embedding service](https://github.com/priyan-19/research_paper_analysis/blob/main/backend/app/embeddings/embedding_service.py): `backend/app/embeddings/embedding_service.py`
- [Vector search and index](https://github.com/priyan-19/research_paper_analysis/blob/main/backend/app/embeddings/vector_store.py): `backend/app/embeddings/vector_store.py`
- [Graph retrieval](https://github.com/priyan-19/research_paper_analysis/blob/main/backend/app/rag/graph_retriever.py): `backend/app/rag/graph_retriever.py`
- [Hybrid retrieval and RRF](https://github.com/priyan-19/research_paper_analysis/blob/main/backend/app/rag/hybrid_retriever.py): `backend/app/rag/hybrid_retriever.py`
- [Grounded chat](https://github.com/priyan-19/research_paper_analysis/blob/main/backend/app/rag/chat_service.py): `backend/app/rag/chat_service.py`
- [Vector RAG](https://github.com/priyan-19/research_paper_analysis/blob/main/backend/app/rag/vector_rag_service.py): `backend/app/rag/vector_rag_service.py`
- [LLM providers](https://github.com/priyan-19/research_paper_analysis/tree/main/backend/app/llm): `backend/app/llm`

### Knowledge and analysis

- [Graph extraction and building](https://github.com/priyan-19/research_paper_analysis/tree/main/backend/app/graph): `backend/app/graph`
- [Entity canonicalization](https://github.com/priyan-19/research_paper_analysis/blob/main/backend/app/graph/canonicalizer.py): `backend/app/graph/canonicalizer.py`
- [Link prediction](https://github.com/priyan-19/research_paper_analysis/blob/main/backend/app/graph/gnn_link_predictor.py): `backend/app/graph/gnn_link_predictor.py`
- [Research analysis](https://github.com/priyan-19/research_paper_analysis/tree/main/backend/app/analysis): `backend/app/analysis`
- [RAG evaluation](https://github.com/priyan-19/research_paper_analysis/blob/main/backend/app/evaluation/metrics.py): `backend/app/evaluation/metrics.py`

### Runtime and storage

- [PostgreSQL and pgvector](https://github.com/priyan-19/research_paper_analysis/blob/main/backend/app/database/postgres.py): `backend/app/database/postgres.py`
- [Neo4j graph store](https://github.com/priyan-19/research_paper_analysis/blob/main/backend/app/database/neo4j.py): `backend/app/database/neo4j.py`
- [Redis](https://github.com/priyan-19/research_paper_analysis/blob/main/backend/app/database/redis.py): `backend/app/database/redis.py`
- [Application runtime](https://github.com/priyan-19/research_paper_analysis/blob/main/backend/app/main.py): `backend/app/main.py`

### Other components

- **Researcher**

## Connections

- Researcher → Streamlit dashboard: uses (evidence: `README.md`)
- Researcher → REST API: requests (evidence: `README.md`)
- Streamlit dashboard → Paper management: manages papers (evidence: `backend/streamlit_app.py`)
- Streamlit dashboard → Grounded chat: asks questions (evidence: `backend/streamlit_app.py`)
- Streamlit dashboard → Hybrid retrieval and RRF: searches evidence (evidence: `backend/streamlit_app.py`)
- Streamlit dashboard → Link prediction: runs predictions (evidence: `backend/streamlit_app.py`)
- Application runtime → API router: mounts routes (evidence: `backend/app/main.py`)
- API router → REST API: registers endpoints (evidence: `backend/app/api/v1/router.py`)
- REST API → Paper management: manages papers
- REST API → Hybrid retrieval and RRF: searches
- REST API → Grounded chat: answers questions
- Paper management → PDF extraction: loads PDF (evidence: `backend/app/services/paper_service.py`)
- Paper management → Metadata extraction: extracts metadata (evidence: `backend/app/services/paper_service.py`)
- Paper management → Semantic chunking: creates chunks (evidence: `backend/app/services/paper_service.py`)
- Paper management → PostgreSQL and pgvector: persists papers
- Paper management → Vector search and index: embeds chunks (evidence: `backend/app/services/paper_service.py`)
- Paper processing worker → PDF extraction: loads PDF (evidence: `backend/app/workers/paper_processing.py`)
- Paper processing worker → Semantic chunking: chunks text (evidence: `backend/app/workers/paper_processing.py`)
- Paper processing worker → Vector search and index: stores embeddings (evidence: `backend/app/workers/paper_processing.py`)
- Paper processing worker → Graph extraction and building: extracts graph (evidence: `backend/app/workers/paper_processing.py`)
- Embedding service → Vector search and index: creates vectors (evidence: `backend/app/embeddings/vector_store.py`)
- Vector search and index → PostgreSQL and pgvector: searches and stores vectors (evidence: `backend/app/embeddings/vector_store.py`)
- Hybrid retrieval and RRF → Vector search and index: retrieves vectors (evidence: `backend/app/rag/hybrid_retriever.py`)
- Hybrid retrieval and RRF → Graph retrieval: retrieves graph context (evidence: `backend/app/rag/hybrid_retriever.py`)
- Hybrid retrieval and RRF → Graph retrieval: fuses ranked results (evidence: `backend/app/rag/hybrid_retriever.py`)
- Graph retrieval → Neo4j graph store: traverses graph (evidence: `backend/app/rag/graph_retriever.py`)
- Graph retrieval → Entity canonicalization: canonicalizes entities (evidence: `backend/app/rag/graph_retriever.py`)
- Grounded chat → Hybrid retrieval and RRF: retrieves evidence (evidence: `backend/app/rag/chat_service.py`)
- Grounded chat → Vector search and index: uses vector results (evidence: `backend/app/rag/chat_service.py`)
- Grounded chat → LLM providers: generates answer (evidence: `backend/app/rag/chat_service.py`)
- Vector RAG → Vector search and index: retrieves passages (evidence: `backend/app/rag/vector_rag_service.py`)
- Vector RAG → LLM providers: generates answer (evidence: `backend/app/rag/vector_rag_service.py`)
- Graph extraction and building → Neo4j graph store: builds graph (evidence: `backend/app/graph/neo4j_builder.py`)
- Link prediction → Entity canonicalization: uses canonical entities (evidence: `backend/app/graph/gnn_link_predictor.py`)
- Research analysis → Paper management: uses paper records (evidence: `backend/app/analysis/similarity_detector.py`)
- Research analysis → Vector search and index: checks similarity (evidence: `backend/app/analysis/similarity_detector.py`)
- Application runtime → PostgreSQL and pgvector: initializes (evidence: `backend/app/main.py`)
- Application runtime → Neo4j graph store: connects (evidence: `backend/app/main.py`)
- Application runtime → Redis: connects (evidence: `backend/app/main.py`)
- RAG evaluation → Hybrid retrieval and RRF: evaluates retrieval
- Grounded chat → RAG evaluation: measured by
