# vickyy234/knowledgeflow_ai architecture

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

- Interactive diagram: https://gitdiagram.com/vickyy234/knowledgeflow_ai
- Repository: https://github.com/vickyy234/knowledgeflow_ai

## Overview

KnowledgeFlow AI is a Streamlit RAG application. Users register or log in, upload supported documents, build a per-user knowledge base, then ask questions and receive generated answers with source citations. Index construction extracts and chunks document text, embeds it, and persists both chunk data and a FAISS index; question handling retrieves chunks before generating an answer. The README documents the broader workflow and capabilities; links involving unsampled application wiring are omitted where source evidence does not establish the caller.

Main entry points: [`build_index.py`](https://github.com/vickyy234/knowledgeflow_ai/blob/main/build_index.py) (Index Builder), [`ui/dashboard.py`](https://github.com/vickyy234/knowledgeflow_ai/blob/main/ui/dashboard.py) (Dashboard), [`core/document_loader.py`](https://github.com/vickyy234/knowledgeflow_ai/blob/main/core/document_loader.py) (Document Loading), [`core/storage_manager.py`](https://github.com/vickyy234/knowledgeflow_ai/blob/main/core/storage_manager.py) (Per-user Storage)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_access["Accounts"]
  node_auth["Authentication<br/>[auth.py]"]
  node_passwords["Password Security<br/>[security.py]"]
  node_user_db[("User Database<br/>[database.py]")]
end

subgraph group_ingestion["Document Ingestion"]
  node_file_manager["Upload Storage<br/>[file_manager.py]"]
  node_document_loader["Document Loading<br/>[document_loader.py]"]
  node_pdf_loader["PDF Loader<br/>[pdf_loader.py]"]
  node_docx_loader["DOCX Loader<br/>[docx_loader.py]"]
  node_txt_loader["TXT Loader<br/>[txt_loader.py]"]
  node_md_loader["Markdown Loader<br/>[md_loader.py]"]
  node_splitter["Text Chunking<br/>[text_splitter.py]"]
end

subgraph group_knowledge["Knowledge and Retrieval"]
  node_storage["Per-user Storage<br/>[storage_manager.py]"]
  node_index_builder["Index Builder<br/>[build_index.py]"]
  node_embeddings["Embedding Adapter<br/>[embeddings.py]"]
  node_gemini["Gemini Models<br/>[gemini_models.py]"]
  node_knowledge_loader["Knowledge Loading"]
  node_retriever["Chunk Retrieval<br/>[retriever.py]"]
  node_faiss[("FAISS Index")]
  node_rag["Answer and Citations<br/>[rag.py]"]
end

subgraph group_interface["Streamlit Interface"]
  node_login_ui["Login UI<br/>[login.py]"]
  node_register_ui["Registration UI<br/>[register.py]"]
  node_navigation["Session Navigation<br/>[navigation.py]"]
  node_dashboard["Dashboard<br/>[dashboard.py]"]
end

node_user(("User"))
node_supabase[("Supabase PostgreSQL")]

node_user -->|"signs in"| node_login_ui
node_user -->|"registers"| node_register_ui
node_auth -->|"hashes and verifies"| node_passwords
node_auth -->|"creates and looks up"| node_user_db
node_user_db -->|"queries"| node_supabase
node_auth -->|"creates user storage"| node_storage
node_user -->|"uploads and asks"| node_dashboard
node_dashboard -->|"logs out through"| node_navigation
node_dashboard -->|"saves uploads"| node_file_manager
node_file_manager -->|"gets document path"| node_storage
node_dashboard -->|"builds knowledge base"| node_index_builder
node_index_builder -->|"gets paths"| node_storage
node_index_builder -->|"loads documents"| node_document_loader
node_document_loader -->|"dispatches PDF"| node_pdf_loader
node_document_loader -->|"dispatches DOCX"| node_docx_loader
node_document_loader -->|"dispatches TXT"| node_txt_loader
node_document_loader -->|"dispatches Markdown"| node_md_loader
node_index_builder -->|"splits documents"| node_splitter
node_index_builder -->|"embeds chunks"| node_embeddings
node_embeddings -->|"requests embeddings"| node_gemini
node_index_builder -->|"creates and writes index"| node_faiss
node_index_builder -->|"persists knowledge data"| node_storage
node_dashboard -->|"loads saved knowledge"| node_knowledge_loader
node_knowledge_loader -->|"gets stored paths"| node_storage
node_dashboard -->|"retrieves chunks"| node_retriever
node_retriever -->|"embeds question"| node_embeddings
node_retriever -->|"searches index"| node_faiss
node_dashboard -->|"generates response"| node_rag
node_rag -->|"requests text output"| node_gemini

click node_login_ui "https://github.com/vickyy234/knowledgeflow_ai/blob/main/ui/login.py"
click node_register_ui "https://github.com/vickyy234/knowledgeflow_ai/blob/main/ui/register.py"
click node_auth "https://github.com/vickyy234/knowledgeflow_ai/blob/main/auth/auth.py"
click node_passwords "https://github.com/vickyy234/knowledgeflow_ai/blob/main/auth/security.py"
click node_user_db "https://github.com/vickyy234/knowledgeflow_ai/blob/main/database/database.py"
click node_navigation "https://github.com/vickyy234/knowledgeflow_ai/blob/main/ui/navigation.py"
click node_dashboard "https://github.com/vickyy234/knowledgeflow_ai/blob/main/ui/dashboard.py"
click node_file_manager "https://github.com/vickyy234/knowledgeflow_ai/blob/main/core/file_manager.py"
click node_storage "https://github.com/vickyy234/knowledgeflow_ai/blob/main/core/storage_manager.py"
click node_index_builder "https://github.com/vickyy234/knowledgeflow_ai/blob/main/build_index.py"
click node_document_loader "https://github.com/vickyy234/knowledgeflow_ai/blob/main/core/document_loader.py"
click node_pdf_loader "https://github.com/vickyy234/knowledgeflow_ai/blob/main/core/loaders/pdf_loader.py"
click node_docx_loader "https://github.com/vickyy234/knowledgeflow_ai/blob/main/core/loaders/docx_loader.py"
click node_txt_loader "https://github.com/vickyy234/knowledgeflow_ai/blob/main/core/loaders/txt_loader.py"
click node_md_loader "https://github.com/vickyy234/knowledgeflow_ai/blob/main/core/loaders/md_loader.py"
click node_splitter "https://github.com/vickyy234/knowledgeflow_ai/blob/main/core/text_splitter.py"
click node_embeddings "https://github.com/vickyy234/knowledgeflow_ai/blob/main/core/embeddings.py"
click node_gemini "https://github.com/vickyy234/knowledgeflow_ai/blob/main/utils/genai/gemini_models.py"
click node_knowledge_loader "https://github.com/vickyy234/knowledgeflow_ai/blob/main/core/knowledge_loader.py"
click node_retriever "https://github.com/vickyy234/knowledgeflow_ai/blob/main/core/retriever.py"
click node_rag "https://github.com/vickyy234/knowledgeflow_ai/blob/main/core/rag.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_auth,node_passwords,node_user_db,node_user toneBlue
class node_file_manager,node_document_loader,node_pdf_loader,node_docx_loader,node_txt_loader,node_md_loader,node_splitter,node_supabase toneAmber
class node_storage,node_index_builder,node_embeddings,node_gemini,node_knowledge_loader,node_retriever,node_faiss,node_rag toneMint
class node_login_ui,node_register_ui,node_navigation,node_dashboard toneRose
```

## Components

### Accounts

- [Authentication](https://github.com/vickyy234/knowledgeflow_ai/blob/main/auth/auth.py): `auth/auth.py`
- [Password Security](https://github.com/vickyy234/knowledgeflow_ai/blob/main/auth/security.py): `auth/security.py`
- [User Database](https://github.com/vickyy234/knowledgeflow_ai/blob/main/database/database.py): `database/database.py`

### Document Ingestion

- [Upload Storage](https://github.com/vickyy234/knowledgeflow_ai/blob/main/core/file_manager.py): `core/file_manager.py`
- [Document Loading](https://github.com/vickyy234/knowledgeflow_ai/blob/main/core/document_loader.py): `core/document_loader.py`
- [PDF Loader](https://github.com/vickyy234/knowledgeflow_ai/blob/main/core/loaders/pdf_loader.py): `core/loaders/pdf_loader.py`
- [DOCX Loader](https://github.com/vickyy234/knowledgeflow_ai/blob/main/core/loaders/docx_loader.py): `core/loaders/docx_loader.py`
- [TXT Loader](https://github.com/vickyy234/knowledgeflow_ai/blob/main/core/loaders/txt_loader.py): `core/loaders/txt_loader.py`
- [Markdown Loader](https://github.com/vickyy234/knowledgeflow_ai/blob/main/core/loaders/md_loader.py): `core/loaders/md_loader.py`
- [Text Chunking](https://github.com/vickyy234/knowledgeflow_ai/blob/main/core/text_splitter.py): `core/text_splitter.py`

### Knowledge and Retrieval

- [Per-user Storage](https://github.com/vickyy234/knowledgeflow_ai/blob/main/core/storage_manager.py): `core/storage_manager.py`
- [Index Builder](https://github.com/vickyy234/knowledgeflow_ai/blob/main/build_index.py): `build_index.py`
- [Embedding Adapter](https://github.com/vickyy234/knowledgeflow_ai/blob/main/core/embeddings.py): `core/embeddings.py`
- [Gemini Models](https://github.com/vickyy234/knowledgeflow_ai/blob/main/utils/genai/gemini_models.py): `utils/genai/gemini_models.py`
- [Knowledge Loading](https://github.com/vickyy234/knowledgeflow_ai/blob/main/core/knowledge_loader.py): `core/knowledge_loader.py`
- [Chunk Retrieval](https://github.com/vickyy234/knowledgeflow_ai/blob/main/core/retriever.py): `core/retriever.py`
- **FAISS Index**
- [Answer and Citations](https://github.com/vickyy234/knowledgeflow_ai/blob/main/core/rag.py): `core/rag.py`

### Streamlit Interface

- [Login UI](https://github.com/vickyy234/knowledgeflow_ai/blob/main/ui/login.py): `ui/login.py`
- [Registration UI](https://github.com/vickyy234/knowledgeflow_ai/blob/main/ui/register.py): `ui/register.py`
- [Session Navigation](https://github.com/vickyy234/knowledgeflow_ai/blob/main/ui/navigation.py): `ui/navigation.py`
- [Dashboard](https://github.com/vickyy234/knowledgeflow_ai/blob/main/ui/dashboard.py): `ui/dashboard.py`

### Other components

- **User**
- **Supabase PostgreSQL**

## Connections

- User → Login UI: signs in (evidence: `README.md`)
- User → Registration UI: registers (evidence: `README.md`)
- Authentication → Password Security: hashes and verifies (evidence: `auth/auth.py`)
- Authentication → User Database: creates and looks up (evidence: `auth/auth.py`)
- User Database → Supabase PostgreSQL: queries (evidence: `README.md`)
- Authentication → Per-user Storage: creates user storage (evidence: `auth/auth.py`)
- User → Dashboard: uploads and asks (evidence: `README.md`)
- Dashboard → Session Navigation: logs out through (evidence: `ui/dashboard.py`)
- Dashboard → Upload Storage: saves uploads (evidence: `ui/dashboard.py`)
- Upload Storage → Per-user Storage: gets document path (evidence: `core/file_manager.py`)
- Dashboard → Index Builder: builds knowledge base (evidence: `ui/dashboard.py`)
- Index Builder → Per-user Storage: gets paths (evidence: `build_index.py`)
- Index Builder → Document Loading: loads documents (evidence: `build_index.py`)
- Document Loading → PDF Loader: dispatches PDF (evidence: `core/document_loader.py`)
- Document Loading → DOCX Loader: dispatches DOCX (evidence: `core/document_loader.py`)
- Document Loading → TXT Loader: dispatches TXT (evidence: `core/document_loader.py`)
- Document Loading → Markdown Loader: dispatches Markdown (evidence: `core/document_loader.py`)
- Index Builder → Text Chunking: splits documents (evidence: `build_index.py`)
- Index Builder → Embedding Adapter: embeds chunks (evidence: `build_index.py`)
- Embedding Adapter → Gemini Models: requests embeddings (evidence: `core/embeddings.py`)
- Index Builder → FAISS Index: creates and writes index (evidence: `build_index.py`)
- Index Builder → Per-user Storage: persists knowledge data (evidence: `build_index.py`)
- Dashboard → Knowledge Loading: loads saved knowledge (evidence: `ui/dashboard.py`)
- Knowledge Loading → Per-user Storage: gets stored paths (evidence: `core/knowledge_loader.py`)
- Dashboard → Chunk Retrieval: retrieves chunks (evidence: `ui/dashboard.py`)
- Chunk Retrieval → Embedding Adapter: embeds question (evidence: `core/retriever.py`)
- Chunk Retrieval → FAISS Index: searches index
- Dashboard → Answer and Citations: generates response (evidence: `ui/dashboard.py`)
- Answer and Citations → Gemini Models: requests text output (evidence: `core/rag.py`)
