# srinivas626/enterprise-rag-chatbot architecture

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

## Overview

This FastAPI application supports authenticated PDF ingestion and question answering over an indexed document collection. Uploads are processed into chunks, embedded, and stored in a FAISS vector store; chat questions enter a LangGraph workflow that uses retrieval and an LLM. OAuth login, session-based user checks, and user records support the protected endpoints. The excerpts show ingestion, storage, authentication, and application wiring; the graph and chat implementation were not excerpted, so their internal links rely on the SOURCE INDEX references rather than inspected call details.

Main entry points: [`app/services/document_service.py`](https://github.com/srinivas626/enterprise-rag-chatbot/blob/main/app/services/document_service.py) (Document ingestion), [`app/api/auth.py`](https://github.com/srinivas626/enterprise-rag-chatbot/blob/main/app/api/auth.py) (Auth endpoints), [`app/main.py`](https://github.com/srinivas626/enterprise-rag-chatbot/blob/main/app/main.py) (FastAPI application), [`app/api/upload.py`](https://github.com/srinivas626/enterprise-rag-chatbot/blob/main/app/api/upload.py) (Upload endpoint)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["HTTP API"]
  node_app["FastAPI application<br/>[main.py]"]
  node_upload_api["Upload endpoint<br/>[upload.py]"]
  node_chat_api["Chat endpoint<br/>[chat.py]"]
end

subgraph group_identity["Identity and Accounts"]
  node_auth_api["Auth endpoints<br/>[auth.py]"]
  node_auth_guard["Session user guard<br/>[dependencies.py]"]
  node_oauth["OAuth clients<br/>[oauth.py]"]
  node_user_model["User records<br/>[user.py]"]
end

subgraph group_knowledge["Document and Retrieval"]
  node_document_service["Document ingestion"]
  node_loader["PDF loader<br/>[loader.py]"]
  node_splitter["Document splitter<br/>[splitter.py]"]
  node_embeddings["Embedding model<br/>[embeddings.py]"]
  node_retriever["Vector retriever<br/>[retriever.py]"]
end

subgraph group_answering["Question Answering"]
  node_rag_service["Question service<br/>[rag_service.py]"]
  node_rag_graph["RAG conversation graph<br/>[graph.py]"]
  node_llm["Language model<br/>[llm.py]"]
end

subgraph group_persistence["Persistence"]
  node_db["Database session<br/>[db.py]"]
  node_storage[("Vector and file storage<br/>[storage.py]")]
end

node_user(("User"))
node_s3[("S3 bucket")]
node_oauth_providers(("OAuth providers"))

node_user -->|"uploads PDF"| node_upload_api
node_user -->|"asks questions"| node_chat_api
node_user -->|"signs in"| node_auth_api
node_app -->|"registers router"| node_upload_api
node_app -->|"registers router"| node_chat_api
node_app -->|"registers router"| node_auth_api
node_upload_api -->|"requires user"| node_auth_guard
node_chat_api -->|"requires user"| node_auth_guard
node_upload_api -->|"ingests document"| node_document_service
node_document_service -->|"loads PDF"| node_loader
node_document_service -->|"splits documents"| node_splitter
node_document_service -->|"embeds chunks"| node_embeddings
node_document_service -->|"syncs index and file"| node_storage
node_retriever -->|"downloads index"| node_storage
node_retriever -->|"loads embeddings"| node_embeddings
node_storage -->|"syncs files"| node_s3
node_chat_api -->|"asks question"| node_rag_service
node_rag_service -->|"invokes graph"| node_rag_graph
node_rag_graph -->|"uses retrieval"| node_retriever
node_rag_graph -->|"uses language model"| node_llm
node_auth_api -->|"creates OAuth client"| node_oauth
node_oauth -->|"registers providers"| node_oauth_providers
node_auth_api -->|"gets database session"| node_db
node_auth_api -->|"queries and creates"| node_user_model
node_auth_guard -->|"gets database session"| node_db
node_auth_guard -->|"loads user"| node_user_model
node_user_model -->|"uses ORM base"| node_db
node_app -->|"creates tables"| node_db

click node_app "https://github.com/srinivas626/enterprise-rag-chatbot/blob/main/app/main.py"
click node_upload_api "https://github.com/srinivas626/enterprise-rag-chatbot/blob/main/app/api/upload.py"
click node_chat_api "https://github.com/srinivas626/enterprise-rag-chatbot/blob/main/app/api/chat.py"
click node_auth_api "https://github.com/srinivas626/enterprise-rag-chatbot/blob/main/app/api/auth.py"
click node_auth_guard "https://github.com/srinivas626/enterprise-rag-chatbot/blob/main/app/auth/dependencies.py"
click node_oauth "https://github.com/srinivas626/enterprise-rag-chatbot/blob/main/app/auth/oauth.py"
click node_user_model "https://github.com/srinivas626/enterprise-rag-chatbot/blob/main/app/models/user.py"
click node_db "https://github.com/srinivas626/enterprise-rag-chatbot/blob/main/app/db.py"
click node_document_service "https://github.com/srinivas626/enterprise-rag-chatbot/blob/main/app/services/document_service.py"
click node_loader "https://github.com/srinivas626/enterprise-rag-chatbot/blob/main/app/rag/loader.py"
click node_splitter "https://github.com/srinivas626/enterprise-rag-chatbot/blob/main/app/rag/splitter.py"
click node_embeddings "https://github.com/srinivas626/enterprise-rag-chatbot/blob/main/app/rag/embeddings.py"
click node_retriever "https://github.com/srinivas626/enterprise-rag-chatbot/blob/main/app/rag/retriever.py"
click node_storage "https://github.com/srinivas626/enterprise-rag-chatbot/blob/main/app/rag/storage.py"
click node_rag_service "https://github.com/srinivas626/enterprise-rag-chatbot/blob/main/app/services/rag_service.py"
click node_rag_graph "https://github.com/srinivas626/enterprise-rag-chatbot/blob/main/app/rag/graph.py"
click node_llm "https://github.com/srinivas626/enterprise-rag-chatbot/blob/main/app/rag/llm.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_upload_api,node_chat_api,node_user toneBlue
class node_auth_api,node_auth_guard,node_oauth,node_user_model,node_s3 toneAmber
class node_document_service,node_loader,node_splitter,node_embeddings,node_retriever toneMint
class node_rag_service,node_rag_graph,node_llm toneRose
class node_db,node_storage,node_oauth_providers toneIndigo
```

## Components

### HTTP API

- [FastAPI application](https://github.com/srinivas626/enterprise-rag-chatbot/blob/main/app/main.py): `app/main.py`
- [Upload endpoint](https://github.com/srinivas626/enterprise-rag-chatbot/blob/main/app/api/upload.py): `app/api/upload.py`
- [Chat endpoint](https://github.com/srinivas626/enterprise-rag-chatbot/blob/main/app/api/chat.py): `app/api/chat.py`

### Identity and Accounts

- [Auth endpoints](https://github.com/srinivas626/enterprise-rag-chatbot/blob/main/app/api/auth.py): `app/api/auth.py`
- [Session user guard](https://github.com/srinivas626/enterprise-rag-chatbot/blob/main/app/auth/dependencies.py): `app/auth/dependencies.py`
- [OAuth clients](https://github.com/srinivas626/enterprise-rag-chatbot/blob/main/app/auth/oauth.py): `app/auth/oauth.py`
- [User records](https://github.com/srinivas626/enterprise-rag-chatbot/blob/main/app/models/user.py): `app/models/user.py`

### Document and Retrieval

- [Document ingestion](https://github.com/srinivas626/enterprise-rag-chatbot/blob/main/app/services/document_service.py): `app/services/document_service.py`
- [PDF loader](https://github.com/srinivas626/enterprise-rag-chatbot/blob/main/app/rag/loader.py): `app/rag/loader.py`
- [Document splitter](https://github.com/srinivas626/enterprise-rag-chatbot/blob/main/app/rag/splitter.py): `app/rag/splitter.py`
- [Embedding model](https://github.com/srinivas626/enterprise-rag-chatbot/blob/main/app/rag/embeddings.py): `app/rag/embeddings.py`
- [Vector retriever](https://github.com/srinivas626/enterprise-rag-chatbot/blob/main/app/rag/retriever.py): `app/rag/retriever.py`

### Question Answering

- [Question service](https://github.com/srinivas626/enterprise-rag-chatbot/blob/main/app/services/rag_service.py): `app/services/rag_service.py`
- [RAG conversation graph](https://github.com/srinivas626/enterprise-rag-chatbot/blob/main/app/rag/graph.py): `app/rag/graph.py`
- [Language model](https://github.com/srinivas626/enterprise-rag-chatbot/blob/main/app/rag/llm.py): `app/rag/llm.py`

### Persistence

- [Database session](https://github.com/srinivas626/enterprise-rag-chatbot/blob/main/app/db.py): `app/db.py`
- [Vector and file storage](https://github.com/srinivas626/enterprise-rag-chatbot/blob/main/app/rag/storage.py): `app/rag/storage.py`

### Other components

- **User**
- **S3 bucket**
- **OAuth providers**

## Connections

- User → Upload endpoint: uploads PDF (evidence: `app/api/upload.py`)
- User → Chat endpoint: asks questions (evidence: `app/api/chat.py`)
- User → Auth endpoints: signs in (evidence: `app/api/auth.py`)
- FastAPI application → Upload endpoint: registers router (evidence: `app/main.py`)
- FastAPI application → Chat endpoint: registers router (evidence: `app/main.py`)
- FastAPI application → Auth endpoints: registers router (evidence: `app/main.py`)
- Upload endpoint → Session user guard: requires user (evidence: `app/api/upload.py`)
- Chat endpoint → Session user guard: requires user (evidence: `app/api/chat.py`)
- Upload endpoint → Document ingestion: ingests document (evidence: `app/api/upload.py`)
- Document ingestion → PDF loader: loads PDF (evidence: `app/services/document_service.py`)
- Document ingestion → Document splitter: splits documents (evidence: `app/services/document_service.py`)
- Document ingestion → Embedding model: embeds chunks (evidence: `app/services/document_service.py`)
- Document ingestion → Vector and file storage: syncs index and file (evidence: `app/services/document_service.py`)
- Vector retriever → Vector and file storage: downloads index (evidence: `app/rag/retriever.py`)
- Vector retriever → Embedding model: loads embeddings (evidence: `app/rag/retriever.py`)
- Vector and file storage → S3 bucket: syncs files (evidence: `app/rag/storage.py`)
- Chat endpoint → Question service: asks question (evidence: `app/api/chat.py`)
- Question service → RAG conversation graph: invokes graph (evidence: `app/services/rag_service.py`)
- RAG conversation graph → Vector retriever: uses retrieval (evidence: `app/rag/graph.py`)
- RAG conversation graph → Language model: uses language model (evidence: `app/rag/graph.py`)
- Auth endpoints → OAuth clients: creates OAuth client (evidence: `app/api/auth.py`)
- OAuth clients → OAuth providers: registers providers (evidence: `app/auth/oauth.py`)
- Auth endpoints → Database session: gets database session (evidence: `app/api/auth.py`)
- Auth endpoints → User records: queries and creates (evidence: `app/api/auth.py`)
- Session user guard → Database session: gets database session (evidence: `app/auth/dependencies.py`)
- Session user guard → User records: loads user (evidence: `app/auth/dependencies.py`)
- User records → Database session: uses ORM base (evidence: `app/models/user.py`)
- FastAPI application → Database session: creates tables (evidence: `app/main.py`)
