# moseskakuno/ai-knowledge-assistant architecture

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

- Interactive diagram: https://gitdiagram.com/moseskakuno/ai-knowledge-assistant
- Repository: https://github.com/moseskakuno/ai-knowledge-assistant

## Overview

This is a Streamlit PDF knowledge assistant. Users upload PDFs, which the app deduplicates, extracts page text, chunks it, embeds it, and stores it; questions are embedded, searched against the stored passages, and answered with source references. The app also exposes document counts, duplicate detection, and deletion. The graph follows the relationships shown in the README and sampled source; no unsampled implementation details are assumed.

Main entry points: [`app.py`](https://github.com/moseskakuno/ai-knowledge-assistant/blob/main/app.py) (Streamlit app), [`rag_pipeline.py`](https://github.com/moseskakuno/ai-knowledge-assistant/blob/main/rag_pipeline.py) (RAG answerer), [`embedding_service.py`](https://github.com/moseskakuno/ai-knowledge-assistant/blob/main/embedding_service.py) (Embeddings), [`vector_store.py`](https://github.com/moseskakuno/ai-knowledge-assistant/blob/main/vector_store.py) (Vector store)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["User Interface"]
  node_app["Streamlit app<br/>[app.py]"]
end

subgraph group_ingestion["Document Ingestion"]
  node_pdf["PDF extraction"]
  node_chunker["Page chunking<br/>[text_chunker.py]"]
end

subgraph group_retrieval["Question Answering"]
  node_embeddings["Embeddings"]
  node_rag["RAG answerer<br/>[rag_pipeline.py]"]
end

subgraph group_storage["Knowledge Base"]
  node_store[("Vector store<br/>[vector_store.py]")]
end

node_user(("User"))
node_openai{{"OpenAI API"}}

node_user -->|"uploads, asks"| node_app
node_app -->|"extracts PDF"| node_pdf
node_app -->|"chunks pages"| node_chunker
node_app -->|"embeds chunks"| node_embeddings
node_app -->|"checks, stores"| node_store
node_app -->|"asks question"| node_rag
node_rag -->|"embeds question"| node_embeddings
node_rag -->|"searches chunks"| node_store
node_embeddings -->|"requests vectors"| node_openai
node_rag -->|"generates answer"| node_openai
node_store -->|"returns documents"| node_app
node_app -->|"shows sources"| node_user

click node_app "https://github.com/moseskakuno/ai-knowledge-assistant/blob/main/app.py"
click node_pdf "https://github.com/moseskakuno/ai-knowledge-assistant/blob/main/document_processor.py"
click node_chunker "https://github.com/moseskakuno/ai-knowledge-assistant/blob/main/text_chunker.py"
click node_embeddings "https://github.com/moseskakuno/ai-knowledge-assistant/blob/main/embedding_service.py"
click node_rag "https://github.com/moseskakuno/ai-knowledge-assistant/blob/main/rag_pipeline.py"
click node_store "https://github.com/moseskakuno/ai-knowledge-assistant/blob/main/vector_store.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_user toneBlue
class node_pdf,node_chunker toneAmber
class node_embeddings,node_rag,node_openai toneMint
class node_store toneRose
```

## Components

### User Interface

- [Streamlit app](https://github.com/moseskakuno/ai-knowledge-assistant/blob/main/app.py): `app.py`

### Document Ingestion

- [PDF extraction](https://github.com/moseskakuno/ai-knowledge-assistant/blob/main/document_processor.py): `document_processor.py`
- [Page chunking](https://github.com/moseskakuno/ai-knowledge-assistant/blob/main/text_chunker.py): `text_chunker.py`

### Question Answering

- [Embeddings](https://github.com/moseskakuno/ai-knowledge-assistant/blob/main/embedding_service.py): `embedding_service.py`
- [RAG answerer](https://github.com/moseskakuno/ai-knowledge-assistant/blob/main/rag_pipeline.py): `rag_pipeline.py`

### Knowledge Base

- [Vector store](https://github.com/moseskakuno/ai-knowledge-assistant/blob/main/vector_store.py): `vector_store.py`

### Other components

- **User**
- **OpenAI API**

## Connections

- User → Streamlit app: uploads, asks (evidence: `README.md`)
- Streamlit app → PDF extraction: extracts PDF (evidence: `app.py`)
- Streamlit app → Page chunking: chunks pages (evidence: `app.py`)
- Streamlit app → Embeddings: embeds chunks (evidence: `app.py`)
- Streamlit app → Vector store: checks, stores (evidence: `app.py`)
- Streamlit app → RAG answerer: asks question (evidence: `app.py`)
- RAG answerer → Embeddings: embeds question (evidence: `rag_pipeline.py`)
- RAG answerer → Vector store: searches chunks (evidence: `rag_pipeline.py`)
- Embeddings → OpenAI API: requests vectors (evidence: `embedding_service.py`)
- RAG answerer → OpenAI API: generates answer (evidence: `rag_pipeline.py`)
- Vector store → Streamlit app: returns documents (evidence: `app.py`)
- Streamlit app → User: shows sources (evidence: `app.py`)
