# harsheetha-2003/research_paper_chabot architecture

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

- Interactive diagram: https://gitdiagram.com/harsheetha-2003/research_paper_chabot
- Repository: https://github.com/harsheetha-2003/research_paper_chabot

## Overview

This is a web application for authenticated research-paper upload and conversational, document-grounded question answering. The main path is user → frontend → FastAPI routes → document embedding or retrieval → generated answer; users can also browse history, request suggested questions and a table of contents, and manage documents. Authentication and persistent records support those workflows. The route, retrieval, and embedding relationships are grounded in shown excerpts or the source index; some capability links are documented in the README, while unsampled implementation details are left unconnected.

Main entry points: [`workingchatbot-4/backend/main.py`](https://github.com/harsheetha-2003/research_paper_chabot/blob/main/workingchatbot-4/backend/main.py) (FastAPI entry), [`workingchatbot-4/backend/database/schema.py`](https://github.com/harsheetha-2003/research_paper_chabot/blob/main/workingchatbot-4/backend/database/schema.py) (Relational records), [`workingchatbot-4/backend/api/routes/chat.py`](https://github.com/harsheetha-2003/research_paper_chabot/blob/main/workingchatbot-4/backend/api/routes/chat.py) (Chat endpoint), [`workingchatbot-4/backend/services/retriever.py`](https://github.com/harsheetha-2003/research_paper_chabot/blob/main/workingchatbot-4/backend/services/retriever.py) (Semantic retrieval)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web interface"]
  node_frontend_app["Web app<br/>[App.js]"]
  node_dashboard["Research dashboard<br/>[DashboardPage.js]"]
  node_legacy_ui["Web client<br/>[script.js]"]
end

subgraph group_api["API and access"]
  node_api_entry["FastAPI entry<br/>[main.py]"]
  node_auth_routes["Authentication<br/>[auth.py]"]
  node_session["Session handling<br/>[session.py]"]
  node_upload["PDF upload<br/>[upload.py]"]
  node_chat["Chat endpoint<br/>[chat.py]"]
  node_doc_views["Document browsing<br/>[view_docs.py]"]
  node_management["Document management<br/>[management.py]"]
end

subgraph group_documents["Document intelligence"]
  node_embedding["Embedding and index<br/>[embedder.py]"]
  node_processing["Document processing"]
  node_retrieval["Semantic retrieval<br/>[retriever.py]"]
  node_llm["Answer generation<br/>[orchestrator.py]"]
end

subgraph group_conversation["Conversation features"]
  node_history_api["History endpoint"]
  node_history_service["Chat history<br/>[chat_history.py]"]
  node_suggestions["Suggested questions"]
  node_question_generator["Question generation"]
  node_toc_api["Contents endpoint"]
  node_toc_extractor["Contents extraction<br/>[toc_extractor.py]"]
  node_citation["Citation endpoint<br/>[citation.py]"]
  node_citation_mapper["Citation mapping<br/>[citation_mapper.py]"]
end

subgraph group_state["Application state"]
  node_database[("Relational records<br/>[schema.py]")]
end

node_user(("Researcher"))
node_llm_service{{"OpenRouter"}}

node_user -->|"uses"| node_frontend_app
node_frontend_app -.->|"requests API"| node_api_entry
node_api_entry -->|"registers route"| node_upload
node_api_entry -->|"registers route"| node_chat
node_api_entry -->|"registers route"| node_auth_routes
node_api_entry -->|"registers route"| node_doc_views
node_api_entry -->|"registers route"| node_history_api
node_api_entry -->|"registers route"| node_management
node_api_entry -->|"registers route"| node_suggestions
node_api_entry -->|"registers route"| node_toc_api
node_auth_routes -->|"manages sessions"| node_session
node_auth_routes -->|"reads and writes"| node_database
node_upload -->|"gets user"| node_session
node_upload -->|"embeds document"| node_embedding
node_upload -->|"stores document"| node_database
node_chat -->|"gets user"| node_session
node_chat -->|"checks and saves"| node_database
node_chat -->|"retrieves context"| node_retrieval
node_retrieval -->|"requests answer"| node_llm
node_llm -->|"sends prompt"| node_llm_service
node_retrieval -->|"saves exchange"| node_history_service
node_history_api -->|"loads history"| node_history_service
node_management -->|"removes history"| node_history_service
node_management -->|"deletes records"| node_database
node_suggestions -->|"generates questions"| node_question_generator
node_suggestions -->|"reads and writes"| node_database
node_toc_api -->|"extracts contents"| node_toc_extractor
node_toc_api -->|"stores contents"| node_database
node_citation -->|"reads records"| node_database
node_chat -->|"maps citations"| node_citation_mapper
node_dashboard -.->|"renders in"| node_frontend_app
node_legacy_ui -.->|"requests API"| node_api_entry
node_embedding -.->|"parses document"| node_processing
node_embedding -.->|"indexes embeddings"| node_retrieval
node_retrieval -.->|"uses model"| node_llm_service

click node_frontend_app "https://github.com/harsheetha-2003/research_paper_chabot/blob/main/workingchatbot-4/frontend/src/App.js"
click node_dashboard "https://github.com/harsheetha-2003/research_paper_chabot/blob/main/workingchatbot-4/frontend/src/pages/DashboardPage.js"
click node_legacy_ui "https://github.com/harsheetha-2003/research_paper_chabot/blob/main/workingchatbot-4/frontend/script.js"
click node_api_entry "https://github.com/harsheetha-2003/research_paper_chabot/blob/main/workingchatbot-4/backend/main.py"
click node_auth_routes "https://github.com/harsheetha-2003/research_paper_chabot/blob/main/workingchatbot-4/backend/api/routes/auth.py"
click node_session "https://github.com/harsheetha-2003/research_paper_chabot/blob/main/workingchatbot-4/backend/services/session.py"
click node_upload "https://github.com/harsheetha-2003/research_paper_chabot/blob/main/workingchatbot-4/backend/api/routes/upload.py"
click node_chat "https://github.com/harsheetha-2003/research_paper_chabot/blob/main/workingchatbot-4/backend/api/routes/chat.py"
click node_doc_views "https://github.com/harsheetha-2003/research_paper_chabot/blob/main/workingchatbot-4/backend/api/routes/view_docs.py"
click node_management "https://github.com/harsheetha-2003/research_paper_chabot/blob/main/workingchatbot-4/backend/api/routes/management.py"
click node_embedding "https://github.com/harsheetha-2003/research_paper_chabot/blob/main/workingchatbot-4/backend/services/embedder.py"
click node_processing "https://github.com/harsheetha-2003/research_paper_chabot/blob/main/workingchatbot-4/backend/services/document_processor.py"
click node_retrieval "https://github.com/harsheetha-2003/research_paper_chabot/blob/main/workingchatbot-4/backend/services/retriever.py"
click node_llm "https://github.com/harsheetha-2003/research_paper_chabot/blob/main/workingchatbot-4/backend/orchestrator.py"
click node_history_api "https://github.com/harsheetha-2003/research_paper_chabot/blob/main/workingchatbot-4/backend/api/routes/chat_history_api.py"
click node_history_service "https://github.com/harsheetha-2003/research_paper_chabot/blob/main/workingchatbot-4/backend/services/chat_history.py"
click node_suggestions "https://github.com/harsheetha-2003/research_paper_chabot/blob/main/workingchatbot-4/backend/api/routes/suggested_questions.py"
click node_question_generator "https://github.com/harsheetha-2003/research_paper_chabot/blob/main/workingchatbot-4/backend/services/question_generator.py"
click node_toc_api "https://github.com/harsheetha-2003/research_paper_chabot/blob/main/workingchatbot-4/backend/api/routes/table_of_contents.py"
click node_toc_extractor "https://github.com/harsheetha-2003/research_paper_chabot/blob/main/workingchatbot-4/backend/services/toc_extractor.py"
click node_citation "https://github.com/harsheetha-2003/research_paper_chabot/blob/main/workingchatbot-4/backend/api/routes/citation.py"
click node_citation_mapper "https://github.com/harsheetha-2003/research_paper_chabot/blob/main/workingchatbot-4/backend/services/citation_mapper.py"
click node_database "https://github.com/harsheetha-2003/research_paper_chabot/blob/main/workingchatbot-4/backend/database/schema.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_frontend_app,node_dashboard,node_legacy_ui toneBlue
class node_api_entry,node_auth_routes,node_session,node_upload,node_chat,node_doc_views,node_management toneAmber
class node_embedding,node_processing,node_retrieval,node_llm,node_llm_service toneMint
class node_history_api,node_history_service,node_suggestions,node_question_generator,node_toc_api,node_toc_extractor,node_citation,node_citation_mapper toneRose
class node_database,node_user toneIndigo
```

## Components

### Web interface

- [Web app](https://github.com/harsheetha-2003/research_paper_chabot/blob/main/workingchatbot-4/frontend/src/App.js): `workingchatbot-4/frontend/src/App.js`
- [Research dashboard](https://github.com/harsheetha-2003/research_paper_chabot/blob/main/workingchatbot-4/frontend/src/pages/DashboardPage.js): `workingchatbot-4/frontend/src/pages/DashboardPage.js`
- [Web client](https://github.com/harsheetha-2003/research_paper_chabot/blob/main/workingchatbot-4/frontend/script.js): `workingchatbot-4/frontend/script.js`

### API and access

- [FastAPI entry](https://github.com/harsheetha-2003/research_paper_chabot/blob/main/workingchatbot-4/backend/main.py): `workingchatbot-4/backend/main.py`
- [Authentication](https://github.com/harsheetha-2003/research_paper_chabot/blob/main/workingchatbot-4/backend/api/routes/auth.py): `workingchatbot-4/backend/api/routes/auth.py`
- [Session handling](https://github.com/harsheetha-2003/research_paper_chabot/blob/main/workingchatbot-4/backend/services/session.py): `workingchatbot-4/backend/services/session.py`
- [PDF upload](https://github.com/harsheetha-2003/research_paper_chabot/blob/main/workingchatbot-4/backend/api/routes/upload.py): `workingchatbot-4/backend/api/routes/upload.py`
- [Chat endpoint](https://github.com/harsheetha-2003/research_paper_chabot/blob/main/workingchatbot-4/backend/api/routes/chat.py): `workingchatbot-4/backend/api/routes/chat.py`
- [Document browsing](https://github.com/harsheetha-2003/research_paper_chabot/blob/main/workingchatbot-4/backend/api/routes/view_docs.py): `workingchatbot-4/backend/api/routes/view_docs.py`
- [Document management](https://github.com/harsheetha-2003/research_paper_chabot/blob/main/workingchatbot-4/backend/api/routes/management.py): `workingchatbot-4/backend/api/routes/management.py`

### Document intelligence

- [Embedding and index](https://github.com/harsheetha-2003/research_paper_chabot/blob/main/workingchatbot-4/backend/services/embedder.py): `workingchatbot-4/backend/services/embedder.py`
- [Document processing](https://github.com/harsheetha-2003/research_paper_chabot/blob/main/workingchatbot-4/backend/services/document_processor.py): `workingchatbot-4/backend/services/document_processor.py`
- [Semantic retrieval](https://github.com/harsheetha-2003/research_paper_chabot/blob/main/workingchatbot-4/backend/services/retriever.py): `workingchatbot-4/backend/services/retriever.py`
- [Answer generation](https://github.com/harsheetha-2003/research_paper_chabot/blob/main/workingchatbot-4/backend/orchestrator.py): `workingchatbot-4/backend/orchestrator.py`

### Conversation features

- [History endpoint](https://github.com/harsheetha-2003/research_paper_chabot/blob/main/workingchatbot-4/backend/api/routes/chat_history_api.py): `workingchatbot-4/backend/api/routes/chat_history_api.py`
- [Chat history](https://github.com/harsheetha-2003/research_paper_chabot/blob/main/workingchatbot-4/backend/services/chat_history.py): `workingchatbot-4/backend/services/chat_history.py`
- [Suggested questions](https://github.com/harsheetha-2003/research_paper_chabot/blob/main/workingchatbot-4/backend/api/routes/suggested_questions.py): `workingchatbot-4/backend/api/routes/suggested_questions.py`
- [Question generation](https://github.com/harsheetha-2003/research_paper_chabot/blob/main/workingchatbot-4/backend/services/question_generator.py): `workingchatbot-4/backend/services/question_generator.py`
- [Contents endpoint](https://github.com/harsheetha-2003/research_paper_chabot/blob/main/workingchatbot-4/backend/api/routes/table_of_contents.py): `workingchatbot-4/backend/api/routes/table_of_contents.py`
- [Contents extraction](https://github.com/harsheetha-2003/research_paper_chabot/blob/main/workingchatbot-4/backend/services/toc_extractor.py): `workingchatbot-4/backend/services/toc_extractor.py`
- [Citation endpoint](https://github.com/harsheetha-2003/research_paper_chabot/blob/main/workingchatbot-4/backend/api/routes/citation.py): `workingchatbot-4/backend/api/routes/citation.py`
- [Citation mapping](https://github.com/harsheetha-2003/research_paper_chabot/blob/main/workingchatbot-4/backend/services/citation_mapper.py): `workingchatbot-4/backend/services/citation_mapper.py`

### Application state

- [Relational records](https://github.com/harsheetha-2003/research_paper_chabot/blob/main/workingchatbot-4/backend/database/schema.py): `workingchatbot-4/backend/database/schema.py`

### Other components

- **Researcher**
- **OpenRouter**

## Connections

- Researcher → Web app: uses
- Web app → FastAPI entry: requests API
- FastAPI entry → PDF upload: registers route (evidence: `workingchatbot-4/backend/main.py`)
- FastAPI entry → Chat endpoint: registers route (evidence: `workingchatbot-4/backend/main.py`)
- FastAPI entry → Authentication: registers route (evidence: `workingchatbot-4/backend/main.py`)
- FastAPI entry → Document browsing: registers route (evidence: `workingchatbot-4/backend/main.py`)
- FastAPI entry → History endpoint: registers route (evidence: `workingchatbot-4/backend/main.py`)
- FastAPI entry → Document management: registers route (evidence: `workingchatbot-4/backend/main.py`)
- FastAPI entry → Suggested questions: registers route (evidence: `workingchatbot-4/backend/main.py`)
- FastAPI entry → Contents endpoint: registers route (evidence: `workingchatbot-4/backend/main.py`)
- Authentication → Session handling: manages sessions (evidence: `workingchatbot-4/backend/api/routes/auth.py`)
- Authentication → Relational records: reads and writes (evidence: `workingchatbot-4/backend/api/routes/auth.py`)
- PDF upload → Session handling: gets user (evidence: `workingchatbot-4/backend/api/routes/upload.py`)
- PDF upload → Embedding and index: embeds document (evidence: `workingchatbot-4/backend/api/routes/upload.py`)
- PDF upload → Relational records: stores document (evidence: `workingchatbot-4/backend/api/routes/upload.py`)
- Chat endpoint → Session handling: gets user (evidence: `workingchatbot-4/backend/api/routes/chat.py`)
- Chat endpoint → Relational records: checks and saves (evidence: `workingchatbot-4/backend/api/routes/chat.py`)
- Chat endpoint → Semantic retrieval: retrieves context (evidence: `workingchatbot-4/backend/api/routes/chat.py`)
- Semantic retrieval → Answer generation: requests answer (evidence: `workingchatbot-4/backend/services/retriever.py`)
- Answer generation → OpenRouter: sends prompt (evidence: `workingchatbot-4/backend/orchestrator.py`)
- Semantic retrieval → Chat history: saves exchange (evidence: `workingchatbot-4/backend/services/retriever.py`)
- History endpoint → Chat history: loads history (evidence: `workingchatbot-4/backend/api/routes/chat_history_api.py`)
- Document management → Chat history: removes history (evidence: `workingchatbot-4/backend/api/routes/management.py`)
- Document management → Relational records: deletes records (evidence: `workingchatbot-4/backend/api/routes/management.py`)
- Suggested questions → Question generation: generates questions (evidence: `workingchatbot-4/backend/api/routes/suggested_questions.py`)
- Suggested questions → Relational records: reads and writes (evidence: `workingchatbot-4/backend/api/routes/suggested_questions.py`)
- Contents endpoint → Contents extraction: extracts contents (evidence: `workingchatbot-4/backend/api/routes/table_of_contents.py`)
- Contents endpoint → Relational records: stores contents (evidence: `workingchatbot-4/backend/api/routes/table_of_contents.py`)
- Citation endpoint → Relational records: reads records (evidence: `workingchatbot-4/backend/api/routes/citation.py`)
- Chat endpoint → Citation mapping: maps citations (evidence: `workingchatbot-4/backend/api/routes/chat.py`)
- Research dashboard → Web app: renders in
- Web client → FastAPI entry: requests API
- Embedding and index → Document processing: parses document
- Embedding and index → Semantic retrieval: indexes embeddings
- Semantic retrieval → OpenRouter: uses model
