# satish-shrestha-4u/generative-ai-ml-rag-scikitlearn-mentor architecture

> Architecture diagram of the GitHub repository satish-shrestha-4u/generative-ai-ml-rag-scikitlearn-mentor, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/satish-shrestha-4u/generative-ai-ml-rag-scikitlearn-mentor
- Repository: https://github.com/satish-shrestha-4u/generative-ai-ml-rag-scikitlearn-mentor

## Overview

ML Mentor is a Streamlit RAG chatbot for learning machine learning and scikit-learn. Users submit questions through the chat UI; the chat engine retrieves and reranks knowledge-base passages, then uses a Groq model to produce an answer and retrieved-source information for display. The engine builds or loads a persistent vector index from the local Markdown knowledge base and uses Hugging Face embeddings. The README documents explanations, examples, quizzes, and exam-style practice. Internal indexing stages are shown from the engine excerpt; storage is created at runtime. Connections to external model services follow the implementation’s configured providers.

Main entry points: [`src/engine.py`](https://github.com/satish-shrestha-4u/generative-ai-ml-rag-scikitlearn-mentor/blob/main/src/engine.py) (RAG chat engine), [`streamlit_app.py`](https://github.com/satish-shrestha-4u/generative-ai-ml-rag-scikitlearn-mentor/blob/main/streamlit_app.py) (Streamlit chat UI), [`src/model_loader.py`](https://github.com/satish-shrestha-4u/generative-ai-ml-rag-scikitlearn-mentor/blob/main/src/model_loader.py) (Model initialization), [`src/config.py`](https://github.com/satish-shrestha-4u/generative-ai-ml-rag-scikitlearn-mentor/blob/main/src/config.py) (Runtime configuration)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["Chat interface"]
  node_streamlit_ui["Streamlit chat UI<br/>[streamlit_app.py]"]
end

subgraph group_knowledge["Knowledge and retrieval"]
  node_knowledge_base["ML knowledge base"]
  node_ingestion["Document ingestion<br/>[engine.py]"]
  node_chunking_indexing["Chunking and indexing<br/>[engine.py]"]
  node_vector_store[("Persistent vector index<br/>[engine.py]")]
  node_retrieval["Passage retrieval<br/>[engine.py]"]
  node_reranking["Passage reranking<br/>[engine.py]"]
end

subgraph group_conversation["Conversation runtime"]
  node_chat_engine["RAG chat engine<br/>[engine.py]"]
  node_chat_memory["Chat memory<br/>[engine.py]"]
end

subgraph group_models["Model integrations"]
  node_configuration["Runtime configuration<br/>[config.py]"]
  node_model_loader["Model initialization<br/>[model_loader.py]"]
  node_groq{{"Groq LLM"}}
  node_embedding_model{{"Hugging Face embeddings"}}
  node_reranker_model{{"Cross-encoder reranker"}}
end

node_learner(("Learner"))

node_learner -->|"asks question"| node_streamlit_ui
node_streamlit_ui -->|"initializes models"| node_model_loader
node_streamlit_ui -->|"submits question"| node_chat_engine
node_streamlit_ui -->|"displays answer and sources"| node_streamlit_ui
node_model_loader -->|"reads settings"| node_configuration
node_model_loader -->|"initializes"| node_groq
node_model_loader -->|"initializes"| node_embedding_model
node_chat_engine -->|"reads settings"| node_configuration
node_chat_engine -->|"loads or builds"| node_vector_store
node_ingestion -->|"reads documents"| node_knowledge_base
node_ingestion -->|"passes documents"| node_chunking_indexing
node_chunking_indexing -->|"embeds chunks"| node_embedding_model
node_chunking_indexing -->|"persists index"| node_vector_store
node_vector_store -->|"provides retriever"| node_retrieval
node_chat_engine -->|"retrieves passages"| node_retrieval
node_chat_engine -->|"reranks passages"| node_reranking
node_reranking -->|"uses model"| node_reranker_model
node_chat_engine -->|"uses memory"| node_chat_memory
node_chat_engine -->|"generates response"| node_groq

click node_streamlit_ui "https://github.com/satish-shrestha-4u/generative-ai-ml-rag-scikitlearn-mentor/blob/main/streamlit_app.py"
click node_knowledge_base "https://github.com/satish-shrestha-4u/generative-ai-ml-rag-scikitlearn-mentor/tree/main/data/ml_mentor_knowledge_base"
click node_ingestion "https://github.com/satish-shrestha-4u/generative-ai-ml-rag-scikitlearn-mentor/blob/main/src/engine.py"
click node_chunking_indexing "https://github.com/satish-shrestha-4u/generative-ai-ml-rag-scikitlearn-mentor/blob/main/src/engine.py"
click node_vector_store "https://github.com/satish-shrestha-4u/generative-ai-ml-rag-scikitlearn-mentor/blob/main/src/engine.py"
click node_retrieval "https://github.com/satish-shrestha-4u/generative-ai-ml-rag-scikitlearn-mentor/blob/main/src/engine.py"
click node_reranking "https://github.com/satish-shrestha-4u/generative-ai-ml-rag-scikitlearn-mentor/blob/main/src/engine.py"
click node_chat_engine "https://github.com/satish-shrestha-4u/generative-ai-ml-rag-scikitlearn-mentor/blob/main/src/engine.py"
click node_chat_memory "https://github.com/satish-shrestha-4u/generative-ai-ml-rag-scikitlearn-mentor/blob/main/src/engine.py"
click node_configuration "https://github.com/satish-shrestha-4u/generative-ai-ml-rag-scikitlearn-mentor/blob/main/src/config.py"
click node_model_loader "https://github.com/satish-shrestha-4u/generative-ai-ml-rag-scikitlearn-mentor/blob/main/src/model_loader.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_streamlit_ui toneBlue
class node_knowledge_base,node_ingestion,node_chunking_indexing,node_vector_store,node_retrieval,node_reranking toneAmber
class node_chat_engine,node_chat_memory toneMint
class node_configuration,node_model_loader,node_groq,node_embedding_model,node_reranker_model toneRose
class node_learner toneIndigo
```

## Components

### Chat interface

- [Streamlit chat UI](https://github.com/satish-shrestha-4u/generative-ai-ml-rag-scikitlearn-mentor/blob/main/streamlit_app.py): `streamlit_app.py`

### Knowledge and retrieval

- [ML knowledge base](https://github.com/satish-shrestha-4u/generative-ai-ml-rag-scikitlearn-mentor/tree/main/data/ml_mentor_knowledge_base): `data/ml_mentor_knowledge_base`
- [Document ingestion](https://github.com/satish-shrestha-4u/generative-ai-ml-rag-scikitlearn-mentor/blob/main/src/engine.py): `src/engine.py`
- [Chunking and indexing](https://github.com/satish-shrestha-4u/generative-ai-ml-rag-scikitlearn-mentor/blob/main/src/engine.py): `src/engine.py`
- [Persistent vector index](https://github.com/satish-shrestha-4u/generative-ai-ml-rag-scikitlearn-mentor/blob/main/src/engine.py): `src/engine.py`
- [Passage retrieval](https://github.com/satish-shrestha-4u/generative-ai-ml-rag-scikitlearn-mentor/blob/main/src/engine.py): `src/engine.py`
- [Passage reranking](https://github.com/satish-shrestha-4u/generative-ai-ml-rag-scikitlearn-mentor/blob/main/src/engine.py): `src/engine.py`

### Conversation runtime

- [RAG chat engine](https://github.com/satish-shrestha-4u/generative-ai-ml-rag-scikitlearn-mentor/blob/main/src/engine.py): `src/engine.py`
- [Chat memory](https://github.com/satish-shrestha-4u/generative-ai-ml-rag-scikitlearn-mentor/blob/main/src/engine.py): `src/engine.py`

### Model integrations

- [Runtime configuration](https://github.com/satish-shrestha-4u/generative-ai-ml-rag-scikitlearn-mentor/blob/main/src/config.py): `src/config.py`
- [Model initialization](https://github.com/satish-shrestha-4u/generative-ai-ml-rag-scikitlearn-mentor/blob/main/src/model_loader.py): `src/model_loader.py`
- **Groq LLM**
- **Hugging Face embeddings**
- **Cross-encoder reranker**

### Other components

- **Learner**

## Connections

- Learner → Streamlit chat UI: asks question (evidence: `streamlit_app.py`)
- Streamlit chat UI → Model initialization: initializes models (evidence: `streamlit_app.py`)
- Streamlit chat UI → RAG chat engine: submits question (evidence: `streamlit_app.py`)
- Streamlit chat UI → Streamlit chat UI: displays answer and sources (evidence: `streamlit_app.py`)
- Model initialization → Runtime configuration: reads settings (evidence: `src/model_loader.py`)
- Model initialization → Groq LLM: initializes (evidence: `src/model_loader.py`)
- Model initialization → Hugging Face embeddings: initializes (evidence: `src/model_loader.py`)
- RAG chat engine → Runtime configuration: reads settings (evidence: `src/engine.py`)
- RAG chat engine → Persistent vector index: loads or builds (evidence: `src/engine.py`)
- Document ingestion → ML knowledge base: reads documents (evidence: `src/engine.py`)
- Document ingestion → Chunking and indexing: passes documents (evidence: `src/engine.py`)
- Chunking and indexing → Hugging Face embeddings: embeds chunks (evidence: `src/engine.py`)
- Chunking and indexing → Persistent vector index: persists index (evidence: `src/engine.py`)
- Persistent vector index → Passage retrieval: provides retriever (evidence: `src/engine.py`)
- RAG chat engine → Passage retrieval: retrieves passages (evidence: `src/engine.py`)
- RAG chat engine → Passage reranking: reranks passages (evidence: `src/engine.py`)
- Passage reranking → Cross-encoder reranker: uses model (evidence: `src/engine.py`)
- RAG chat engine → Chat memory: uses memory (evidence: `src/engine.py`)
- RAG chat engine → Groq LLM: generates response (evidence: `src/engine.py`)
