# jabbarabdul18/ai-rag-assistant architecture

> Architecture diagram of the GitHub repository jabbarabdul18/ai-rag-assistant, 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/jabbarabdul18/ai-rag-assistant
- Repository: https://github.com/jabbarabdul18/ai-rag-assistant

## Overview

This is a document-grounded RAG assistant: users upload documents, the application extracts and indexes their text, then answers questions with retrieved context and can stream responses. The README also advertises summarization and vector-database visualization; these are retained as application capabilities, though their implementation paths are not independently visible in the sampled excerpts. The tree and excerpts show both a Streamlit application and a separate browser script; their relationship is unclear, so that link is unverified.

Main entry points: [`backend/app.py`](https://github.com/jabbarabdul18/ai-rag-assistant/blob/main/backend/app.py) (Assistant app), [`backend/rag_engine.py`](https://github.com/jabbarabdul18/ai-rag-assistant/blob/main/backend/rag_engine.py) (Chunking and indexing), [`static/script.js`](https://github.com/jabbarabdul18/ai-rag-assistant/blob/main/static/script.js) (Browser client), [`backend/file_processor.py`](https://github.com/jabbarabdul18/ai-rag-assistant/blob/main/backend/file_processor.py) (Text extraction)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interaction["User interaction"]
  node_streamlit["Assistant app<br/>[app.py]"]
  node_webclient["Browser client<br/>[script.js]"]
  node_summary["Document summaries<br/>[app.py]"]
  node_visualization["Vector visualization<br/>[app.py]"]
end

subgraph group_ingestion["Document ingestion"]
  node_uploads["Uploaded files"]
  node_extractor["Text extraction<br/>[file_processor.py]"]
  node_cleaning["Text cleaning<br/>[file_processor.py]"]
end

subgraph group_rag["RAG and answers"]
  node_chunking["Chunking and indexing<br/>[rag_engine.py]"]
  node_vectors[("FAISS index<br/>[rag_engine.py]")]
  node_retrieval["Similarity retrieval<br/>[rag_engine.py]"]
  node_answering["Answer generation<br/>[rag_engine.py]"]
end

subgraph group_integrations["Models and services"]
  node_embedding["Text embeddings"]
  node_llm["OpenAI API"]
end

node_user(("User"))

node_user -->|"asks and uploads"| node_streamlit
node_user -->|"uses"| node_webclient
node_webclient -.->|"may call"| node_streamlit
node_streamlit -->|"extracts uploads"| node_extractor
node_extractor -->|"cleans text"| node_cleaning
node_streamlit -->|"adds documents"| node_chunking
node_chunking -->|"embeds chunks"| node_embedding
node_chunking -->|"stores chunks"| node_vectors
node_retrieval -->|"searches"| node_vectors
node_answering -->|"retrieves context"| node_retrieval
node_answering -->|"requests completion"| node_llm
node_streamlit -.->|"requests streamed answers"| node_answering
node_streamlit -.->|"offers summarization"| node_summary
node_streamlit -.->|"offers vector visualization"| node_visualization

click node_streamlit "https://github.com/jabbarabdul18/ai-rag-assistant/blob/main/backend/app.py"
click node_webclient "https://github.com/jabbarabdul18/ai-rag-assistant/blob/main/static/script.js"
click node_extractor "https://github.com/jabbarabdul18/ai-rag-assistant/blob/main/backend/file_processor.py"
click node_cleaning "https://github.com/jabbarabdul18/ai-rag-assistant/blob/main/backend/file_processor.py"
click node_chunking "https://github.com/jabbarabdul18/ai-rag-assistant/blob/main/backend/rag_engine.py"
click node_vectors "https://github.com/jabbarabdul18/ai-rag-assistant/blob/main/backend/rag_engine.py"
click node_retrieval "https://github.com/jabbarabdul18/ai-rag-assistant/blob/main/backend/rag_engine.py"
click node_answering "https://github.com/jabbarabdul18/ai-rag-assistant/blob/main/backend/rag_engine.py"
click node_summary "https://github.com/jabbarabdul18/ai-rag-assistant/blob/main/backend/app.py"
click node_visualization "https://github.com/jabbarabdul18/ai-rag-assistant/blob/main/backend/app.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,node_webclient,node_summary,node_visualization,node_user toneBlue
class node_uploads,node_extractor,node_cleaning toneAmber
class node_chunking,node_vectors,node_retrieval,node_answering toneMint
class node_embedding,node_llm toneRose
```

## Components

### User interaction

- [Assistant app](https://github.com/jabbarabdul18/ai-rag-assistant/blob/main/backend/app.py): `backend/app.py`
- [Browser client](https://github.com/jabbarabdul18/ai-rag-assistant/blob/main/static/script.js): `static/script.js`
- [Document summaries](https://github.com/jabbarabdul18/ai-rag-assistant/blob/main/backend/app.py): `backend/app.py`
- [Vector visualization](https://github.com/jabbarabdul18/ai-rag-assistant/blob/main/backend/app.py): `backend/app.py`

### Document ingestion

- **Uploaded files**
- [Text extraction](https://github.com/jabbarabdul18/ai-rag-assistant/blob/main/backend/file_processor.py): `backend/file_processor.py`
- [Text cleaning](https://github.com/jabbarabdul18/ai-rag-assistant/blob/main/backend/file_processor.py): `backend/file_processor.py`

### RAG and answers

- [Chunking and indexing](https://github.com/jabbarabdul18/ai-rag-assistant/blob/main/backend/rag_engine.py): `backend/rag_engine.py`
- [FAISS index](https://github.com/jabbarabdul18/ai-rag-assistant/blob/main/backend/rag_engine.py): `backend/rag_engine.py`
- [Similarity retrieval](https://github.com/jabbarabdul18/ai-rag-assistant/blob/main/backend/rag_engine.py): `backend/rag_engine.py`
- [Answer generation](https://github.com/jabbarabdul18/ai-rag-assistant/blob/main/backend/rag_engine.py): `backend/rag_engine.py`

### Models and services

- **Text embeddings**
- **OpenAI API**

### Other components

- **User**

## Connections

- User → Assistant app: asks and uploads (evidence: `README.md`)
- User → Browser client: uses (evidence: `static/script.js`)
- Browser client → Assistant app: may call
- Assistant app → Text extraction: extracts uploads (evidence: `backend/app.py`)
- Text extraction → Text cleaning: cleans text (evidence: `backend/file_processor.py`)
- Assistant app → Chunking and indexing: adds documents (evidence: `backend/app.py`)
- Chunking and indexing → Text embeddings: embeds chunks (evidence: `backend/rag_engine.py`)
- Chunking and indexing → FAISS index: stores chunks (evidence: `backend/rag_engine.py`)
- Similarity retrieval → FAISS index: searches (evidence: `backend/rag_engine.py`)
- Answer generation → Similarity retrieval: retrieves context (evidence: `backend/rag_engine.py`)
- Answer generation → OpenAI API: requests completion (evidence: `backend/rag_engine.py`)
- Assistant app → Answer generation: requests streamed answers (evidence: `backend/app.py`)
- Assistant app → Document summaries: offers summarization (evidence: `README.md`)
- Assistant app → Vector visualization: offers vector visualization (evidence: `README.md`)
