# maulikgupta27/studymate-ai architecture

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

- Interactive diagram: https://gitdiagram.com/maulikgupta27/studymate-ai
- Repository: https://github.com/maulikgupta27/studymate-ai

## Overview

StudyMate AI is a multi-user PDF study assistant. Users authenticate, upload PDFs for per-session indexing, then ask questions and receive answers grounded in retrieved pages with citations; document listing, deletion, caching, and persistent memory support that workflow. The graph separates the React interface, API orchestration, document indexing, and answer retrieval. The README documents major capabilities, while some route and retrieval implementation details are only partially excerpted; uncertain internal links are omitted.

Main entry points: [`frontend/src/App.jsx`](https://github.com/maulikgupta27/studymate-ai/blob/main/frontend/src/App.jsx) (App orchestration), [`backend/app/routes.py`](https://github.com/maulikgupta27/studymate-ai/blob/main/backend/app/routes.py) (API routes), [`backend/app/services/retrieval.py`](https://github.com/maulikgupta27/studymate-ai/blob/main/backend/app/services/retrieval.py) (Search and citations), [`frontend/src/components/LockScreen.jsx`](https://github.com/maulikgupta27/studymate-ai/blob/main/frontend/src/components/LockScreen.jsx) (Passcode screen)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Study interface"]
  node_app["App orchestration<br/>[App.jsx]"]
  node_lock["Passcode screen<br/>[LockScreen.jsx]"]
  node_uploadui["PDF uploader"]
  node_doclist["Document list"]
  node_askui["Question interface"]
  node_header["Session header<br/>[Header.jsx]"]
end

subgraph group_api["API and sessions"]
  node_client["API client<br/>[api.js]"]
  node_server["FastAPI application<br/>[main.py]"]
  node_routes["API routes<br/>[routes.py]"]
  node_schemas["Request schemas<br/>[schemas.py]"]
  node_config["Runtime settings<br/>[config.py]"]
end

subgraph group_index["PDF indexing"]
  node_ingest["PDF ingestion<br/>[indexing.py]"]
  node_chroma[("ChromaDB vectors")]
end

subgraph group_qa["Grounded answers"]
  node_retrieval["Search and citations<br/>[retrieval.py]"]
  node_memory["Memory and cache<br/>[memory.py]"]
  node_openai{{"OpenAI models"}}
  node_mem0[("Mem0 memory service")]
end

node_student(("Student"))

node_student -->|"enters passcode"| node_lock
node_lock -->|"verifies passcode"| node_client
node_app -->|"renders when locked"| node_lock
node_app -->|"renders"| node_header
node_app -->|"renders"| node_uploadui
node_app -->|"renders"| node_doclist
node_app -->|"renders"| node_askui
node_app -->|"requests API"| node_client
node_uploadui -->|"submits files"| node_app
node_askui -->|"submits questions"| node_app
node_doclist -->|"requests actions"| node_app
node_client -->|"sends HTTP requests"| node_server
node_server -->|"mounts routes"| node_routes
node_routes -->|"validates payloads"| node_schemas
node_routes -->|"indexes uploads"| node_ingest
node_ingest -->|"stores embeddings"| node_chroma
node_routes -->|"runs search and Q&amp;A"| node_retrieval
node_retrieval -->|"searches vectors"| node_chroma
node_retrieval -->|"checks and records"| node_memory
node_retrieval -->|"generates answers"| node_openai
node_memory -->|"reads and stores memories"| node_mem0
node_routes -->|"clears user data"| node_memory
node_config -->|"sets limits and store"| node_ingest
node_config -->|"sets model and store"| node_retrieval

click node_app "https://github.com/maulikgupta27/studymate-ai/blob/main/frontend/src/App.jsx"
click node_lock "https://github.com/maulikgupta27/studymate-ai/blob/main/frontend/src/components/LockScreen.jsx"
click node_uploadui "https://github.com/maulikgupta27/studymate-ai/blob/main/frontend/src/components/UploadPdfSection.jsx"
click node_doclist "https://github.com/maulikgupta27/studymate-ai/blob/main/frontend/src/components/UploadedPdfList.jsx"
click node_askui "https://github.com/maulikgupta27/studymate-ai/blob/main/frontend/src/components/AskQuestionSection.jsx"
click node_header "https://github.com/maulikgupta27/studymate-ai/blob/main/frontend/src/components/Header.jsx"
click node_client "https://github.com/maulikgupta27/studymate-ai/blob/main/frontend/src/api.js"
click node_server "https://github.com/maulikgupta27/studymate-ai/blob/main/backend/app/main.py"
click node_routes "https://github.com/maulikgupta27/studymate-ai/blob/main/backend/app/routes.py"
click node_schemas "https://github.com/maulikgupta27/studymate-ai/blob/main/backend/app/schemas.py"
click node_config "https://github.com/maulikgupta27/studymate-ai/blob/main/backend/app/config.py"
click node_ingest "https://github.com/maulikgupta27/studymate-ai/blob/main/backend/app/services/indexing.py"
click node_retrieval "https://github.com/maulikgupta27/studymate-ai/blob/main/backend/app/services/retrieval.py"
click node_memory "https://github.com/maulikgupta27/studymate-ai/blob/main/backend/app/services/memory.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_app,node_lock,node_uploadui,node_doclist,node_askui,node_header toneBlue
class node_client,node_server,node_routes,node_schemas,node_config toneAmber
class node_ingest,node_chroma toneMint
class node_retrieval,node_memory,node_openai,node_mem0 toneRose
class node_student toneIndigo
```

## Components

### Study interface

- [App orchestration](https://github.com/maulikgupta27/studymate-ai/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Passcode screen](https://github.com/maulikgupta27/studymate-ai/blob/main/frontend/src/components/LockScreen.jsx): `frontend/src/components/LockScreen.jsx`
- [PDF uploader](https://github.com/maulikgupta27/studymate-ai/blob/main/frontend/src/components/UploadPdfSection.jsx): `frontend/src/components/UploadPdfSection.jsx`
- [Document list](https://github.com/maulikgupta27/studymate-ai/blob/main/frontend/src/components/UploadedPdfList.jsx): `frontend/src/components/UploadedPdfList.jsx`
- [Question interface](https://github.com/maulikgupta27/studymate-ai/blob/main/frontend/src/components/AskQuestionSection.jsx): `frontend/src/components/AskQuestionSection.jsx`
- [Session header](https://github.com/maulikgupta27/studymate-ai/blob/main/frontend/src/components/Header.jsx): `frontend/src/components/Header.jsx`

### API and sessions

- [API client](https://github.com/maulikgupta27/studymate-ai/blob/main/frontend/src/api.js): `frontend/src/api.js`
- [FastAPI application](https://github.com/maulikgupta27/studymate-ai/blob/main/backend/app/main.py): `backend/app/main.py`
- [API routes](https://github.com/maulikgupta27/studymate-ai/blob/main/backend/app/routes.py): `backend/app/routes.py`
- [Request schemas](https://github.com/maulikgupta27/studymate-ai/blob/main/backend/app/schemas.py): `backend/app/schemas.py`
- [Runtime settings](https://github.com/maulikgupta27/studymate-ai/blob/main/backend/app/config.py): `backend/app/config.py`

### PDF indexing

- [PDF ingestion](https://github.com/maulikgupta27/studymate-ai/blob/main/backend/app/services/indexing.py): `backend/app/services/indexing.py`
- **ChromaDB vectors**

### Grounded answers

- [Search and citations](https://github.com/maulikgupta27/studymate-ai/blob/main/backend/app/services/retrieval.py): `backend/app/services/retrieval.py`
- [Memory and cache](https://github.com/maulikgupta27/studymate-ai/blob/main/backend/app/services/memory.py): `backend/app/services/memory.py`
- **OpenAI models**
- **Mem0 memory service**

### Other components

- **Student**

## Connections

- Student → Passcode screen: enters passcode (evidence: `frontend/src/components/LockScreen.jsx`)
- Passcode screen → API client: verifies passcode (evidence: `frontend/src/components/LockScreen.jsx`)
- App orchestration → Passcode screen: renders when locked (evidence: `frontend/src/App.jsx`)
- App orchestration → Session header: renders (evidence: `frontend/src/App.jsx`)
- App orchestration → PDF uploader: renders (evidence: `frontend/src/App.jsx`)
- App orchestration → Document list: renders (evidence: `frontend/src/App.jsx`)
- App orchestration → Question interface: renders (evidence: `frontend/src/App.jsx`)
- App orchestration → API client: requests API (evidence: `frontend/src/App.jsx`)
- PDF uploader → App orchestration: submits files (evidence: `frontend/src/components/UploadPdfSection.jsx`)
- Question interface → App orchestration: submits questions (evidence: `frontend/src/App.jsx`)
- Document list → App orchestration: requests actions (evidence: `frontend/src/App.jsx`)
- API client → FastAPI application: sends HTTP requests (evidence: `README.md`)
- FastAPI application → API routes: mounts routes (evidence: `backend/app/main.py`)
- API routes → Request schemas: validates payloads (evidence: `backend/app/routes.py`)
- API routes → PDF ingestion: indexes uploads (evidence: `backend/app/routes.py`)
- PDF ingestion → ChromaDB vectors: stores embeddings (evidence: `backend/app/services/indexing.py`)
- API routes → Search and citations: runs search and Q&A (evidence: `backend/app/routes.py`)
- Search and citations → ChromaDB vectors: searches vectors (evidence: `README.md`)
- Search and citations → Memory and cache: checks and records (evidence: `backend/app/services/retrieval.py`)
- Search and citations → OpenAI models: generates answers (evidence: `backend/app/services/retrieval.py`)
- Memory and cache → Mem0 memory service: reads and stores memories (evidence: `backend/app/services/memory.py`)
- API routes → Memory and cache: clears user data (evidence: `backend/app/routes.py`)
- Runtime settings → PDF ingestion: sets limits and store (evidence: `backend/app/services/indexing.py`)
- Runtime settings → Search and citations: sets model and store (evidence: `backend/app/services/retrieval.py`)
