# technoritesh152005/rag architecture

> Architecture diagram of the GitHub repository technoritesh152005/rag, 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/technoritesh152005/rag
- Repository: https://github.com/technoritesh152005/rag

## Overview

DocuFlux is a workspace-scoped documentation ingestion and grounded-Q&A product. Users add web pages, PDFs, or YouTube videos; background processing extracts and chunks content, deduplicates it, and indexes it for retrieval. In a workspace, chat combines vector and keyword search, then streams cited answers. The graph also preserves the documented workspace, FAQ, analytics, and evaluation capabilities. Some implementation details—especially YouTube/PDF processing, socket routing, and cache internals—are documented but not excerpted, so those links cite the README rather than implying source inspection.

Main entry points: [`Backend/src/server.js`](https://github.com/technoritesh152005/rag/blob/main/Backend/src/server.js) (Fastify API), [`Backend/src/modules/chat/rag.service.js`](https://github.com/technoritesh152005/rag/blob/main/Backend/src/modules/chat/rag.service.js) (RAG orchestration), [`Backend/src/modules/jobs/ingestion.job.js`](https://github.com/technoritesh152005/rag/blob/main/Backend/src/modules/jobs/ingestion.job.js) (Index storage), [`Frontend/src/App.jsx`](https://github.com/technoritesh152005/rag/blob/main/Frontend/src/App.jsx) (React app)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Workspace client"]
  node_frontend["React app<br/>[App.jsx]"]
  node_workspace_ui["Workspace UI<br/>[WorkspacePage.jsx]"]
  node_source_ui["Source panel<br/>[SourcePanel.jsx]"]
  node_chat_ui["Chat panel<br/>[ChatPanel.jsx]"]
end

subgraph group_api["API and workspace"]
  node_api["Fastify API<br/>[server.js]"]
  node_auth["Token authentication<br/>[auth_middleware.js]"]
  node_workspace["Workspace operations"]
  node_sources["Source management<br/>[source.service.js]"]
  node_pdf_upload["PDF upload"]
  node_storage[("PDF object storage")]
  node_gateway["Realtime gateway<br/>[chat.gateway.js]"]
  node_faq["Workspace FAQs<br/>[faq.service.js]"]
end

subgraph group_ingest["Ingestion and indexing"]
  node_queue["Ingestion queue<br/>[queue.js]"]
  node_worker["Ingestion worker"]
  node_extract["Content extraction"]
  node_chunking["Chunking and dedup<br/>[chunker.service.js]"]
  node_embedding["Local embeddings"]
  node_indexing["Index storage<br/>[ingestion.job.js]"]
end

subgraph group_qa["Retrieval and answers"]
  node_pinecone[("Pinecone vectors")]
  node_postgres[("PostgreSQL chunks")]
  node_rag["RAG orchestration<br/>[rag.service.js]"]
  node_hybrid["Hybrid retrieval<br/>[hybrid.service.js]"]
  node_cache[("Redis answer caches")]
  node_groq["Groq generation<br/>[groq.service.js]"]
end

subgraph group_insights["Evaluation and insights"]
  node_analytics["Usage analytics<br/>[usage.service.js]"]
  node_evaluation["Evaluation runs<br/>[eval.service.js]"]
end

node_user(("User"))
node_external_auth(("Supabase Auth"))
node_sources_ext["Web, PDF, video sources"]

node_user -->|"uses"| node_frontend
node_frontend -->|"routes to"| node_workspace_ui
node_workspace_ui -->|"renders"| node_source_ui
node_workspace_ui -->|"renders"| node_chat_ui
node_frontend -->|"authenticates with"| node_external_auth
node_frontend -->|"HTTP requests"| node_api
node_api -->|"validates access"| node_auth
node_auth -->|"validates token"| node_external_auth
node_api -->|"routes workspace requests"| node_workspace
node_source_ui -->|"submits sources"| node_api
node_api -->|"routes source requests"| node_sources
node_api -->|"routes PDF uploads"| node_pdf_upload
node_pdf_upload -->|"creates upload URL"| node_storage
node_pdf_upload -->|"enqueues indexing"| node_queue
node_sources_ext -.->|"submits URLs and videos"| node_queue
node_storage -->|"provides PDF"| node_extract
node_queue -->|"dispatches jobs"| node_worker
node_worker -->|"crawls source"| node_extract
node_extract -->|"sections content"| node_chunking
node_worker -->|"sends chunks"| node_indexing
node_indexing -->|"embeds chunks"| node_embedding
node_indexing -->|"upserts vectors"| node_pinecone
node_indexing -->|"stores searchable chunks"| node_postgres
node_chat_ui -->|"sends questions"| node_api
node_api -->|"dispatches chat"| node_rag
node_rag -->|"embeds question"| node_embedding
node_rag -->|"checks and stores answers"| node_cache
node_rag -->|"requests retrieval"| node_hybrid
node_hybrid -->|"searches vectors"| node_pinecone
node_hybrid -->|"searches keywords"| node_postgres
node_rag -->|"streams generation"| node_groq
node_rag -->|"streams cited answers"| node_gateway
node_gateway -->|"streams chat and status"| node_frontend
node_worker -->|"publishes source progress"| node_gateway
node_api -->|"serves FAQ requests"| node_faq
node_workspace_ui -->|"runs evaluations"| node_evaluation
node_api -->|"routes evaluation requests"| node_evaluation
node_rag -->|"records usage"| node_analytics
node_indexing -->|"records ingestion usage"| node_analytics

click node_frontend "https://github.com/technoritesh152005/rag/blob/main/Frontend/src/App.jsx"
click node_workspace_ui "https://github.com/technoritesh152005/rag/blob/main/Frontend/src/pages/WorkspacePage.jsx"
click node_source_ui "https://github.com/technoritesh152005/rag/blob/main/Frontend/src/features/sources/SourcePanel.jsx"
click node_chat_ui "https://github.com/technoritesh152005/rag/blob/main/Frontend/src/features/chat/ChatPanel.jsx"
click node_api "https://github.com/technoritesh152005/rag/blob/main/Backend/src/server.js"
click node_auth "https://github.com/technoritesh152005/rag/blob/main/Backend/src/modules/auth/auth_middleware.js"
click node_workspace "https://github.com/technoritesh152005/rag/blob/main/Backend/src/modules/workspace/workspace_service.js"
click node_sources "https://github.com/technoritesh152005/rag/blob/main/Backend/src/modules/sources/source.service.js"
click node_pdf_upload "https://github.com/technoritesh152005/rag/blob/main/Backend/src/modules/sources/pdf-upload.routes.js"
click node_storage "https://github.com/technoritesh152005/rag/blob/main/Backend/src/lib/supabase.storage.js"
click node_queue "https://github.com/technoritesh152005/rag/blob/main/Backend/src/modules/jobs/queue.js"
click node_worker "https://github.com/technoritesh152005/rag/blob/main/Backend/src/worker/ingestion.worker.js"
click node_extract "https://github.com/technoritesh152005/rag/tree/main/Backend/src/modules"
click node_chunking "https://github.com/technoritesh152005/rag/blob/main/Backend/src/modules/crawler/chunker.service.js"
click node_embedding "https://github.com/technoritesh152005/rag/blob/main/Backend/src/modules/Embeeding/embeeding.service.config.js"
click node_indexing "https://github.com/technoritesh152005/rag/blob/main/Backend/src/modules/jobs/ingestion.job.js"
click node_pinecone "https://github.com/technoritesh152005/rag/blob/main/Backend/src/modules/vector-store/pinecone.service.js"
click node_postgres "https://github.com/technoritesh152005/rag/blob/main/Backend/src/modules/vector-store/fullTextSearch.service.js"
click node_rag "https://github.com/technoritesh152005/rag/blob/main/Backend/src/modules/chat/rag.service.js"
click node_hybrid "https://github.com/technoritesh152005/rag/blob/main/Backend/src/modules/vector-store/hybrid.service.js"
click node_cache "https://github.com/technoritesh152005/rag/tree/main/Backend/src/modules/cache"
click node_groq "https://github.com/technoritesh152005/rag/blob/main/Backend/src/modules/chat/groq.service.js"
click node_gateway "https://github.com/technoritesh152005/rag/blob/main/Backend/src/modules/chat/chat.gateway.js"
click node_faq "https://github.com/technoritesh152005/rag/blob/main/Backend/src/modules/chat/faq.service.js"
click node_analytics "https://github.com/technoritesh152005/rag/blob/main/Backend/src/modules/analytics/usage.service.js"
click node_evaluation "https://github.com/technoritesh152005/rag/blob/main/Backend/src/modules/eval/eval.service.js"

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_workspace_ui,node_source_ui,node_chat_ui,node_user toneBlue
class node_api,node_auth,node_workspace,node_sources,node_pdf_upload,node_storage,node_gateway,node_faq toneAmber
class node_queue,node_worker,node_extract,node_chunking,node_embedding,node_indexing toneMint
class node_pinecone,node_postgres,node_rag,node_hybrid,node_cache,node_groq toneRose
class node_analytics,node_evaluation,node_external_auth,node_sources_ext toneIndigo
```

## Components

### Workspace client

- [React app](https://github.com/technoritesh152005/rag/blob/main/Frontend/src/App.jsx): `Frontend/src/App.jsx`
- [Workspace UI](https://github.com/technoritesh152005/rag/blob/main/Frontend/src/pages/WorkspacePage.jsx): `Frontend/src/pages/WorkspacePage.jsx`
- [Source panel](https://github.com/technoritesh152005/rag/blob/main/Frontend/src/features/sources/SourcePanel.jsx): `Frontend/src/features/sources/SourcePanel.jsx`
- [Chat panel](https://github.com/technoritesh152005/rag/blob/main/Frontend/src/features/chat/ChatPanel.jsx): `Frontend/src/features/chat/ChatPanel.jsx`

### API and workspace

- [Fastify API](https://github.com/technoritesh152005/rag/blob/main/Backend/src/server.js): `Backend/src/server.js`
- [Token authentication](https://github.com/technoritesh152005/rag/blob/main/Backend/src/modules/auth/auth_middleware.js): `Backend/src/modules/auth/auth_middleware.js`
- [Workspace operations](https://github.com/technoritesh152005/rag/blob/main/Backend/src/modules/workspace/workspace_service.js): `Backend/src/modules/workspace/workspace_service.js`
- [Source management](https://github.com/technoritesh152005/rag/blob/main/Backend/src/modules/sources/source.service.js): `Backend/src/modules/sources/source.service.js`
- [PDF upload](https://github.com/technoritesh152005/rag/blob/main/Backend/src/modules/sources/pdf-upload.routes.js): `Backend/src/modules/sources/pdf-upload.routes.js`
- [PDF object storage](https://github.com/technoritesh152005/rag/blob/main/Backend/src/lib/supabase.storage.js): `Backend/src/lib/supabase.storage.js`
- [Realtime gateway](https://github.com/technoritesh152005/rag/blob/main/Backend/src/modules/chat/chat.gateway.js): `Backend/src/modules/chat/chat.gateway.js`
- [Workspace FAQs](https://github.com/technoritesh152005/rag/blob/main/Backend/src/modules/chat/faq.service.js): `Backend/src/modules/chat/faq.service.js`

### Ingestion and indexing

- [Ingestion queue](https://github.com/technoritesh152005/rag/blob/main/Backend/src/modules/jobs/queue.js): `Backend/src/modules/jobs/queue.js`
- [Ingestion worker](https://github.com/technoritesh152005/rag/blob/main/Backend/src/worker/ingestion.worker.js): `Backend/src/worker/ingestion.worker.js`
- [Content extraction](https://github.com/technoritesh152005/rag/tree/main/Backend/src/modules): `Backend/src/modules`
- [Chunking and dedup](https://github.com/technoritesh152005/rag/blob/main/Backend/src/modules/crawler/chunker.service.js): `Backend/src/modules/crawler/chunker.service.js`
- [Local embeddings](https://github.com/technoritesh152005/rag/blob/main/Backend/src/modules/Embeeding/embeeding.service.config.js): `Backend/src/modules/Embeeding/embeeding.service.config.js`
- [Index storage](https://github.com/technoritesh152005/rag/blob/main/Backend/src/modules/jobs/ingestion.job.js): `Backend/src/modules/jobs/ingestion.job.js`

### Retrieval and answers

- [Pinecone vectors](https://github.com/technoritesh152005/rag/blob/main/Backend/src/modules/vector-store/pinecone.service.js): `Backend/src/modules/vector-store/pinecone.service.js`
- [PostgreSQL chunks](https://github.com/technoritesh152005/rag/blob/main/Backend/src/modules/vector-store/fullTextSearch.service.js): `Backend/src/modules/vector-store/fullTextSearch.service.js`
- [RAG orchestration](https://github.com/technoritesh152005/rag/blob/main/Backend/src/modules/chat/rag.service.js): `Backend/src/modules/chat/rag.service.js`
- [Hybrid retrieval](https://github.com/technoritesh152005/rag/blob/main/Backend/src/modules/vector-store/hybrid.service.js): `Backend/src/modules/vector-store/hybrid.service.js`
- [Redis answer caches](https://github.com/technoritesh152005/rag/tree/main/Backend/src/modules/cache): `Backend/src/modules/cache`
- [Groq generation](https://github.com/technoritesh152005/rag/blob/main/Backend/src/modules/chat/groq.service.js): `Backend/src/modules/chat/groq.service.js`

### Evaluation and insights

- [Usage analytics](https://github.com/technoritesh152005/rag/blob/main/Backend/src/modules/analytics/usage.service.js): `Backend/src/modules/analytics/usage.service.js`
- [Evaluation runs](https://github.com/technoritesh152005/rag/blob/main/Backend/src/modules/eval/eval.service.js): `Backend/src/modules/eval/eval.service.js`

### Other components

- **User**
- **Supabase Auth**
- **Web, PDF, video sources**

## Connections

- User → React app: uses (evidence: `README.md`)
- React app → Workspace UI: routes to (evidence: `Frontend/src/App.jsx`)
- Workspace UI → Source panel: renders (evidence: `Frontend/src/pages/WorkspacePage.jsx`)
- Workspace UI → Chat panel: renders (evidence: `Frontend/src/pages/WorkspacePage.jsx`)
- React app → Supabase Auth: authenticates with (evidence: `README.md`)
- React app → Fastify API: HTTP requests (evidence: `README.md`)
- Fastify API → Token authentication: validates access (evidence: `Backend/src/server.js`)
- Token authentication → Supabase Auth: validates token (evidence: `README.md`)
- Fastify API → Workspace operations: routes workspace requests (evidence: `Backend/src/server.js`)
- Source panel → Fastify API: submits sources (evidence: `README.md`)
- Fastify API → Source management: routes source requests (evidence: `Backend/src/server.js`)
- Fastify API → PDF upload: routes PDF uploads (evidence: `Backend/src/server.js`)
- PDF upload → PDF object storage: creates upload URL (evidence: `Backend/src/modules/sources/pdf-upload.routes.js`)
- PDF upload → Ingestion queue: enqueues indexing (evidence: `Backend/src/modules/sources/pdf-upload.routes.js`)
- Web, PDF, video sources → Ingestion queue: submits URLs and videos (evidence: `README.md`)
- PDF object storage → Content extraction: provides PDF (evidence: `README.md`)
- Ingestion queue → Ingestion worker: dispatches jobs (evidence: `Backend/src/worker/ingestion.worker.js`)
- Ingestion worker → Content extraction: crawls source (evidence: `Backend/src/worker/ingestion.worker.js`)
- Content extraction → Chunking and dedup: sections content (evidence: `Backend/src/modules/crawler/crawler.service.js`)
- Ingestion worker → Index storage: sends chunks (evidence: `Backend/src/worker/ingestion.worker.js`)
- Index storage → Local embeddings: embeds chunks (evidence: `Backend/src/modules/jobs/ingestion.job.js`)
- Index storage → Pinecone vectors: upserts vectors (evidence: `Backend/src/modules/jobs/ingestion.job.js`)
- Index storage → PostgreSQL chunks: stores searchable chunks (evidence: `Backend/src/modules/jobs/ingestion.job.js`)
- Chat panel → Fastify API: sends questions (evidence: `README.md`)
- Fastify API → RAG orchestration: dispatches chat
- RAG orchestration → Local embeddings: embeds question (evidence: `Backend/src/modules/chat/rag.service.js`)
- RAG orchestration → Redis answer caches: checks and stores answers (evidence: `Backend/src/modules/chat/rag.service.js`)
- RAG orchestration → Hybrid retrieval: requests retrieval (evidence: `Backend/src/modules/chat/rag.service.js`)
- Hybrid retrieval → Pinecone vectors: searches vectors (evidence: `Backend/src/modules/vector-store/hybrid.service.js`)
- Hybrid retrieval → PostgreSQL chunks: searches keywords (evidence: `Backend/src/modules/vector-store/hybrid.service.js`)
- RAG orchestration → Groq generation: streams generation (evidence: `Backend/src/modules/chat/rag.service.js`)
- RAG orchestration → Realtime gateway: streams cited answers (evidence: `README.md`)
- Realtime gateway → React app: streams chat and status (evidence: `README.md`)
- Ingestion worker → Realtime gateway: publishes source progress (evidence: `README.md`)
- Fastify API → Workspace FAQs: serves FAQ requests (evidence: `Backend/src/server.js`)
- Workspace UI → Evaluation runs: runs evaluations (evidence: `Frontend/src/pages/WorkspacePage.jsx`)
- Fastify API → Evaluation runs: routes evaluation requests
- RAG orchestration → Usage analytics: records usage (evidence: `Backend/src/modules/chat/rag.service.js`)
- Index storage → Usage analytics: records ingestion usage (evidence: `Backend/src/modules/jobs/ingestion.job.js`)
