# ysaibhanu99/klyvix architecture

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

- Interactive diagram: https://gitdiagram.com/ysaibhanu99/klyvix
- Repository: https://github.com/ysaibhanu99/klyvix

## Overview

Klyvix is a multi-persona AI assistant for academic and professional workflows. Users can authenticate, choose a persona, chat with streamed responses, and upload documents for grounded answers; the platform also supports research search and structured code or resume feedback. The backend routes chat through persona configuration, optional document retrieval, and provider selection, while Redis supports response caching and rate limiting. The README documents major capabilities beyond the sampled implementation excerpts; those are represented at subsystem level where exact internal wiring is not shown.

Main entry points: [`backend/app/routers/chat.py`](https://github.com/ysaibhanu99/klyvix/blob/main/backend/app/routers/chat.py) (Chat endpoint), [`backend/app/core/llm_client.py`](https://github.com/ysaibhanu99/klyvix/blob/main/backend/app/core/llm_client.py) (LLM routing and streaming), [`backend/app/core/retrieval.py`](https://github.com/ysaibhanu99/klyvix/blob/main/backend/app/core/retrieval.py) (Document processing and retrieval), [`backend/app/main.py`](https://github.com/ysaibhanu99/klyvix/blob/main/backend/app/main.py) (FastAPI application)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Web interface"]
  node_web_app["Web application<br/>[app.js]"]
  node_chat_ui["Chat interface<br/>[chat.js]"]
  node_structured_ui["Structured cards<br/>[structured.js]"]
  node_upload_ui["Upload interface<br/>[upload.js]"]
  node_api_client["API client<br/>[api.js]"]
end

subgraph group_api["API workflows"]
  node_app_server["FastAPI application<br/>[main.py]"]
  node_auth_routes["Authentication<br/>[auth.py]"]
  node_chat_route["Chat endpoint<br/>[chat.py]"]
  node_upload_route["Upload endpoint<br/>[upload.py]"]
end

subgraph group_ai["AI and retrieval"]
  node_persona_registry["Six AI personas<br/>[registry.py]"]
  node_retrieval["Document processing and retrieval<br/>[retrieval.py]"]
  node_llm_router["LLM routing and streaming<br/>[llm_client.py]"]
end

subgraph group_state["State and services"]
  node_rate_limiter["Rate limiting<br/>[rate_limit.py]"]
  node_cache["Response cache<br/>[cache.py]"]
  node_postgres[("PostgreSQL<br/>[database.py]")]
  node_qdrant[("Qdrant vectors<br/>[retrieval.py]")]
  node_redis[("Redis<br/>[cache.py]")]
end

node_user(("User"))
node_llm_providers["Gemini, Mistral, Groq"]
node_research_search["Google Search grounding"]

node_user -->|"uses"| node_web_app
node_web_app -->|"requests"| node_api_client
node_api_client -->|"calls chat API"| node_chat_route
node_chat_route -->|"loads persona"| node_persona_registry
node_chat_route -->|"retrieves context"| node_retrieval
node_chat_route -->|"streams response"| node_llm_router
node_chat_route -->|"applies limit"| node_rate_limiter
node_chat_route -->|"verifies token"| node_auth_routes
node_auth_routes -->|"reads and writes users"| node_postgres
node_auth_routes -->|"issues JWT"| node_user
node_upload_route -->|"stores documents"| node_retrieval
node_upload_route -->|"applies limit"| node_rate_limiter
node_retrieval -->|"stores metadata"| node_postgres
node_retrieval -->|"stores and searches vectors"| node_qdrant
node_retrieval -->|"requests embeddings"| node_llm_router
node_llm_router -->|"selects provider settings"| node_persona_registry
node_llm_router -->|"reads and writes responses"| node_cache
node_llm_router -->|"streams completions"| node_llm_providers
node_llm_router -.->|"grounds research"| node_research_search
node_rate_limiter -->|"increments counters"| node_cache
node_cache -->|"caches and counts"| node_redis
node_app_server -->|"mounts router"| node_auth_routes
node_app_server -->|"mounts router"| node_chat_route
node_app_server -->|"mounts router"| node_upload_route
node_app_server -->|"serves frontend"| node_web_app
node_chat_ui -.->|"uses API"| node_api_client
node_upload_ui -.->|"uses API"| node_api_client
node_structured_ui -.->|"renders outputs"| node_web_app

click node_web_app "https://github.com/ysaibhanu99/klyvix/blob/main/backend/static/js/app.js"
click node_chat_ui "https://github.com/ysaibhanu99/klyvix/blob/main/backend/static/js/components/chat.js"
click node_structured_ui "https://github.com/ysaibhanu99/klyvix/blob/main/backend/static/js/components/structured.js"
click node_upload_ui "https://github.com/ysaibhanu99/klyvix/blob/main/backend/static/js/components/upload.js"
click node_api_client "https://github.com/ysaibhanu99/klyvix/blob/main/backend/static/js/api.js"
click node_app_server "https://github.com/ysaibhanu99/klyvix/blob/main/backend/app/main.py"
click node_auth_routes "https://github.com/ysaibhanu99/klyvix/blob/main/backend/app/routers/auth.py"
click node_chat_route "https://github.com/ysaibhanu99/klyvix/blob/main/backend/app/routers/chat.py"
click node_upload_route "https://github.com/ysaibhanu99/klyvix/blob/main/backend/app/routers/upload.py"
click node_persona_registry "https://github.com/ysaibhanu99/klyvix/blob/main/backend/app/personas/registry.py"
click node_retrieval "https://github.com/ysaibhanu99/klyvix/blob/main/backend/app/core/retrieval.py"
click node_llm_router "https://github.com/ysaibhanu99/klyvix/blob/main/backend/app/core/llm_client.py"
click node_rate_limiter "https://github.com/ysaibhanu99/klyvix/blob/main/backend/app/core/rate_limit.py"
click node_cache "https://github.com/ysaibhanu99/klyvix/blob/main/backend/app/core/cache.py"
click node_postgres "https://github.com/ysaibhanu99/klyvix/blob/main/backend/app/models/database.py"
click node_qdrant "https://github.com/ysaibhanu99/klyvix/blob/main/backend/app/core/retrieval.py"
click node_redis "https://github.com/ysaibhanu99/klyvix/blob/main/backend/app/core/cache.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_web_app,node_chat_ui,node_structured_ui,node_upload_ui,node_api_client,node_user toneBlue
class node_app_server,node_auth_routes,node_chat_route,node_upload_route toneAmber
class node_persona_registry,node_retrieval,node_llm_router toneMint
class node_rate_limiter,node_cache,node_postgres,node_qdrant,node_redis toneRose
class node_llm_providers,node_research_search toneIndigo
```

## Components

### Web interface

- [Web application](https://github.com/ysaibhanu99/klyvix/blob/main/backend/static/js/app.js): `backend/static/js/app.js`
- [Chat interface](https://github.com/ysaibhanu99/klyvix/blob/main/backend/static/js/components/chat.js): `backend/static/js/components/chat.js`
- [Structured cards](https://github.com/ysaibhanu99/klyvix/blob/main/backend/static/js/components/structured.js): `backend/static/js/components/structured.js`
- [Upload interface](https://github.com/ysaibhanu99/klyvix/blob/main/backend/static/js/components/upload.js): `backend/static/js/components/upload.js`
- [API client](https://github.com/ysaibhanu99/klyvix/blob/main/backend/static/js/api.js): `backend/static/js/api.js`

### API workflows

- [FastAPI application](https://github.com/ysaibhanu99/klyvix/blob/main/backend/app/main.py): `backend/app/main.py`
- [Authentication](https://github.com/ysaibhanu99/klyvix/blob/main/backend/app/routers/auth.py): `backend/app/routers/auth.py`
- [Chat endpoint](https://github.com/ysaibhanu99/klyvix/blob/main/backend/app/routers/chat.py): `backend/app/routers/chat.py`
- [Upload endpoint](https://github.com/ysaibhanu99/klyvix/blob/main/backend/app/routers/upload.py): `backend/app/routers/upload.py`

### AI and retrieval

- [Six AI personas](https://github.com/ysaibhanu99/klyvix/blob/main/backend/app/personas/registry.py): `backend/app/personas/registry.py`
- [Document processing and retrieval](https://github.com/ysaibhanu99/klyvix/blob/main/backend/app/core/retrieval.py): `backend/app/core/retrieval.py`
- [LLM routing and streaming](https://github.com/ysaibhanu99/klyvix/blob/main/backend/app/core/llm_client.py): `backend/app/core/llm_client.py`

### State and services

- [Rate limiting](https://github.com/ysaibhanu99/klyvix/blob/main/backend/app/core/rate_limit.py): `backend/app/core/rate_limit.py`
- [Response cache](https://github.com/ysaibhanu99/klyvix/blob/main/backend/app/core/cache.py): `backend/app/core/cache.py`
- [PostgreSQL](https://github.com/ysaibhanu99/klyvix/blob/main/backend/app/models/database.py): `backend/app/models/database.py`
- [Qdrant vectors](https://github.com/ysaibhanu99/klyvix/blob/main/backend/app/core/retrieval.py): `backend/app/core/retrieval.py`
- [Redis](https://github.com/ysaibhanu99/klyvix/blob/main/backend/app/core/cache.py): `backend/app/core/cache.py`

### Other components

- **User**
- **Gemini, Mistral, Groq**
- **Google Search grounding**

## Connections

- User → Web application: uses (evidence: `README.md`)
- Web application → API client: requests (evidence: `README.md`)
- API client → Chat endpoint: calls chat API (evidence: `README.md`)
- Chat endpoint → Six AI personas: loads persona (evidence: `backend/app/routers/chat.py`)
- Chat endpoint → Document processing and retrieval: retrieves context (evidence: `backend/app/routers/chat.py`)
- Chat endpoint → LLM routing and streaming: streams response (evidence: `backend/app/routers/chat.py`)
- Chat endpoint → Rate limiting: applies limit (evidence: `backend/app/routers/chat.py`)
- Chat endpoint → Authentication: verifies token (evidence: `backend/app/routers/chat.py`)
- Authentication → PostgreSQL: reads and writes users (evidence: `backend/app/routers/auth.py`)
- Authentication → User: issues JWT (evidence: `backend/app/routers/auth.py`)
- Upload endpoint → Document processing and retrieval: stores documents (evidence: `backend/app/routers/upload.py`)
- Upload endpoint → Rate limiting: applies limit (evidence: `backend/app/routers/upload.py`)
- Document processing and retrieval → PostgreSQL: stores metadata (evidence: `backend/app/core/retrieval.py`)
- Document processing and retrieval → Qdrant vectors: stores and searches vectors (evidence: `backend/app/core/retrieval.py`)
- Document processing and retrieval → LLM routing and streaming: requests embeddings (evidence: `backend/app/core/retrieval.py`)
- LLM routing and streaming → Six AI personas: selects provider settings (evidence: `backend/app/core/llm_client.py`)
- LLM routing and streaming → Response cache: reads and writes responses (evidence: `backend/app/core/llm_client.py`)
- LLM routing and streaming → Gemini, Mistral, Groq: streams completions (evidence: `backend/app/core/llm_client.py`)
- LLM routing and streaming → Google Search grounding: grounds research (evidence: `README.md`)
- Rate limiting → Response cache: increments counters (evidence: `backend/app/core/rate_limit.py`)
- Response cache → Redis: caches and counts (evidence: `backend/app/core/cache.py`)
- FastAPI application → Authentication: mounts router (evidence: `backend/app/main.py`)
- FastAPI application → Chat endpoint: mounts router (evidence: `backend/app/main.py`)
- FastAPI application → Upload endpoint: mounts router (evidence: `backend/app/main.py`)
- FastAPI application → Web application: serves frontend (evidence: `backend/app/main.py`)
- Chat interface → API client: uses API
- Upload interface → API client: uses API
- Structured cards → Web application: renders outputs
