# rakno-27/enterprise-ai-knowledge-assistant architecture

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

- Interactive diagram: https://gitdiagram.com/rakno-27/enterprise-ai-knowledge-assistant
- Repository: https://github.com/rakno-27/enterprise-ai-knowledge-assistant

## Overview

Enterprise AI Assistant is a web application for chat with optional retrieval-augmented generation and document management. Users submit chat messages or upload documents through the frontend; the frontend API calls the backend, whose chat service coordinates RAG when enabled. The RAG service handles document ingestion and retrieval, including OCR, chunking, metadata, embeddings, hybrid search, and reranking. The tree and excerpts establish several service dependencies, but endpoint internals and most auxiliary service implementations were not sampled, so those relationships are marked unverified or omitted.

Main entry points: [`enterprise-ai-assistant/backend/app/services/rag_service.py`](https://github.com/rakno-27/enterprise-ai-knowledge-assistant/blob/main/enterprise-ai-assistant/backend/app/services/rag_service.py) (RAG and ingestion), [`enterprise-ai-assistant/frontend/src/App.tsx`](https://github.com/rakno-27/enterprise-ai-knowledge-assistant/blob/main/enterprise-ai-assistant/frontend/src/App.tsx) (Application shell), [`enterprise-ai-assistant/frontend/src/lib/api.ts`](https://github.com/rakno-27/enterprise-ai-knowledge-assistant/blob/main/enterprise-ai-assistant/frontend/src/lib/api.ts) (Frontend API client), [`enterprise-ai-assistant/backend/app/services/chat_service.py`](https://github.com/rakno-27/enterprise-ai-knowledge-assistant/blob/main/enterprise-ai-assistant/backend/app/services/chat_service.py) (Chat orchestration)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Web interface"]
  node_app["Application shell<br/>[App.tsx]"]
  node_chatui["Chat interface<br/>[ChatArea.tsx]"]
  node_docui["Document manager<br/>[DocumentModal.tsx]"]
  node_sidebar["Session sidebar<br/>[Sidebar.tsx]"]
  node_webapi["Frontend API client<br/>[api.ts]"]
end

subgraph group_api["Backend API"]
  node_server["API application<br/>[main.py]"]
  node_routes["API endpoints<br/>[endpoints.py]"]
  node_chat["Chat orchestration<br/>[chat_service.py]"]
  node_chatschema["Chat contracts<br/>[chat.py]"]
end

subgraph group_knowledge["Knowledge pipeline"]
  node_rag["RAG and ingestion<br/>[rag_service.py]"]
  node_ocr["Document OCR<br/>[ocr_service.py]"]
  node_chunking["Text chunking"]
  node_metadata["Metadata extraction"]
  node_rerank["Search reranking<br/>[rerank_service.py]"]
  node_storage["Document storage<br/>[storage_service.py]"]
end

subgraph group_platform["Identity and state"]
  node_config["Runtime settings<br/>[config.py]"]
  node_database[("Relational database<br/>[database.py]")]
  node_auth["Authentication<br/>[auth.py]"]
  node_security["Security utilities<br/>[security.py]"]
  node_session["Session handling<br/>[session.py]"]
end

node_user(("User"))

node_user -->|"uses"| node_app
node_app -->|"renders"| node_chatui
node_app -->|"renders"| node_docui
node_app -->|"renders"| node_sidebar
node_app -->|"requests data"| node_webapi
node_chatui -->|"loads chat data"| node_webapi
node_docui -->|"manages documents"| node_webapi
node_sidebar -->|"loads documents"| node_webapi
node_webapi -->|"HTTP requests"| node_routes
node_server -->|"mounts routes"| node_routes
node_server -->|"initializes state"| node_database
node_routes -.->|"dispatches chat"| node_chat
node_chat -->|"requests retrieval"| node_rag
node_rag -->|"chunks text"| node_chunking
node_rag -->|"extracts metadata"| node_metadata
node_rag -->|"reranks matches"| node_rerank
node_rag -->|"uses storage"| node_storage
node_rag -->|"extracts text"| node_ocr
node_database -->|"reads settings"| node_config
node_storage -->|"reads settings"| node_config
node_chat -->|"uses contracts"| node_chatschema

click node_app "https://github.com/rakno-27/enterprise-ai-knowledge-assistant/blob/main/enterprise-ai-assistant/frontend/src/App.tsx"
click node_chatui "https://github.com/rakno-27/enterprise-ai-knowledge-assistant/blob/main/enterprise-ai-assistant/frontend/src/components/ChatArea.tsx"
click node_docui "https://github.com/rakno-27/enterprise-ai-knowledge-assistant/blob/main/enterprise-ai-assistant/frontend/src/components/DocumentModal.tsx"
click node_sidebar "https://github.com/rakno-27/enterprise-ai-knowledge-assistant/blob/main/enterprise-ai-assistant/frontend/src/components/Sidebar.tsx"
click node_webapi "https://github.com/rakno-27/enterprise-ai-knowledge-assistant/blob/main/enterprise-ai-assistant/frontend/src/lib/api.ts"
click node_server "https://github.com/rakno-27/enterprise-ai-knowledge-assistant/blob/main/enterprise-ai-assistant/backend/app/main.py"
click node_routes "https://github.com/rakno-27/enterprise-ai-knowledge-assistant/blob/main/enterprise-ai-assistant/backend/app/api/v1/endpoints.py"
click node_chat "https://github.com/rakno-27/enterprise-ai-knowledge-assistant/blob/main/enterprise-ai-assistant/backend/app/services/chat_service.py"
click node_chatschema "https://github.com/rakno-27/enterprise-ai-knowledge-assistant/blob/main/enterprise-ai-assistant/backend/app/schemas/chat.py"
click node_rag "https://github.com/rakno-27/enterprise-ai-knowledge-assistant/blob/main/enterprise-ai-assistant/backend/app/services/rag_service.py"
click node_ocr "https://github.com/rakno-27/enterprise-ai-knowledge-assistant/blob/main/enterprise-ai-assistant/backend/app/services/ocr_service.py"
click node_chunking "https://github.com/rakno-27/enterprise-ai-knowledge-assistant/blob/main/enterprise-ai-assistant/backend/app/services/chunking_service.py"
click node_metadata "https://github.com/rakno-27/enterprise-ai-knowledge-assistant/blob/main/enterprise-ai-assistant/backend/app/services/metadata_service.py"
click node_rerank "https://github.com/rakno-27/enterprise-ai-knowledge-assistant/blob/main/enterprise-ai-assistant/backend/app/services/rerank_service.py"
click node_storage "https://github.com/rakno-27/enterprise-ai-knowledge-assistant/blob/main/enterprise-ai-assistant/backend/app/services/storage_service.py"
click node_config "https://github.com/rakno-27/enterprise-ai-knowledge-assistant/blob/main/enterprise-ai-assistant/backend/app/core/config.py"
click node_database "https://github.com/rakno-27/enterprise-ai-knowledge-assistant/blob/main/enterprise-ai-assistant/backend/app/core/database.py"
click node_auth "https://github.com/rakno-27/enterprise-ai-knowledge-assistant/blob/main/enterprise-ai-assistant/backend/app/core/auth.py"
click node_security "https://github.com/rakno-27/enterprise-ai-knowledge-assistant/blob/main/enterprise-ai-assistant/backend/app/core/security.py"
click node_session "https://github.com/rakno-27/enterprise-ai-knowledge-assistant/blob/main/enterprise-ai-assistant/backend/app/core/session.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_chatui,node_docui,node_sidebar,node_webapi,node_user toneBlue
class node_server,node_routes,node_chat,node_chatschema toneAmber
class node_rag,node_ocr,node_chunking,node_metadata,node_rerank,node_storage toneMint
class node_config,node_database,node_auth,node_security,node_session toneRose
```

## Components

### Web interface

- [Application shell](https://github.com/rakno-27/enterprise-ai-knowledge-assistant/blob/main/enterprise-ai-assistant/frontend/src/App.tsx): `enterprise-ai-assistant/frontend/src/App.tsx`
- [Chat interface](https://github.com/rakno-27/enterprise-ai-knowledge-assistant/blob/main/enterprise-ai-assistant/frontend/src/components/ChatArea.tsx): `enterprise-ai-assistant/frontend/src/components/ChatArea.tsx`
- [Document manager](https://github.com/rakno-27/enterprise-ai-knowledge-assistant/blob/main/enterprise-ai-assistant/frontend/src/components/DocumentModal.tsx): `enterprise-ai-assistant/frontend/src/components/DocumentModal.tsx`
- [Session sidebar](https://github.com/rakno-27/enterprise-ai-knowledge-assistant/blob/main/enterprise-ai-assistant/frontend/src/components/Sidebar.tsx): `enterprise-ai-assistant/frontend/src/components/Sidebar.tsx`
- [Frontend API client](https://github.com/rakno-27/enterprise-ai-knowledge-assistant/blob/main/enterprise-ai-assistant/frontend/src/lib/api.ts): `enterprise-ai-assistant/frontend/src/lib/api.ts`

### Backend API

- [API application](https://github.com/rakno-27/enterprise-ai-knowledge-assistant/blob/main/enterprise-ai-assistant/backend/app/main.py): `enterprise-ai-assistant/backend/app/main.py`
- [API endpoints](https://github.com/rakno-27/enterprise-ai-knowledge-assistant/blob/main/enterprise-ai-assistant/backend/app/api/v1/endpoints.py): `enterprise-ai-assistant/backend/app/api/v1/endpoints.py`
- [Chat orchestration](https://github.com/rakno-27/enterprise-ai-knowledge-assistant/blob/main/enterprise-ai-assistant/backend/app/services/chat_service.py): `enterprise-ai-assistant/backend/app/services/chat_service.py`
- [Chat contracts](https://github.com/rakno-27/enterprise-ai-knowledge-assistant/blob/main/enterprise-ai-assistant/backend/app/schemas/chat.py): `enterprise-ai-assistant/backend/app/schemas/chat.py`

### Knowledge pipeline

- [RAG and ingestion](https://github.com/rakno-27/enterprise-ai-knowledge-assistant/blob/main/enterprise-ai-assistant/backend/app/services/rag_service.py): `enterprise-ai-assistant/backend/app/services/rag_service.py`
- [Document OCR](https://github.com/rakno-27/enterprise-ai-knowledge-assistant/blob/main/enterprise-ai-assistant/backend/app/services/ocr_service.py): `enterprise-ai-assistant/backend/app/services/ocr_service.py`
- [Text chunking](https://github.com/rakno-27/enterprise-ai-knowledge-assistant/blob/main/enterprise-ai-assistant/backend/app/services/chunking_service.py): `enterprise-ai-assistant/backend/app/services/chunking_service.py`
- [Metadata extraction](https://github.com/rakno-27/enterprise-ai-knowledge-assistant/blob/main/enterprise-ai-assistant/backend/app/services/metadata_service.py): `enterprise-ai-assistant/backend/app/services/metadata_service.py`
- [Search reranking](https://github.com/rakno-27/enterprise-ai-knowledge-assistant/blob/main/enterprise-ai-assistant/backend/app/services/rerank_service.py): `enterprise-ai-assistant/backend/app/services/rerank_service.py`
- [Document storage](https://github.com/rakno-27/enterprise-ai-knowledge-assistant/blob/main/enterprise-ai-assistant/backend/app/services/storage_service.py): `enterprise-ai-assistant/backend/app/services/storage_service.py`

### Identity and state

- [Runtime settings](https://github.com/rakno-27/enterprise-ai-knowledge-assistant/blob/main/enterprise-ai-assistant/backend/app/core/config.py): `enterprise-ai-assistant/backend/app/core/config.py`
- [Relational database](https://github.com/rakno-27/enterprise-ai-knowledge-assistant/blob/main/enterprise-ai-assistant/backend/app/core/database.py): `enterprise-ai-assistant/backend/app/core/database.py`
- [Authentication](https://github.com/rakno-27/enterprise-ai-knowledge-assistant/blob/main/enterprise-ai-assistant/backend/app/core/auth.py): `enterprise-ai-assistant/backend/app/core/auth.py`
- [Security utilities](https://github.com/rakno-27/enterprise-ai-knowledge-assistant/blob/main/enterprise-ai-assistant/backend/app/core/security.py): `enterprise-ai-assistant/backend/app/core/security.py`
- [Session handling](https://github.com/rakno-27/enterprise-ai-knowledge-assistant/blob/main/enterprise-ai-assistant/backend/app/core/session.py): `enterprise-ai-assistant/backend/app/core/session.py`

### Other components

- **User**

## Connections

- User → Application shell: uses (evidence: `enterprise-ai-assistant/frontend/src/App.tsx`)
- Application shell → Chat interface: renders (evidence: `enterprise-ai-assistant/frontend/src/App.tsx`)
- Application shell → Document manager: renders (evidence: `enterprise-ai-assistant/frontend/src/App.tsx`)
- Application shell → Session sidebar: renders (evidence: `enterprise-ai-assistant/frontend/src/App.tsx`)
- Application shell → Frontend API client: requests data (evidence: `enterprise-ai-assistant/frontend/src/App.tsx`)
- Chat interface → Frontend API client: loads chat data (evidence: `enterprise-ai-assistant/frontend/src/components/ChatArea.tsx`)
- Document manager → Frontend API client: manages documents (evidence: `enterprise-ai-assistant/frontend/src/components/DocumentModal.tsx`)
- Session sidebar → Frontend API client: loads documents (evidence: `enterprise-ai-assistant/frontend/src/components/Sidebar.tsx`)
- Frontend API client → API endpoints: HTTP requests (evidence: `enterprise-ai-assistant/frontend/src/lib/api.ts`)
- API application → API endpoints: mounts routes (evidence: `enterprise-ai-assistant/backend/app/main.py`)
- API application → Relational database: initializes state (evidence: `enterprise-ai-assistant/backend/app/main.py`)
- API endpoints → Chat orchestration: dispatches chat (evidence: `enterprise-ai-assistant/backend/app/api/v1/endpoints.py`)
- Chat orchestration → RAG and ingestion: requests retrieval (evidence: `enterprise-ai-assistant/backend/app/services/chat_service.py`)
- RAG and ingestion → Text chunking: chunks text (evidence: `enterprise-ai-assistant/backend/app/services/rag_service.py`)
- RAG and ingestion → Metadata extraction: extracts metadata (evidence: `enterprise-ai-assistant/backend/app/services/rag_service.py`)
- RAG and ingestion → Search reranking: reranks matches (evidence: `enterprise-ai-assistant/backend/app/services/rag_service.py`)
- RAG and ingestion → Document storage: uses storage (evidence: `enterprise-ai-assistant/backend/app/services/rag_service.py`)
- RAG and ingestion → Document OCR: extracts text (evidence: `enterprise-ai-assistant/backend/app/services/rag_service.py`)
- Relational database → Runtime settings: reads settings (evidence: `enterprise-ai-assistant/backend/app/core/database.py`)
- Document storage → Runtime settings: reads settings (evidence: `enterprise-ai-assistant/backend/app/services/storage_service.py`)
- Chat orchestration → Chat contracts: uses contracts (evidence: `enterprise-ai-assistant/backend/app/services/chat_service.py`)
