# abdelhafid-cloud/knovera architecture

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

- Interactive diagram: https://gitdiagram.com/abdelhafid-cloud/knovera
- Repository: https://github.com/abdelhafid-cloud/knovera

## Overview

Knovera is a multi-organization RAG platform: users access assigned assistants, ask questions, and receive answers grounded in organization knowledge bases. Administrators manage organizations, members, assistants, documents, and platform settings. Document indexing is asynchronous: the API queues uploads for a separate worker, which extracts and chunks content, creates embeddings, and indexes them for retrieval. The README documents the main service boundaries; sampled backend code confirms chat-to-RAG and document-storage behavior. Some worker and UI connections are shown only at the documented architectural level.

Main entry points: [`pipeline/app/process.py`](https://github.com/abdelhafid-cloud/knovera/blob/prod/pipeline/app/process.py) (Indexing worker), [`backend/app/routes`](https://github.com/abdelhafid-cloud/knovera/tree/prod/backend/app/routes) (Flask API), [`backend/app/services/chat/service.py`](https://github.com/abdelhafid-cloud/knovera/blob/prod/backend/app/services/chat/service.py) (Chat orchestration), [`backend/app/services/documents/service.py`](https://github.com/abdelhafid-cloud/knovera/blob/prod/backend/app/services/documents/service.py) (Document management)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["User experience"]
  node_frontend["Next.js interface"]
  node_chat_ui["Assistant chat<br/>[page.tsx]"]
  node_admin_ui["Admin workspaces"]
end

subgraph group_management["Identity and management"]
  node_api["Flask API"]
  node_auth["Authentication<br/>[service.py]"]
  node_tenant_access["Tenant access control<br/>[security.py]"]
  node_org_management["Organizations and roles<br/>[service.py]"]
  node_document_service["Document management<br/>[service.py]"]
end

subgraph group_rag["Chat and retrieval"]
  node_chat_service["Chat orchestration<br/>[service.py]"]
  node_embeddings["Query embeddings<br/>[embeddings.py]"]
  node_vectorstore["Vector retrieval<br/>[vectorstore.py]"]
  node_rerank["Result reranking<br/>[rerank.py]"]
  node_llm["Answer generation<br/>[llm.py]"]
end

subgraph group_indexing["Document indexing"]
  node_worker["Indexing worker<br/>[process.py]"]
  node_extract["Text extraction and OCR<br/>[parsers.py]"]
  node_chunking["Text chunking<br/>[chunking.py]"]
  node_index_embeddings["Document embeddings<br/>[embeddings.py]"]
end

subgraph group_services["Infrastructure"]
  node_queue["Redis job queue"]
  node_postgres[("PostgreSQL")]
  node_minio[("MinIO object storage")]
  node_qdrant[("Qdrant vector store")]
  node_cohere["Cohere"]
  node_llm_provider["LLM provider"]
  node_mistral["Mistral OCR"]
end

node_user(("User"))

node_user -->|"uses"| node_frontend
node_frontend -->|"calls API"| node_api
node_user -->|"asks question"| node_chat_ui
node_chat_ui -.->|"submits chat"| node_chat_service
node_admin_ui -->|"manages platform"| node_api
node_api -.->|"handles identity"| node_auth
node_api -.->|"checks access"| node_tenant_access
node_api -.->|"manages organizations"| node_org_management
node_api -.->|"manages documents"| node_document_service
node_chat_service -->|"embeds query"| node_embeddings
node_chat_service -->|"searches chunks"| node_vectorstore
node_chat_service -->|"reranks results"| node_rerank
node_chat_service -->|"generates answer"| node_llm
node_document_service -->|"stores uploads"| node_minio
node_document_service -->|"enqueues indexing"| node_queue
node_queue -->|"dispatches jobs"| node_worker
node_worker -->|"downloads documents"| node_minio
node_worker -->|"extracts text"| node_extract
node_extract -.->|"optional OCR"| node_mistral
node_worker -->|"chunks text"| node_chunking
node_worker -->|"creates embeddings"| node_index_embeddings
node_index_embeddings -->|"uses embeddings"| node_cohere
node_worker -->|"writes vectors"| node_qdrant
node_vectorstore -.->|"queries vectors"| node_qdrant
node_llm -.->|"requests generation"| node_llm_provider
node_api -->|"stores business data"| node_postgres
node_worker -.->|"updates indexing state"| node_postgres

click node_frontend "https://github.com/abdelhafid-cloud/knovera/tree/prod/frontend/app"
click node_chat_ui "https://github.com/abdelhafid-cloud/knovera/blob/prod/frontend/app/chat/%5BassistantId%5D/page.tsx"
click node_admin_ui "https://github.com/abdelhafid-cloud/knovera/tree/prod/frontend/app/(dashboard)"
click node_api "https://github.com/abdelhafid-cloud/knovera/tree/prod/backend/app/routes"
click node_auth "https://github.com/abdelhafid-cloud/knovera/blob/prod/backend/app/services/auth/service.py"
click node_tenant_access "https://github.com/abdelhafid-cloud/knovera/blob/prod/backend/app/utils/security.py"
click node_org_management "https://github.com/abdelhafid-cloud/knovera/blob/prod/backend/app/services/organizations/service.py"
click node_document_service "https://github.com/abdelhafid-cloud/knovera/blob/prod/backend/app/services/documents/service.py"
click node_chat_service "https://github.com/abdelhafid-cloud/knovera/blob/prod/backend/app/services/chat/service.py"
click node_embeddings "https://github.com/abdelhafid-cloud/knovera/blob/prod/backend/app/services/rag/embeddings.py"
click node_vectorstore "https://github.com/abdelhafid-cloud/knovera/blob/prod/backend/app/services/rag/vectorstore.py"
click node_rerank "https://github.com/abdelhafid-cloud/knovera/blob/prod/backend/app/services/rag/rerank.py"
click node_llm "https://github.com/abdelhafid-cloud/knovera/blob/prod/backend/app/services/rag/llm.py"
click node_worker "https://github.com/abdelhafid-cloud/knovera/blob/prod/pipeline/app/process.py"
click node_extract "https://github.com/abdelhafid-cloud/knovera/blob/prod/pipeline/app/extract/parsers.py"
click node_chunking "https://github.com/abdelhafid-cloud/knovera/blob/prod/pipeline/app/chunking.py"
click node_index_embeddings "https://github.com/abdelhafid-cloud/knovera/blob/prod/pipeline/app/embeddings.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_frontend,node_chat_ui,node_admin_ui,node_user toneBlue
class node_api,node_auth,node_tenant_access,node_org_management,node_document_service toneAmber
class node_chat_service,node_embeddings,node_vectorstore,node_rerank,node_llm toneMint
class node_worker,node_extract,node_chunking,node_index_embeddings toneRose
class node_queue,node_postgres,node_minio,node_qdrant,node_cohere,node_llm_provider,node_mistral toneIndigo
```

## Components

### User experience

- [Next.js interface](https://github.com/abdelhafid-cloud/knovera/tree/prod/frontend/app): `frontend/app`
- [Assistant chat](https://github.com/abdelhafid-cloud/knovera/blob/prod/frontend/app/chat/%5BassistantId%5D/page.tsx): `frontend/app/chat/[assistantId]/page.tsx`
- [Admin workspaces](https://github.com/abdelhafid-cloud/knovera/tree/prod/frontend/app/(dashboard)): `frontend/app/(dashboard)`

### Identity and management

- [Flask API](https://github.com/abdelhafid-cloud/knovera/tree/prod/backend/app/routes): `backend/app/routes`
- [Authentication](https://github.com/abdelhafid-cloud/knovera/blob/prod/backend/app/services/auth/service.py): `backend/app/services/auth/service.py`
- [Tenant access control](https://github.com/abdelhafid-cloud/knovera/blob/prod/backend/app/utils/security.py): `backend/app/utils/security.py`
- [Organizations and roles](https://github.com/abdelhafid-cloud/knovera/blob/prod/backend/app/services/organizations/service.py): `backend/app/services/organizations/service.py`
- [Document management](https://github.com/abdelhafid-cloud/knovera/blob/prod/backend/app/services/documents/service.py): `backend/app/services/documents/service.py`

### Chat and retrieval

- [Chat orchestration](https://github.com/abdelhafid-cloud/knovera/blob/prod/backend/app/services/chat/service.py): `backend/app/services/chat/service.py`
- [Query embeddings](https://github.com/abdelhafid-cloud/knovera/blob/prod/backend/app/services/rag/embeddings.py): `backend/app/services/rag/embeddings.py`
- [Vector retrieval](https://github.com/abdelhafid-cloud/knovera/blob/prod/backend/app/services/rag/vectorstore.py): `backend/app/services/rag/vectorstore.py`
- [Result reranking](https://github.com/abdelhafid-cloud/knovera/blob/prod/backend/app/services/rag/rerank.py): `backend/app/services/rag/rerank.py`
- [Answer generation](https://github.com/abdelhafid-cloud/knovera/blob/prod/backend/app/services/rag/llm.py): `backend/app/services/rag/llm.py`

### Document indexing

- [Indexing worker](https://github.com/abdelhafid-cloud/knovera/blob/prod/pipeline/app/process.py): `pipeline/app/process.py`
- [Text extraction and OCR](https://github.com/abdelhafid-cloud/knovera/blob/prod/pipeline/app/extract/parsers.py): `pipeline/app/extract/parsers.py`
- [Text chunking](https://github.com/abdelhafid-cloud/knovera/blob/prod/pipeline/app/chunking.py): `pipeline/app/chunking.py`
- [Document embeddings](https://github.com/abdelhafid-cloud/knovera/blob/prod/pipeline/app/embeddings.py): `pipeline/app/embeddings.py`

### Infrastructure

- **Redis job queue**
- **PostgreSQL**
- **MinIO object storage**
- **Qdrant vector store**
- **Cohere**
- **LLM provider**
- **Mistral OCR**

### Other components

- **User**

## Connections

- User → Next.js interface: uses
- Next.js interface → Flask API: calls API
- User → Assistant chat: asks question
- Assistant chat → Chat orchestration: submits chat
- Admin workspaces → Flask API: manages platform
- Flask API → Authentication: handles identity
- Flask API → Tenant access control: checks access
- Flask API → Organizations and roles: manages organizations
- Flask API → Document management: manages documents
- Chat orchestration → Query embeddings: embeds query (evidence: `backend/app/services/chat/service.py`)
- Chat orchestration → Vector retrieval: searches chunks (evidence: `backend/app/services/chat/service.py`)
- Chat orchestration → Result reranking: reranks results (evidence: `backend/app/services/chat/service.py`)
- Chat orchestration → Answer generation: generates answer (evidence: `backend/app/services/chat/service.py`)
- Document management → MinIO object storage: stores uploads (evidence: `backend/app/services/documents/service.py`)
- Document management → Redis job queue: enqueues indexing
- Redis job queue → Indexing worker: dispatches jobs
- Indexing worker → MinIO object storage: downloads documents
- Indexing worker → Text extraction and OCR: extracts text
- Text extraction and OCR → Mistral OCR: optional OCR
- Indexing worker → Text chunking: chunks text
- Indexing worker → Document embeddings: creates embeddings
- Document embeddings → Cohere: uses embeddings
- Indexing worker → Qdrant vector store: writes vectors
- Vector retrieval → Qdrant vector store: queries vectors
- Answer generation → LLM provider: requests generation
- Flask API → PostgreSQL: stores business data
- Indexing worker → PostgreSQL: updates indexing state
