# ankit65k/ragcx architecture

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

- Interactive diagram: https://gitdiagram.com/ankit65k/ragcx
- Repository: https://github.com/ankit65k/ragcx

## Overview

RagCX is a PDF knowledge-base and RAG chat platform. Users authenticate, upload documents, and ask questions; the API persists sessions and relays chat/document events through Redis to the Python AI service, which processes documents into a vector store and retrieves context for generated answers. The frontend also exposes document management, suggested questions, dashboard, and settings capabilities. Edges reflect the README’s service architecture and the supplied source excerpts/index; unsampled subsystem internals and some runtime wiring are not asserted.

Main entry points: [`backend/src/app.ts`](https://github.com/ankit65k/ragcx/blob/main/backend/src/app.ts) (REST API), [`frontend/src/app`](https://github.com/ankit65k/ragcx/tree/main/frontend/src/app) (Web experience), [`ai-service/app/chat/pipeline.py`](https://github.com/ankit65k/ragcx/blob/main/ai-service/app/chat/pipeline.py) (Chat event pipeline), [`ai-service/app/workflows/engine.py`](https://github.com/ankit65k/ragcx/blob/main/ai-service/app/workflows/engine.py) (Workflow engine)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Web frontend"]
  node_web["Web experience"]
  node_authui["Authentication UI"]
  node_chatu["Chat UI"]
  node_docui["Document UI"]
  node_otherui["Dashboard and settings"]
end

subgraph group_backend["API and domain"]
  node_rest["REST API<br/>[app.ts]"]
  node_auth["Auth and sessions<br/>[auth.service.ts]"]
  node_documents["Document management"]
  node_chatapi["Chat and questions API<br/>[chat.controller.ts]"]
  node_dashboard["Dashboard API"]
end

subgraph group_ai["AI workflows"]
  node_aientry["AI service<br/>[main.py]"]
  node_chatpipe["Chat event pipeline<br/>[pipeline.py]"]
  node_workflow["Workflow engine<br/>[engine.py]"]
  node_rag["RAG answer generation<br/>[pipeline.py]"]
  node_questions["Suggested questions<br/>[pipeline.py]"]
  node_memory["Conversation memory<br/>[manager.py]"]
  node_docflow["Document processing"]
  node_embed["Embeddings<br/>[service.py]"]
  node_retrieval["Retrieval<br/>[services.py]"]
end

subgraph group_infra["Infrastructure"]
  node_storagefactory["Storage provider<br/>[storage.factory.ts]"]
  node_localstorage["Local file storage"]
  node_db[("PostgreSQL data<br/>[index.ts]")]
  node_redis["Redis Pub/Sub"]
  node_vectors[("Chroma vector store<br/>[chroma.py]")]
  node_llm["Ollama model<br/>[ollama.py]"]
end

node_user(("User"))
node_files["PDF files"]

node_user -->|"uses"| node_web
node_web -->|"offers sign-in"| node_authui
node_authui -.->|"calls REST"| node_rest
node_web -->|"offers chat"| node_chatu
node_web -->|"offers uploads"| node_docui
node_web -->|"offers tools"| node_otherui
node_chatu -.->|"calls REST"| node_rest
node_docui -.->|"calls REST"| node_rest
node_rest -.->|"routes requests"| node_auth
node_rest -.->|"routes requests"| node_documents
node_rest -.->|"routes requests"| node_chatapi
node_rest -.->|"routes requests"| node_dashboard
node_auth -.->|"persists accounts"| node_db
node_documents -.->|"stores files"| node_storagefactory
node_storagefactory -->|"creates provider"| node_localstorage
node_documents -.->|"publishes document events"| node_redis
node_chatapi -->|"publishes chat events"| node_redis
node_chatapi -->|"persists chat data"| node_db
node_dashboard -->|"reads metrics"| node_db
node_redis -->|"delivers events"| node_aientry
node_aientry -.->|"dispatches chat"| node_chatpipe
node_chatpipe -->|"executes workflow"| node_workflow
node_workflow -.->|"runs answer stage"| node_rag
node_workflow -.->|"runs processing stage"| node_docflow
node_workflow -.->|"runs question stage"| node_questions
node_chatpipe -.->|"manages conversation"| node_memory
node_rag -->|"retrieves context"| node_retrieval
node_retrieval -.->|"searches vectors"| node_vectors
node_rag -->|"generates answer"| node_llm
node_questions -->|"generates questions"| node_llm
node_docflow -.->|"creates embeddings"| node_embed
node_embed -.->|"stores vectors"| node_vectors
node_files -.->|"uploads PDF"| node_documents
node_chatpipe -->|"publishes response"| node_redis

click node_web "https://github.com/ankit65k/ragcx/tree/main/frontend/src/app"
click node_authui "https://github.com/ankit65k/ragcx/tree/main/frontend/src/features/auth"
click node_chatu "https://github.com/ankit65k/ragcx/tree/main/frontend/src/features/chat"
click node_docui "https://github.com/ankit65k/ragcx/tree/main/frontend/src/features/documents"
click node_otherui "https://github.com/ankit65k/ragcx/tree/main/frontend/src/features"
click node_rest "https://github.com/ankit65k/ragcx/blob/main/backend/src/app.ts"
click node_auth "https://github.com/ankit65k/ragcx/blob/main/backend/src/modules/auth/services/auth.service.ts"
click node_documents "https://github.com/ankit65k/ragcx/tree/main/backend/src/modules/documents"
click node_chatapi "https://github.com/ankit65k/ragcx/blob/main/backend/src/modules/chat/controllers/chat.controller.ts"
click node_dashboard "https://github.com/ankit65k/ragcx/blob/main/backend/src/modules/dashboard/controllers/dashboard.controller.ts"
click node_storagefactory "https://github.com/ankit65k/ragcx/blob/main/backend/src/infrastructure/storage/storage.factory.ts"
click node_localstorage "https://github.com/ankit65k/ragcx/blob/main/backend/src/infrastructure/storage/providers/local-storage.provider.ts"
click node_db "https://github.com/ankit65k/ragcx/blob/main/backend/src/database/client/index.ts"
click node_redis "https://github.com/ankit65k/ragcx/tree/main/backend/src/infrastructure/redis"
click node_aientry "https://github.com/ankit65k/ragcx/blob/main/ai-service/app/main.py"
click node_chatpipe "https://github.com/ankit65k/ragcx/blob/main/ai-service/app/chat/pipeline.py"
click node_workflow "https://github.com/ankit65k/ragcx/blob/main/ai-service/app/workflows/engine.py"
click node_rag "https://github.com/ankit65k/ragcx/blob/main/ai-service/app/rag/pipeline.py"
click node_questions "https://github.com/ankit65k/ragcx/blob/main/ai-service/app/questions/pipeline.py"
click node_memory "https://github.com/ankit65k/ragcx/blob/main/ai-service/app/memory/manager.py"
click node_docflow "https://github.com/ankit65k/ragcx/blob/main/ai-service/app/workflows/definitions/document_processing.py"
click node_embed "https://github.com/ankit65k/ragcx/blob/main/ai-service/app/embeddings/service.py"
click node_retrieval "https://github.com/ankit65k/ragcx/blob/main/ai-service/app/retrievers/services.py"
click node_vectors "https://github.com/ankit65k/ragcx/blob/main/ai-service/app/vector_store/chroma.py"
click node_llm "https://github.com/ankit65k/ragcx/blob/main/ai-service/app/models/ollama.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,node_authui,node_chatu,node_docui,node_otherui,node_user toneBlue
class node_rest,node_auth,node_documents,node_chatapi,node_dashboard toneAmber
class node_aientry,node_chatpipe,node_workflow,node_rag,node_questions,node_memory,node_docflow,node_embed,node_retrieval toneMint
class node_storagefactory,node_localstorage,node_db,node_redis,node_vectors,node_llm toneRose
class node_files toneIndigo
```

## Components

### Web frontend

- [Web experience](https://github.com/ankit65k/ragcx/tree/main/frontend/src/app): `frontend/src/app`
- [Authentication UI](https://github.com/ankit65k/ragcx/tree/main/frontend/src/features/auth): `frontend/src/features/auth`
- [Chat UI](https://github.com/ankit65k/ragcx/tree/main/frontend/src/features/chat): `frontend/src/features/chat`
- [Document UI](https://github.com/ankit65k/ragcx/tree/main/frontend/src/features/documents): `frontend/src/features/documents`
- [Dashboard and settings](https://github.com/ankit65k/ragcx/tree/main/frontend/src/features): `frontend/src/features`

### API and domain

- [REST API](https://github.com/ankit65k/ragcx/blob/main/backend/src/app.ts): `backend/src/app.ts`
- [Auth and sessions](https://github.com/ankit65k/ragcx/blob/main/backend/src/modules/auth/services/auth.service.ts): `backend/src/modules/auth/services/auth.service.ts`
- [Document management](https://github.com/ankit65k/ragcx/tree/main/backend/src/modules/documents): `backend/src/modules/documents`
- [Chat and questions API](https://github.com/ankit65k/ragcx/blob/main/backend/src/modules/chat/controllers/chat.controller.ts): `backend/src/modules/chat/controllers/chat.controller.ts`
- [Dashboard API](https://github.com/ankit65k/ragcx/blob/main/backend/src/modules/dashboard/controllers/dashboard.controller.ts): `backend/src/modules/dashboard/controllers/dashboard.controller.ts`

### AI workflows

- [AI service](https://github.com/ankit65k/ragcx/blob/main/ai-service/app/main.py): `ai-service/app/main.py`
- [Chat event pipeline](https://github.com/ankit65k/ragcx/blob/main/ai-service/app/chat/pipeline.py): `ai-service/app/chat/pipeline.py`
- [Workflow engine](https://github.com/ankit65k/ragcx/blob/main/ai-service/app/workflows/engine.py): `ai-service/app/workflows/engine.py`
- [RAG answer generation](https://github.com/ankit65k/ragcx/blob/main/ai-service/app/rag/pipeline.py): `ai-service/app/rag/pipeline.py`
- [Suggested questions](https://github.com/ankit65k/ragcx/blob/main/ai-service/app/questions/pipeline.py): `ai-service/app/questions/pipeline.py`
- [Conversation memory](https://github.com/ankit65k/ragcx/blob/main/ai-service/app/memory/manager.py): `ai-service/app/memory/manager.py`
- [Document processing](https://github.com/ankit65k/ragcx/blob/main/ai-service/app/workflows/definitions/document_processing.py): `ai-service/app/workflows/definitions/document_processing.py`
- [Embeddings](https://github.com/ankit65k/ragcx/blob/main/ai-service/app/embeddings/service.py): `ai-service/app/embeddings/service.py`
- [Retrieval](https://github.com/ankit65k/ragcx/blob/main/ai-service/app/retrievers/services.py): `ai-service/app/retrievers/services.py`

### Infrastructure

- [Storage provider](https://github.com/ankit65k/ragcx/blob/main/backend/src/infrastructure/storage/storage.factory.ts): `backend/src/infrastructure/storage/storage.factory.ts`
- [Local file storage](https://github.com/ankit65k/ragcx/blob/main/backend/src/infrastructure/storage/providers/local-storage.provider.ts): `backend/src/infrastructure/storage/providers/local-storage.provider.ts`
- [PostgreSQL data](https://github.com/ankit65k/ragcx/blob/main/backend/src/database/client/index.ts): `backend/src/database/client/index.ts`
- [Redis Pub/Sub](https://github.com/ankit65k/ragcx/tree/main/backend/src/infrastructure/redis): `backend/src/infrastructure/redis`
- [Chroma vector store](https://github.com/ankit65k/ragcx/blob/main/ai-service/app/vector_store/chroma.py): `ai-service/app/vector_store/chroma.py`
- [Ollama model](https://github.com/ankit65k/ragcx/blob/main/ai-service/app/models/ollama.py): `ai-service/app/models/ollama.py`

### Other components

- **User**
- **PDF files**

## Connections

- User → Web experience: uses
- Web experience → Authentication UI: offers sign-in (evidence: `frontend/src/features/auth/hooks/useAuth.ts`)
- Authentication UI → REST API: calls REST
- Web experience → Chat UI: offers chat
- Web experience → Document UI: offers uploads
- Web experience → Dashboard and settings: offers tools
- Chat UI → REST API: calls REST
- Document UI → REST API: calls REST
- REST API → Auth and sessions: routes requests
- REST API → Document management: routes requests
- REST API → Chat and questions API: routes requests
- REST API → Dashboard API: routes requests (evidence: `backend/src/modules/dashboard/controllers/dashboard.controller.ts`)
- Auth and sessions → PostgreSQL data: persists accounts
- Document management → Storage provider: stores files
- Storage provider → Local file storage: creates provider (evidence: `backend/src/infrastructure/storage/storage.factory.ts`)
- Document management → Redis Pub/Sub: publishes document events
- Chat and questions API → Redis Pub/Sub: publishes chat events (evidence: `backend/src/modules/chat/controllers/chat.controller.ts`)
- Chat and questions API → PostgreSQL data: persists chat data (evidence: `backend/src/modules/chat/controllers/chat.controller.ts`)
- Dashboard API → PostgreSQL data: reads metrics (evidence: `backend/src/modules/dashboard/controllers/dashboard.controller.ts`)
- Redis Pub/Sub → AI service: delivers events
- AI service → Chat event pipeline: dispatches chat
- Chat event pipeline → Workflow engine: executes workflow (evidence: `ai-service/app/chat/pipeline.py`)
- Workflow engine → RAG answer generation: runs answer stage
- Workflow engine → Document processing: runs processing stage
- Workflow engine → Suggested questions: runs question stage
- Chat event pipeline → Conversation memory: manages conversation
- RAG answer generation → Retrieval: retrieves context (evidence: `ai-service/app/rag/pipeline.py`)
- Retrieval → Chroma vector store: searches vectors
- RAG answer generation → Ollama model: generates answer (evidence: `ai-service/app/rag/pipeline.py`)
- Suggested questions → Ollama model: generates questions (evidence: `ai-service/app/questions/pipeline.py`)
- Document processing → Embeddings: creates embeddings
- Embeddings → Chroma vector store: stores vectors
- PDF files → Document management: uploads PDF
- Chat event pipeline → Redis Pub/Sub: publishes response (evidence: `ai-service/app/chat/pipeline.py`)
