# sanika-gajarishi/ai-customer-support--rag architecture

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

- Interactive diagram: https://gitdiagram.com/sanika-gajarishi/ai-customer-support--rag
- Repository: https://github.com/sanika-gajarishi/ai-customer-support--rag

## Overview

ShopEase is a customer-support application with a Streamlit UI and FastAPI backend. Customers authenticate, ask policy questions, review conversation history, submit feedback, and manage support tickets; administrators monitor usage, manage policy files, rebuild the knowledge base, and update tickets. The chat handler owns conversation persistence and calls RAG, which retrieves policy context before generating an answer. Admin-triggered ingestion extracts and chunks documents, embeds them, and persists a FAISS index. The graph follows README-documented capabilities and sampled calls; unsampled internals are not inferred.

Main entry points: [`backend/app/database.py`](https://github.com/sanika-gajarishi/ai-customer-support--rag/blob/main/backend/app/database.py) (Database sessions), [`backend/app/main.py`](https://github.com/sanika-gajarishi/ai-customer-support--rag/blob/main/backend/app/main.py) (FastAPI app), [`backend/app/api/admin.py`](https://github.com/sanika-gajarishi/ai-customer-support--rag/blob/main/backend/app/api/admin.py) (Admin API), [`backend/app/api/chat.py`](https://github.com/sanika-gajarishi/ai-customer-support--rag/blob/main/backend/app/api/chat.py) (Chat handler)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["User interface"]
  node_frontend["Streamlit interface<br/>[app.py]"]
end

subgraph group_api["API and identity"]
  node_fastapi["FastAPI app<br/>[main.py]"]
  node_auth_api["Registration and login<br/>[auth.py]"]
  node_security["Token authorization<br/>[security.py]"]
  node_chat_api["Chat handler<br/>[chat.py]"]
  node_history_api["History API<br/>[history.py]"]
  node_feedback_api["Feedback API<br/>[feedback.py]"]
  node_admin_api["Admin API<br/>[admin.py]"]
  node_ticket_api["Ticket API<br/>[tickets.py]"]
end

subgraph group_knowledge["Knowledge and answers"]
  node_rag["RAG answer service<br/>[rag_service.py]"]
  node_document_processing["Document extraction and chunking"]
  node_ingestion["Index ingestion<br/>[ingest_service.py]"]
  node_embeddings["Embeddings and vector store"]
  node_llm["Answer generation<br/>[llm_service.py]"]
  node_policy_files["Policy documents"]
  node_faiss[("FAISS index")]
end

subgraph group_records["Support records"]
  node_models["Persistence models<br/>[models.py]"]
  node_database_config["Database sessions<br/>[database.py]"]
  node_postgres[("PostgreSQL")]
end

node_customer(("Customer"))
node_admin_actor(("Administrator"))
node_gemini(("Gemini<br/>external service"))

node_customer -->|"uses"| node_frontend
node_admin_actor -->|"uses"| node_frontend
node_frontend -->|"sends HTTP requests"| node_fastapi
node_fastapi -->|"registers routes"| node_auth_api
node_fastapi -->|"registers routes"| node_chat_api
node_fastapi -->|"registers routes"| node_history_api
node_fastapi -->|"registers routes"| node_feedback_api
node_fastapi -->|"registers routes"| node_admin_api
node_fastapi -->|"registers routes"| node_ticket_api
node_auth_api -->|"creates tokens"| node_security
node_auth_api -->|"gets sessions"| node_database_config
node_chat_api -->|"checks user"| node_security
node_chat_api -->|"requests answer"| node_rag
node_chat_api -->|"reads and writes"| node_database_config
node_history_api -->|"reads history"| node_database_config
node_feedback_api -->|"stores feedback"| node_database_config
node_admin_api -->|"checks admin"| node_security
node_admin_api -->|"reads summary"| node_database_config
node_admin_api -->|"manages files"| node_policy_files
node_admin_api -->|"triggers rebuild"| node_ingestion
node_ticket_api -->|"checks access"| node_security
node_ticket_api -->|"reads and writes"| node_database_config
node_database_config -->|"connects"| node_postgres
node_database_config -->|"provides base"| node_models
node_ingestion -->|"loads and splits"| node_document_processing
node_ingestion -->|"builds index"| node_embeddings
node_ingestion -->|"ingests documents"| node_policy_files
node_embeddings -->|"persists index"| node_faiss
node_rag -->|"loads and searches"| node_embeddings
node_rag -->|"generates answer"| node_llm
node_llm -->|"requests generation"| node_gemini
node_rag -->|"retrieves context"| node_faiss

click node_frontend "https://github.com/sanika-gajarishi/ai-customer-support--rag/blob/main/frontend/app.py"
click node_fastapi "https://github.com/sanika-gajarishi/ai-customer-support--rag/blob/main/backend/app/main.py"
click node_auth_api "https://github.com/sanika-gajarishi/ai-customer-support--rag/blob/main/backend/app/api/auth.py"
click node_security "https://github.com/sanika-gajarishi/ai-customer-support--rag/blob/main/backend/app/security.py"
click node_chat_api "https://github.com/sanika-gajarishi/ai-customer-support--rag/blob/main/backend/app/api/chat.py"
click node_history_api "https://github.com/sanika-gajarishi/ai-customer-support--rag/blob/main/backend/app/api/history.py"
click node_feedback_api "https://github.com/sanika-gajarishi/ai-customer-support--rag/blob/main/backend/app/api/feedback.py"
click node_admin_api "https://github.com/sanika-gajarishi/ai-customer-support--rag/blob/main/backend/app/api/admin.py"
click node_ticket_api "https://github.com/sanika-gajarishi/ai-customer-support--rag/blob/main/backend/app/api/tickets.py"
click node_rag "https://github.com/sanika-gajarishi/ai-customer-support--rag/blob/main/backend/app/services/rag_service.py"
click node_document_processing "https://github.com/sanika-gajarishi/ai-customer-support--rag/blob/main/backend/app/services/document_service.py"
click node_ingestion "https://github.com/sanika-gajarishi/ai-customer-support--rag/blob/main/backend/app/services/ingest_service.py"
click node_embeddings "https://github.com/sanika-gajarishi/ai-customer-support--rag/blob/main/backend/app/services/embedding_service.py"
click node_llm "https://github.com/sanika-gajarishi/ai-customer-support--rag/blob/main/backend/app/services/llm_service.py"
click node_policy_files "https://github.com/sanika-gajarishi/ai-customer-support--rag/tree/main/backend/data/documents"
click node_faiss "https://github.com/sanika-gajarishi/ai-customer-support--rag/tree/main/backend/data"
click node_models "https://github.com/sanika-gajarishi/ai-customer-support--rag/blob/main/backend/app/models.py"
click node_database_config "https://github.com/sanika-gajarishi/ai-customer-support--rag/blob/main/backend/app/database.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_frontend toneBlue
class node_fastapi,node_auth_api,node_security,node_chat_api,node_history_api,node_feedback_api,node_admin_api,node_ticket_api toneAmber
class node_rag,node_document_processing,node_ingestion,node_embeddings,node_llm,node_policy_files,node_faiss toneMint
class node_models,node_database_config,node_postgres toneRose
class node_customer,node_admin_actor,node_gemini toneIndigo
```

## Components

### User interface

- [Streamlit interface](https://github.com/sanika-gajarishi/ai-customer-support--rag/blob/main/frontend/app.py): `frontend/app.py`

### API and identity

- [FastAPI app](https://github.com/sanika-gajarishi/ai-customer-support--rag/blob/main/backend/app/main.py): `backend/app/main.py`
- [Registration and login](https://github.com/sanika-gajarishi/ai-customer-support--rag/blob/main/backend/app/api/auth.py): `backend/app/api/auth.py`
- [Token authorization](https://github.com/sanika-gajarishi/ai-customer-support--rag/blob/main/backend/app/security.py): `backend/app/security.py`
- [Chat handler](https://github.com/sanika-gajarishi/ai-customer-support--rag/blob/main/backend/app/api/chat.py): `backend/app/api/chat.py`
- [History API](https://github.com/sanika-gajarishi/ai-customer-support--rag/blob/main/backend/app/api/history.py): `backend/app/api/history.py`
- [Feedback API](https://github.com/sanika-gajarishi/ai-customer-support--rag/blob/main/backend/app/api/feedback.py): `backend/app/api/feedback.py`
- [Admin API](https://github.com/sanika-gajarishi/ai-customer-support--rag/blob/main/backend/app/api/admin.py): `backend/app/api/admin.py`
- [Ticket API](https://github.com/sanika-gajarishi/ai-customer-support--rag/blob/main/backend/app/api/tickets.py): `backend/app/api/tickets.py`

### Knowledge and answers

- [RAG answer service](https://github.com/sanika-gajarishi/ai-customer-support--rag/blob/main/backend/app/services/rag_service.py): `backend/app/services/rag_service.py`
- [Document extraction and chunking](https://github.com/sanika-gajarishi/ai-customer-support--rag/blob/main/backend/app/services/document_service.py): `backend/app/services/document_service.py`
- [Index ingestion](https://github.com/sanika-gajarishi/ai-customer-support--rag/blob/main/backend/app/services/ingest_service.py): `backend/app/services/ingest_service.py`
- [Embeddings and vector store](https://github.com/sanika-gajarishi/ai-customer-support--rag/blob/main/backend/app/services/embedding_service.py): `backend/app/services/embedding_service.py`
- [Answer generation](https://github.com/sanika-gajarishi/ai-customer-support--rag/blob/main/backend/app/services/llm_service.py): `backend/app/services/llm_service.py`
- [Policy documents](https://github.com/sanika-gajarishi/ai-customer-support--rag/tree/main/backend/data/documents): `backend/data/documents`
- [FAISS index](https://github.com/sanika-gajarishi/ai-customer-support--rag/tree/main/backend/data): `backend/data`

### Support records

- [Persistence models](https://github.com/sanika-gajarishi/ai-customer-support--rag/blob/main/backend/app/models.py): `backend/app/models.py`
- [Database sessions](https://github.com/sanika-gajarishi/ai-customer-support--rag/blob/main/backend/app/database.py): `backend/app/database.py`
- **PostgreSQL**

### Other components

- **Customer**
- **Administrator**
- **Gemini**: external service

## Connections

- Customer → Streamlit interface: uses (evidence: `README.md`)
- Administrator → Streamlit interface: uses (evidence: `README.md`)
- Streamlit interface → FastAPI app: sends HTTP requests (evidence: `README.md`)
- FastAPI app → Registration and login: registers routes (evidence: `backend/app/main.py`)
- FastAPI app → Chat handler: registers routes (evidence: `backend/app/main.py`)
- FastAPI app → History API: registers routes (evidence: `backend/app/main.py`)
- FastAPI app → Feedback API: registers routes (evidence: `backend/app/main.py`)
- FastAPI app → Admin API: registers routes (evidence: `backend/app/main.py`)
- FastAPI app → Ticket API: registers routes (evidence: `backend/app/main.py`)
- Registration and login → Token authorization: creates tokens (evidence: `backend/app/api/auth.py`)
- Registration and login → Database sessions: gets sessions (evidence: `backend/app/api/auth.py`)
- Chat handler → Token authorization: checks user (evidence: `backend/app/api/chat.py`)
- Chat handler → RAG answer service: requests answer (evidence: `backend/app/api/chat.py`)
- Chat handler → Database sessions: reads and writes (evidence: `backend/app/api/chat.py`)
- History API → Database sessions: reads history (evidence: `backend/app/api/history.py`)
- Feedback API → Database sessions: stores feedback (evidence: `backend/app/api/feedback.py`)
- Admin API → Token authorization: checks admin (evidence: `backend/app/api/admin.py`)
- Admin API → Database sessions: reads summary (evidence: `backend/app/api/admin.py`)
- Admin API → Policy documents: manages files (evidence: `backend/app/api/admin.py`)
- Admin API → Index ingestion: triggers rebuild (evidence: `backend/app/api/admin.py`)
- Ticket API → Token authorization: checks access (evidence: `backend/app/api/tickets.py`)
- Ticket API → Database sessions: reads and writes (evidence: `backend/app/api/tickets.py`)
- Database sessions → PostgreSQL: connects (evidence: `README.md`)
- Database sessions → Persistence models: provides base (evidence: `backend/app/models.py`)
- Index ingestion → Document extraction and chunking: loads and splits (evidence: `backend/app/services/ingest_service.py`)
- Index ingestion → Embeddings and vector store: builds index (evidence: `backend/app/services/ingest_service.py`)
- Index ingestion → Policy documents: ingests documents (evidence: `README.md`)
- Embeddings and vector store → FAISS index: persists index (evidence: `README.md`)
- RAG answer service → Embeddings and vector store: loads and searches (evidence: `backend/app/services/rag_service.py`)
- RAG answer service → Answer generation: generates answer (evidence: `backend/app/services/rag_service.py`)
- Answer generation → Gemini: requests generation (evidence: `README.md`)
- RAG answer service → FAISS index: retrieves context (evidence: `README.md`)
