# nitin-kumar369/prepsyncv1 architecture

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

- Interactive diagram: https://gitdiagram.com/nitin-kumar369/prepsyncv1
- Repository: https://github.com/nitin-kumar369/prepsyncv1

## Overview

PrepSync is a textbook-browsing and RAG chat web app, with admin-managed PDF ingestion, authentication, and account features. The main workflow is admin upload through text chunking and indexing, followed by a user query that retrieves textbook context and returns a generated answer; chat and book data are persisted in MongoDB. The graph combines README workflow details with the source excerpts and index. Several route and frontend implementations were not excerpted, so uncertain internal calls are omitted.

Main entry points: [`backend/db.py`](https://github.com/nitin-kumar369/prepsyncv1/blob/main/backend/db.py) (MongoDB records), [`backend/routes/admin.py`](https://github.com/nitin-kumar369/prepsyncv1/blob/main/backend/routes/admin.py) (Admin routes), [`frontend/src/App.jsx`](https://github.com/nitin-kumar369/prepsyncv1/blob/main/frontend/src/App.jsx) (App routing), [`backend/main.py`](https://github.com/nitin-kumar369/prepsyncv1/blob/main/backend/main.py) (FastAPI app)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web interface"]
  node_frontend_app["App routing<br/>[App.jsx]"]
  node_chat_pages["Chat pages"]
  node_admin_page["Admin panel<br/>[Admin.jsx]"]
  node_auth_store["Auth store<br/>[authStore.js]"]
  node_chat_store["Chat store<br/>[chatStore.js]"]
  node_book_pages["Book browsing"]
end

subgraph group_api["API and access"]
  node_api_app["FastAPI app<br/>[main.py]"]
  node_auth_routes["Auth routes<br/>[auth.py]"]
  node_chat_routes["Chat routes<br/>[chat.py]"]
  node_admin_routes["Admin routes<br/>[admin.py]"]
  node_book_routes["Book routes<br/>[books.py]"]
  node_auth_logic["JWT auth<br/>[auth.py]"]
  node_models["Data models<br/>[models.py]"]
  node_config["Configuration<br/>[config.py]"]
end

subgraph group_ingest["Textbook ingestion"]
  node_chunking["Text chunking<br/>[chunking.py]"]
  node_formula["Formula extraction"]
end

subgraph group_rag["Retrieval and answers"]
  node_embedding["Embeddings"]
  node_vector_store["Vector retrieval<br/>[vector_store.py]"]
  node_llm["Answer generation<br/>[llm.py]"]
end

subgraph group_data["Persistence"]
  node_mongo[("MongoDB records<br/>[db.py]")]
end

node_student(("Student"))
node_admin_user(("Admin"))
node_user_db[("MongoDB")]

node_student -->|"uses"| node_frontend_app
node_admin_user -->|"uses"| node_frontend_app
node_frontend_app -->|"routes to"| node_chat_pages
node_frontend_app -->|"routes to"| node_admin_page
node_frontend_app -->|"routes to"| node_book_pages
node_frontend_app -->|"initializes"| node_auth_store
node_chat_pages -->|"uses"| node_chat_store
node_auth_store -->|"requests auth"| node_auth_routes
node_api_app -->|"mounts"| node_auth_routes
node_api_app -->|"mounts"| node_chat_routes
node_api_app -->|"mounts"| node_admin_routes
node_api_app -.->|"mounts"| node_book_routes
node_auth_routes -->|"uses"| node_auth_logic
node_chat_routes -->|"uses"| node_auth_logic
node_admin_routes -->|"uses"| node_auth_logic
node_auth_routes -->|"uses"| node_mongo
node_chat_routes -->|"loads and saves"| node_mongo
node_admin_routes -->|"manages records"| node_mongo
node_book_routes -->|"uses"| node_mongo
node_admin_routes -->|"chunks uploads"| node_chunking
node_admin_routes -->|"indexes books"| node_vector_store
node_admin_routes -.->|"extracts formulas"| node_formula
node_chat_routes -->|"retrieves context"| node_vector_store
node_chat_routes -->|"generates answer"| node_llm
node_vector_store -->|"uses embeddings"| node_embedding
node_embedding -->|"reads and updates chunks"| node_mongo
node_vector_store -->|"stores and queries chunks"| node_mongo
node_mongo -->|"connects to"| node_user_db
node_api_app -->|"validates settings"| node_config

click node_frontend_app "https://github.com/nitin-kumar369/prepsyncv1/blob/main/frontend/src/App.jsx"
click node_chat_pages "https://github.com/nitin-kumar369/prepsyncv1/tree/main/frontend/src/pages"
click node_admin_page "https://github.com/nitin-kumar369/prepsyncv1/blob/main/frontend/src/pages/Admin.jsx"
click node_auth_store "https://github.com/nitin-kumar369/prepsyncv1/blob/main/frontend/src/store/authStore.js"
click node_chat_store "https://github.com/nitin-kumar369/prepsyncv1/blob/main/frontend/src/store/chatStore.js"
click node_book_pages "https://github.com/nitin-kumar369/prepsyncv1/tree/main/frontend/src/pages"
click node_api_app "https://github.com/nitin-kumar369/prepsyncv1/blob/main/backend/main.py"
click node_auth_routes "https://github.com/nitin-kumar369/prepsyncv1/blob/main/backend/routes/auth.py"
click node_chat_routes "https://github.com/nitin-kumar369/prepsyncv1/blob/main/backend/routes/chat.py"
click node_admin_routes "https://github.com/nitin-kumar369/prepsyncv1/blob/main/backend/routes/admin.py"
click node_book_routes "https://github.com/nitin-kumar369/prepsyncv1/blob/main/backend/routes/books.py"
click node_auth_logic "https://github.com/nitin-kumar369/prepsyncv1/blob/main/backend/auth.py"
click node_models "https://github.com/nitin-kumar369/prepsyncv1/blob/main/backend/models.py"
click node_chunking "https://github.com/nitin-kumar369/prepsyncv1/blob/main/backend/rag/chunking.py"
click node_formula "https://github.com/nitin-kumar369/prepsyncv1/blob/main/backend/rag/formula_extractor.py"
click node_embedding "https://github.com/nitin-kumar369/prepsyncv1/blob/main/backend/rag/embedding_manager.py"
click node_vector_store "https://github.com/nitin-kumar369/prepsyncv1/blob/main/backend/rag/vector_store.py"
click node_llm "https://github.com/nitin-kumar369/prepsyncv1/blob/main/backend/rag/llm.py"
click node_mongo "https://github.com/nitin-kumar369/prepsyncv1/blob/main/backend/db.py"
click node_config "https://github.com/nitin-kumar369/prepsyncv1/blob/main/backend/config.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_chat_pages,node_admin_page,node_auth_store,node_chat_store,node_book_pages toneBlue
class node_api_app,node_auth_routes,node_chat_routes,node_admin_routes,node_book_routes,node_auth_logic,node_models,node_config,node_user_db toneAmber
class node_chunking,node_formula toneMint
class node_embedding,node_vector_store,node_llm toneRose
class node_mongo,node_student,node_admin_user toneIndigo
```

## Components

### Web interface

- [App routing](https://github.com/nitin-kumar369/prepsyncv1/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Chat pages](https://github.com/nitin-kumar369/prepsyncv1/tree/main/frontend/src/pages): `frontend/src/pages`
- [Admin panel](https://github.com/nitin-kumar369/prepsyncv1/blob/main/frontend/src/pages/Admin.jsx): `frontend/src/pages/Admin.jsx`
- [Auth store](https://github.com/nitin-kumar369/prepsyncv1/blob/main/frontend/src/store/authStore.js): `frontend/src/store/authStore.js`
- [Chat store](https://github.com/nitin-kumar369/prepsyncv1/blob/main/frontend/src/store/chatStore.js): `frontend/src/store/chatStore.js`
- [Book browsing](https://github.com/nitin-kumar369/prepsyncv1/tree/main/frontend/src/pages): `frontend/src/pages`

### API and access

- [FastAPI app](https://github.com/nitin-kumar369/prepsyncv1/blob/main/backend/main.py): `backend/main.py`
- [Auth routes](https://github.com/nitin-kumar369/prepsyncv1/blob/main/backend/routes/auth.py): `backend/routes/auth.py`
- [Chat routes](https://github.com/nitin-kumar369/prepsyncv1/blob/main/backend/routes/chat.py): `backend/routes/chat.py`
- [Admin routes](https://github.com/nitin-kumar369/prepsyncv1/blob/main/backend/routes/admin.py): `backend/routes/admin.py`
- [Book routes](https://github.com/nitin-kumar369/prepsyncv1/blob/main/backend/routes/books.py): `backend/routes/books.py`
- [JWT auth](https://github.com/nitin-kumar369/prepsyncv1/blob/main/backend/auth.py): `backend/auth.py`
- [Data models](https://github.com/nitin-kumar369/prepsyncv1/blob/main/backend/models.py): `backend/models.py`
- [Configuration](https://github.com/nitin-kumar369/prepsyncv1/blob/main/backend/config.py): `backend/config.py`

### Textbook ingestion

- [Text chunking](https://github.com/nitin-kumar369/prepsyncv1/blob/main/backend/rag/chunking.py): `backend/rag/chunking.py`
- [Formula extraction](https://github.com/nitin-kumar369/prepsyncv1/blob/main/backend/rag/formula_extractor.py): `backend/rag/formula_extractor.py`

### Retrieval and answers

- [Embeddings](https://github.com/nitin-kumar369/prepsyncv1/blob/main/backend/rag/embedding_manager.py): `backend/rag/embedding_manager.py`
- [Vector retrieval](https://github.com/nitin-kumar369/prepsyncv1/blob/main/backend/rag/vector_store.py): `backend/rag/vector_store.py`
- [Answer generation](https://github.com/nitin-kumar369/prepsyncv1/blob/main/backend/rag/llm.py): `backend/rag/llm.py`

### Persistence

- [MongoDB records](https://github.com/nitin-kumar369/prepsyncv1/blob/main/backend/db.py): `backend/db.py`

### Other components

- **Student**
- **Admin**
- **MongoDB**

## Connections

- Student → App routing: uses (evidence: `frontend/src/App.jsx`)
- Admin → App routing: uses (evidence: `frontend/src/App.jsx`)
- App routing → Chat pages: routes to (evidence: `frontend/src/App.jsx`)
- App routing → Admin panel: routes to (evidence: `frontend/src/App.jsx`)
- App routing → Book browsing: routes to (evidence: `frontend/src/App.jsx`)
- App routing → Auth store: initializes (evidence: `frontend/src/App.jsx`)
- Chat pages → Chat store: uses (evidence: `frontend/src/pages/ChatSession.jsx`)
- Auth store → Auth routes: requests auth (evidence: `frontend/src/store/authStore.js`)
- FastAPI app → Auth routes: mounts (evidence: `backend/main.py`)
- FastAPI app → Chat routes: mounts (evidence: `backend/main.py`)
- FastAPI app → Admin routes: mounts (evidence: `backend/main.py`)
- FastAPI app → Book routes: mounts (evidence: `backend/main.py`)
- Auth routes → JWT auth: uses (evidence: `backend/routes/auth.py`)
- Chat routes → JWT auth: uses (evidence: `backend/routes/chat.py`)
- Admin routes → JWT auth: uses (evidence: `backend/routes/admin.py`)
- Auth routes → MongoDB records: uses (evidence: `backend/routes/auth.py`)
- Chat routes → MongoDB records: loads and saves (evidence: `backend/routes/chat.py`)
- Admin routes → MongoDB records: manages records (evidence: `backend/routes/admin.py`)
- Book routes → MongoDB records: uses (evidence: `backend/routes/books.py`)
- Admin routes → Text chunking: chunks uploads (evidence: `backend/routes/admin.py`)
- Admin routes → Vector retrieval: indexes books (evidence: `backend/routes/admin.py`)
- Admin routes → Formula extraction: extracts formulas
- Chat routes → Vector retrieval: retrieves context (evidence: `backend/routes/chat.py`)
- Chat routes → Answer generation: generates answer (evidence: `backend/routes/chat.py`)
- Vector retrieval → Embeddings: uses embeddings (evidence: `backend/rag/vector_store.py`)
- Embeddings → MongoDB records: reads and updates chunks (evidence: `backend/rag/embedding_manager.py`)
- Vector retrieval → MongoDB records: stores and queries chunks (evidence: `backend/rag/vector_store.py`)
- MongoDB records → MongoDB: connects to (evidence: `README.md`)
- FastAPI app → Configuration: validates settings (evidence: `backend/main.py`)
