# sirius-248/ai-student-academic-mentor-rag architecture

> Architecture diagram of the GitHub repository sirius-248/ai-student-academic-mentor-rag, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sirius-248/ai-student-academic-mentor-rag
- Repository: https://github.com/sirius-248/ai-student-academic-mentor-rag

## Overview

This is an academic-mentoring RAG application exposed through a FastAPI API and an interactive CLI. Its main workflow indexes PDFs into a vector store, then retrieves relevant chunks to build a prompt, generate an answer, and return source references. The graph preserves both product entry points and the documented tutoring and PDF-processing capabilities. Pipeline orchestration and several service calls are visible in sampled source; API route internals and other unsampled implementations are represented only where the tree or documentation supports them.

Main entry points: [`app/pipeline/rag_pipeline.py`](https://github.com/sirius-248/ai-student-academic-mentor-rag/blob/master/app/pipeline/rag_pipeline.py) (RAG pipeline), [`app/api/main.py`](https://github.com/sirius-248/ai-student-academic-mentor-rag/blob/master/app/api/main.py) (FastAPI app), [`app/retriever/retriever.py`](https://github.com/sirius-248/ai-student-academic-mentor-rag/blob/master/app/retriever/retriever.py) (Semantic retriever), [`app/vector_store`](https://github.com/sirius-248/ai-student-academic-mentor-rag/tree/master/app/vector_store) (Vector store)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["User interfaces"]
  node_cli["Interactive CLI<br/>[main.py]"]
  node_api["FastAPI app<br/>[main.py]"]
  node_doc_routes["Document routes<br/>[documents.py]"]
  node_question_routes["Question routes<br/>[questions.py]"]
end

subgraph group_index["Document indexing"]
  node_reader["PDF reader<br/>[pdf_reader.py]"]
  node_cleaner["Text preprocessing<br/>[pipeline.py]"]
  node_chunker["Text chunker<br/>[text_chunker.py]"]
end

subgraph group_answer["Question answering"]
  node_pipeline["RAG pipeline<br/>[rag_pipeline.py]"]
  node_retriever["Semantic retriever<br/>[retriever.py]"]
  node_prompt_builder["Prompt builder<br/>[prompt_builder.py]"]
  node_llm["LLM clients"]
  node_response["Answer and citations<br/>[answer_response.py]"]
end

subgraph group_infra["Models and storage"]
  node_embedding_service["Embedding service"]
  node_embedder["Embedding providers"]
  node_vector_store[("Vector store")]
  node_chunk_model["Document chunks<br/>[document_chunk.py]"]
  node_registry[("Document registry<br/>[dependencies.py]")]
end

node_student(("Student"))
node_llm_provider(("LLM provider"))

node_student -->|"asks questions"| node_cli
node_student -->|"uses API"| node_api
node_cli -->|"indexes and asks"| node_pipeline
node_api -->|"dispatches"| node_doc_routes
node_api -->|"dispatches"| node_question_routes
node_api -->|"loads store"| node_vector_store
node_api -->|"recovers records"| node_registry
node_doc_routes -->|"indexes documents"| node_pipeline
node_question_routes -->|"asks questions"| node_pipeline
node_pipeline -->|"extracts text"| node_reader
node_pipeline -->|"cleans text"| node_cleaner
node_pipeline -->|"creates chunks"| node_chunker
node_pipeline -->|"embeds chunks"| node_embedding_service
node_pipeline -->|"adds and saves"| node_vector_store
node_pipeline -->|"retrieves context"| node_retriever
node_retriever -->|"embeds query"| node_embedding_service
node_retriever -->|"searches"| node_vector_store
node_embedding_service -->|"generates vectors"| node_embedder
node_vector_store -->|"stores chunks"| node_chunk_model
node_retriever -.-> node_prompt_builder
node_pipeline -->|"builds prompt"| node_prompt_builder
node_pipeline -->|"generates answer"| node_llm
node_llm -->|"requests generation"| node_llm_provider
node_pipeline -->|"returns answer and sources"| node_response

click node_cli "https://github.com/sirius-248/ai-student-academic-mentor-rag/blob/master/app/main.py"
click node_api "https://github.com/sirius-248/ai-student-academic-mentor-rag/blob/master/app/api/main.py"
click node_doc_routes "https://github.com/sirius-248/ai-student-academic-mentor-rag/blob/master/app/api/routes/documents.py"
click node_question_routes "https://github.com/sirius-248/ai-student-academic-mentor-rag/blob/master/app/api/routes/questions.py"
click node_pipeline "https://github.com/sirius-248/ai-student-academic-mentor-rag/blob/master/app/pipeline/rag_pipeline.py"
click node_reader "https://github.com/sirius-248/ai-student-academic-mentor-rag/blob/master/app/document_reader/pdf_reader.py"
click node_cleaner "https://github.com/sirius-248/ai-student-academic-mentor-rag/blob/master/app/preprocessing/pipeline.py"
click node_chunker "https://github.com/sirius-248/ai-student-academic-mentor-rag/blob/master/app/chunking/text_chunker.py"
click node_embedding_service "https://github.com/sirius-248/ai-student-academic-mentor-rag/blob/master/app/embeddings/embedding_service.py"
click node_embedder "https://github.com/sirius-248/ai-student-academic-mentor-rag/tree/master/app/embeddings"
click node_retriever "https://github.com/sirius-248/ai-student-academic-mentor-rag/blob/master/app/retriever/retriever.py"
click node_vector_store "https://github.com/sirius-248/ai-student-academic-mentor-rag/tree/master/app/vector_store"
click node_prompt_builder "https://github.com/sirius-248/ai-student-academic-mentor-rag/blob/master/app/prompt/prompt_builder.py"
click node_llm "https://github.com/sirius-248/ai-student-academic-mentor-rag/tree/master/app/llm"
click node_chunk_model "https://github.com/sirius-248/ai-student-academic-mentor-rag/blob/master/app/models/document_chunk.py"
click node_registry "https://github.com/sirius-248/ai-student-academic-mentor-rag/blob/master/app/api/dependencies.py"
click node_response "https://github.com/sirius-248/ai-student-academic-mentor-rag/blob/master/app/pipeline/answer_response.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_cli,node_api,node_doc_routes,node_question_routes toneBlue
class node_reader,node_cleaner,node_chunker toneAmber
class node_pipeline,node_retriever,node_prompt_builder,node_llm,node_response toneMint
class node_embedding_service,node_embedder,node_vector_store,node_chunk_model,node_registry toneRose
class node_student,node_llm_provider toneIndigo
```

## Components

### User interfaces

- [Interactive CLI](https://github.com/sirius-248/ai-student-academic-mentor-rag/blob/master/app/main.py): `app/main.py`
- [FastAPI app](https://github.com/sirius-248/ai-student-academic-mentor-rag/blob/master/app/api/main.py): `app/api/main.py`
- [Document routes](https://github.com/sirius-248/ai-student-academic-mentor-rag/blob/master/app/api/routes/documents.py): `app/api/routes/documents.py`
- [Question routes](https://github.com/sirius-248/ai-student-academic-mentor-rag/blob/master/app/api/routes/questions.py): `app/api/routes/questions.py`

### Document indexing

- [PDF reader](https://github.com/sirius-248/ai-student-academic-mentor-rag/blob/master/app/document_reader/pdf_reader.py): `app/document_reader/pdf_reader.py`
- [Text preprocessing](https://github.com/sirius-248/ai-student-academic-mentor-rag/blob/master/app/preprocessing/pipeline.py): `app/preprocessing/pipeline.py`
- [Text chunker](https://github.com/sirius-248/ai-student-academic-mentor-rag/blob/master/app/chunking/text_chunker.py): `app/chunking/text_chunker.py`

### Question answering

- [RAG pipeline](https://github.com/sirius-248/ai-student-academic-mentor-rag/blob/master/app/pipeline/rag_pipeline.py): `app/pipeline/rag_pipeline.py`
- [Semantic retriever](https://github.com/sirius-248/ai-student-academic-mentor-rag/blob/master/app/retriever/retriever.py): `app/retriever/retriever.py`
- [Prompt builder](https://github.com/sirius-248/ai-student-academic-mentor-rag/blob/master/app/prompt/prompt_builder.py): `app/prompt/prompt_builder.py`
- [LLM clients](https://github.com/sirius-248/ai-student-academic-mentor-rag/tree/master/app/llm): `app/llm`
- [Answer and citations](https://github.com/sirius-248/ai-student-academic-mentor-rag/blob/master/app/pipeline/answer_response.py): `app/pipeline/answer_response.py`

### Models and storage

- [Embedding service](https://github.com/sirius-248/ai-student-academic-mentor-rag/blob/master/app/embeddings/embedding_service.py): `app/embeddings/embedding_service.py`
- [Embedding providers](https://github.com/sirius-248/ai-student-academic-mentor-rag/tree/master/app/embeddings): `app/embeddings`
- [Vector store](https://github.com/sirius-248/ai-student-academic-mentor-rag/tree/master/app/vector_store): `app/vector_store`
- [Document chunks](https://github.com/sirius-248/ai-student-academic-mentor-rag/blob/master/app/models/document_chunk.py): `app/models/document_chunk.py`
- [Document registry](https://github.com/sirius-248/ai-student-academic-mentor-rag/blob/master/app/api/dependencies.py): `app/api/dependencies.py`

### Other components

- **Student**
- **LLM provider**

## Connections

- Student → Interactive CLI: asks questions
- Student → FastAPI app: uses API
- Interactive CLI → RAG pipeline: indexes and asks
- FastAPI app → Document routes: dispatches
- FastAPI app → Question routes: dispatches
- FastAPI app → Vector store: loads store
- FastAPI app → Document registry: recovers records
- Document routes → RAG pipeline: indexes documents
- Question routes → RAG pipeline: asks questions
- RAG pipeline → PDF reader: extracts text
- RAG pipeline → Text preprocessing: cleans text
- RAG pipeline → Text chunker: creates chunks
- RAG pipeline → Embedding service: embeds chunks
- RAG pipeline → Vector store: adds and saves
- RAG pipeline → Semantic retriever: retrieves context
- Semantic retriever → Embedding service: embeds query
- Semantic retriever → Vector store: searches
- Embedding service → Embedding providers: generates vectors
- Vector store → Document chunks: stores chunks
- Semantic retriever → Prompt builder
- RAG pipeline → Prompt builder: builds prompt
- RAG pipeline → LLM clients: generates answer
- LLM clients → LLM provider: requests generation
- RAG pipeline → Answer and citations: returns answer and sources
