# jasirahamed786/infosys-rag-project architecture

> Architecture diagram of the GitHub repository jasirahamed786/infosys-rag-project, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-17). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/jasirahamed786/infosys-rag-project
- Repository: https://github.com/jasirahamed786/infosys-rag-project

## Overview

#### Purpose and Entry Points
Clario is a real-time customer-support coaching system. A React agent console submits conversation turns to a FastAPI backend, which executes AI analysis and returns coaching artifacts. Backend entry point: `backend/app/main.py`; frontend bootstrap and root UI: `frontend/src/main.tsx`, `frontend/src/App.tsx`.

#### API and Session Boundary
FastAPI registers domain routers for conversation processing, session lifecycle, knowledge ingestion, simulator operation, coaching, escalation, analytics, and reports. Request/response and persistence-facing schemas are centralized in `backend/app/models/schemas.py`. Key API surfaces are organized in `backend/app/routers/conversation.py`, `backend/app/routers/sessions.py`, and `backend/app/routers/knowledge.py`.

#### Turn Orchestration Pipeline
`backend/app/orchestration/pipeline.py` is the central control-flow boundary for a conversation turn. It composes specialized agents, isolates failures through fallbacks, and aggregates outputs for the live console. The staged flow is: incoming customer message → intent/sentiment classification → conditional RAG retrieval → coaching recommendation → escalation assessment; simulator mode additionally generates the next customer message.

#### Specialized AI Agents
Agent responsibilities are split by concern rather than embedded in route handlers:
- Intent, sentiment, and frustration classification: `backend/app/agents/intent_sentiment_agent.py`
- Knowledge-grounded retrieval decisions: `backend/app/agents/knowledge_agent.py`
- Suggested agent response and communication feedback: `backend/app/agents/coaching_agent.py`
- Cross-turn escalation risk and recommended action: `backend/app/agents/escalation_agent.py`
- Simulated customer turns for practice mode: `backend/app/agents/simulator_agent.py`
- Future/post-session summarization capability: `backend/app/agents/summary_agent.py`

Groq/Llama is used for intent and simulation; Google Gemini serves knowledge, coaching, and escalation functions through the shared LLM boundary in `backend/app/utils/llm_client.py`.

#### Persistence and Knowledge Retrieval
MongoDB persists sessions, messages, and report-oriented data through `backend/app/services/mongo.py`. RAG ingestion/retrieval is separated in `backend/app/services/rag.py`, backed by local persisted ChromaDB data at `backend/chroma_data/chroma.sqlite3`. This separates durable operational conversation state (MongoDB) from semantic knowledge indexing (ChromaDB). Runtime credentials and service configuration are environment-driven via `backend/app/core/config.py` and `.env.example`.

#### Frontend Session Experience
The frontend is a Vite React 18/TypeScript SPA. `frontend/src/context/SessionContext.tsx` holds active conversation state and accumulated pipeline output above navigation, so state survives movement between session configuration and live views. `frontend/src/services/api.ts` is the frontend/backend contract boundary. Primary operational screens are `frontend/src/pages/SessionConfig.tsx`, `frontend/src/pages/LiveConsole.tsx`, and `frontend/src/pages/KnowledgeBaseUpload.tsx`.

#### Runtime and External Dependencies
The deployable runtime is a Python FastAPI server (typically Uvicorn on port 8000) plus a Node/Vite frontend (typically port 5173). Material external services are MongoDB, Groq, and Google Gemini. ChromaDB is locally persisted under `backend/chroma_data/`; no separate web-server or queue infrastructure is evidenced by the repository tree.

Main entry points: [`backend/app/orchestration/pipeline.py`](https://github.com/jasirahamed786/infosys-rag-project/blob/master/backend/app/orchestration/pipeline.py) (Turn pipeline), [`backend/app/utils/llm_client.py`](https://github.com/jasirahamed786/infosys-rag-project/blob/master/backend/app/utils/llm_client.py) (LLM client), [`backend/app/routers/conversation.py`](https://github.com/jasirahamed786/infosys-rag-project/blob/master/backend/app/routers/conversation.py) (Domain routers), [`frontend/src/App.tsx`](https://github.com/jasirahamed786/infosys-rag-project/blob/master/frontend/src/App.tsx) (Root UI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["React SPA"]
  node_frontend_bootstrap["App bootstrap<br/>Vite React entry<br/>[main.tsx]"]
  node_app_shell["Root UI<br/>React application<br/>[App.tsx]"]
  node_session_context["Session state<br/>React context<br/>[SessionContext.tsx]"]
  node_operational_screens["Session &amp; live screens<br/>React pages<br/>[SessionConfig.tsx]"]
  node_knowledge_upload["Knowledge upload<br/>React page"]
  node_frontend_api["API client<br/>frontend contract<br/>[api.ts]"]
end

subgraph group_api["FastAPI backend"]
  node_fastapi_app["FastAPI entry<br/>Python server<br/>[main.py]"]
  node_domain_routers["Domain routers<br/>HTTP API<br/>[conversation.py]"]
  node_schemas["Shared schemas<br/>API and persistence models<br/>[schemas.py]"]
end

subgraph group_ai["AI pipeline"]
  node_turn_pipeline{{"Turn pipeline<br/>orchestrator<br/>[pipeline.py]"}}
  node_intent_agent["Intent &amp; sentiment<br/>AI agent"]
  node_knowledge_agent["Knowledge retrieval<br/>AI agent<br/>[knowledge_agent.py]"]
  node_coaching_agent["Coaching<br/>AI agent<br/>[coaching_agent.py]"]
  node_escalation_agent["Escalation assessment<br/>AI agent"]
  node_simulator_agent["Customer simulator<br/>AI agent<br/>[simulator_agent.py]"]
  node_llm_client["LLM client<br/>provider boundary<br/>[llm_client.py]"]
end

subgraph group_data["Data &amp; external services"]
  node_mongo_service["Mongo persistence<br/>data service<br/>[mongo.py]"]
  node_mongodb[("MongoDB<br/>operational datastore")]
  node_rag_service["RAG service<br/>knowledge indexing and retrieval<br/>[rag.py]"]
  node_chromadb[("ChromaDB index<br/>local vector store<br/>[chroma.sqlite3]")]
  node_llm_providers(("Groq &amp; Gemini<br/>external LLM providers"))
end

node_frontend_bootstrap -->|"mounts"| node_app_shell
node_app_shell -->|"provides state"| node_session_context
node_session_context -->|"supplies session state"| node_operational_screens
node_app_shell -->|"renders"| node_knowledge_upload
node_operational_screens -->|"submits turns"| node_frontend_api
node_knowledge_upload -->|"uploads knowledge"| node_frontend_api
node_frontend_api -->|"HTTP"| node_fastapi_app
node_fastapi_app -->|"registers"| node_domain_routers
node_domain_routers -->|"validates with"| node_schemas
node_domain_routers -->|"processes turns"| node_turn_pipeline
node_domain_routers -->|"session lifecycle"| node_mongo_service
node_domain_routers -->|"knowledge ingestion"| node_rag_service
node_turn_pipeline -->|"classifies"| node_intent_agent
node_turn_pipeline -.->|"retrieves conditionally"| node_knowledge_agent
node_turn_pipeline -->|"recommends"| node_coaching_agent
node_turn_pipeline -->|"assesses"| node_escalation_agent
node_turn_pipeline -.->|"practice mode"| node_simulator_agent
node_turn_pipeline -->|"persists turn data"| node_mongo_service
node_knowledge_agent -->|"queries"| node_rag_service
node_rag_service -->|"indexes and retrieves"| node_chromadb
node_mongo_service -->|"stores"| node_mongodb
node_intent_agent -->|"LLM call"| node_llm_client
node_knowledge_agent -->|"LLM call"| node_llm_client
node_coaching_agent -->|"LLM call"| node_llm_client
node_escalation_agent -->|"LLM call"| node_llm_client
node_simulator_agent -->|"LLM call"| node_llm_client
node_llm_client -->|"provider requests"| node_llm_providers

click node_frontend_bootstrap "https://github.com/jasirahamed786/infosys-rag-project/blob/master/frontend/src/main.tsx"
click node_app_shell "https://github.com/jasirahamed786/infosys-rag-project/blob/master/frontend/src/App.tsx"
click node_session_context "https://github.com/jasirahamed786/infosys-rag-project/blob/master/frontend/src/context/SessionContext.tsx"
click node_operational_screens "https://github.com/jasirahamed786/infosys-rag-project/blob/master/frontend/src/pages/SessionConfig.tsx"
click node_knowledge_upload "https://github.com/jasirahamed786/infosys-rag-project/blob/master/frontend/src/pages/KnowledgeBaseUpload.tsx"
click node_frontend_api "https://github.com/jasirahamed786/infosys-rag-project/blob/master/frontend/src/services/api.ts"
click node_fastapi_app "https://github.com/jasirahamed786/infosys-rag-project/blob/master/backend/app/main.py"
click node_domain_routers "https://github.com/jasirahamed786/infosys-rag-project/blob/master/backend/app/routers/conversation.py"
click node_schemas "https://github.com/jasirahamed786/infosys-rag-project/blob/master/backend/app/models/schemas.py"
click node_turn_pipeline "https://github.com/jasirahamed786/infosys-rag-project/blob/master/backend/app/orchestration/pipeline.py"
click node_intent_agent "https://github.com/jasirahamed786/infosys-rag-project/blob/master/backend/app/agents/intent_sentiment_agent.py"
click node_knowledge_agent "https://github.com/jasirahamed786/infosys-rag-project/blob/master/backend/app/agents/knowledge_agent.py"
click node_coaching_agent "https://github.com/jasirahamed786/infosys-rag-project/blob/master/backend/app/agents/coaching_agent.py"
click node_escalation_agent "https://github.com/jasirahamed786/infosys-rag-project/blob/master/backend/app/agents/escalation_agent.py"
click node_simulator_agent "https://github.com/jasirahamed786/infosys-rag-project/blob/master/backend/app/agents/simulator_agent.py"
click node_llm_client "https://github.com/jasirahamed786/infosys-rag-project/blob/master/backend/app/utils/llm_client.py"
click node_mongo_service "https://github.com/jasirahamed786/infosys-rag-project/blob/master/backend/app/services/mongo.py"
click node_rag_service "https://github.com/jasirahamed786/infosys-rag-project/blob/master/backend/app/services/rag.py"
click node_chromadb "https://github.com/jasirahamed786/infosys-rag-project/blob/master/backend/chroma_data/chroma.sqlite3"

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_bootstrap,node_app_shell,node_session_context,node_operational_screens,node_knowledge_upload,node_frontend_api toneBlue
class node_fastapi_app,node_domain_routers,node_schemas toneAmber
class node_turn_pipeline,node_intent_agent,node_knowledge_agent,node_coaching_agent,node_escalation_agent,node_simulator_agent,node_llm_client toneMint
class node_mongo_service,node_mongodb,node_rag_service,node_chromadb,node_llm_providers toneRose
```

## Components

### React SPA

- [App bootstrap](https://github.com/jasirahamed786/infosys-rag-project/blob/master/frontend/src/main.tsx): Vite React entry · `frontend/src/main.tsx`
- [Root UI](https://github.com/jasirahamed786/infosys-rag-project/blob/master/frontend/src/App.tsx): React application · `frontend/src/App.tsx`
- [Session state](https://github.com/jasirahamed786/infosys-rag-project/blob/master/frontend/src/context/SessionContext.tsx): React context · Retains active session and pipeline output across views. · `frontend/src/context/SessionContext.tsx`
- [Session & live screens](https://github.com/jasirahamed786/infosys-rag-project/blob/master/frontend/src/pages/SessionConfig.tsx): React pages · `frontend/src/pages/SessionConfig.tsx`
- [Knowledge upload](https://github.com/jasirahamed786/infosys-rag-project/blob/master/frontend/src/pages/KnowledgeBaseUpload.tsx): React page · `frontend/src/pages/KnowledgeBaseUpload.tsx`
- [API client](https://github.com/jasirahamed786/infosys-rag-project/blob/master/frontend/src/services/api.ts): frontend contract · `frontend/src/services/api.ts`

### FastAPI backend

- [FastAPI entry](https://github.com/jasirahamed786/infosys-rag-project/blob/master/backend/app/main.py): Python server · `backend/app/main.py`
- [Domain routers](https://github.com/jasirahamed786/infosys-rag-project/blob/master/backend/app/routers/conversation.py): HTTP API · Conversation, session, knowledge, simulator, coaching, escalation, analytics, and reports. · `backend/app/routers/conversation.py`
- [Shared schemas](https://github.com/jasirahamed786/infosys-rag-project/blob/master/backend/app/models/schemas.py): API and persistence models · `backend/app/models/schemas.py`

### AI pipeline

- [Turn pipeline](https://github.com/jasirahamed786/infosys-rag-project/blob/master/backend/app/orchestration/pipeline.py): orchestrator · Composes agents, fallbacks, and live coaching artifacts. · `backend/app/orchestration/pipeline.py`
- [Intent & sentiment](https://github.com/jasirahamed786/infosys-rag-project/blob/master/backend/app/agents/intent_sentiment_agent.py): AI agent · `backend/app/agents/intent_sentiment_agent.py`
- [Knowledge retrieval](https://github.com/jasirahamed786/infosys-rag-project/blob/master/backend/app/agents/knowledge_agent.py): AI agent · `backend/app/agents/knowledge_agent.py`
- [Coaching](https://github.com/jasirahamed786/infosys-rag-project/blob/master/backend/app/agents/coaching_agent.py): AI agent · `backend/app/agents/coaching_agent.py`
- [Escalation assessment](https://github.com/jasirahamed786/infosys-rag-project/blob/master/backend/app/agents/escalation_agent.py): AI agent · `backend/app/agents/escalation_agent.py`
- [Customer simulator](https://github.com/jasirahamed786/infosys-rag-project/blob/master/backend/app/agents/simulator_agent.py): AI agent · Used only for practice-mode next turns. · `backend/app/agents/simulator_agent.py`
- [LLM client](https://github.com/jasirahamed786/infosys-rag-project/blob/master/backend/app/utils/llm_client.py): provider boundary · Routes Groq/Llama and Google Gemini calls. · `backend/app/utils/llm_client.py`

### Data & external services

- [Mongo persistence](https://github.com/jasirahamed786/infosys-rag-project/blob/master/backend/app/services/mongo.py): data service · `backend/app/services/mongo.py`
- **MongoDB**: operational datastore · Stores sessions, messages, and report data.
- [RAG service](https://github.com/jasirahamed786/infosys-rag-project/blob/master/backend/app/services/rag.py): knowledge indexing and retrieval · `backend/app/services/rag.py`
- [ChromaDB index](https://github.com/jasirahamed786/infosys-rag-project/blob/master/backend/chroma_data/chroma.sqlite3): local vector store · `backend/chroma_data/chroma.sqlite3`
- **Groq & Gemini**: external LLM providers · Groq/Llama supports intent and simulation; Gemini supports knowledge, coaching, and escalation.

## Connections

- App bootstrap → Root UI: mounts
- Root UI → Session state: provides state
- Session state → Session & live screens: supplies session state
- Root UI → Knowledge upload: renders
- Session & live screens → API client: submits turns
- Knowledge upload → API client: uploads knowledge
- API client → FastAPI entry: HTTP
- FastAPI entry → Domain routers: registers
- Domain routers → Shared schemas: validates with
- Domain routers → Turn pipeline: processes turns
- Domain routers → Mongo persistence: session lifecycle
- Domain routers → RAG service: knowledge ingestion
- Turn pipeline → Intent & sentiment: classifies
- Turn pipeline → Knowledge retrieval: retrieves conditionally
- Turn pipeline → Coaching: recommends
- Turn pipeline → Escalation assessment: assesses
- Turn pipeline → Customer simulator: practice mode
- Turn pipeline → Mongo persistence: persists turn data
- Knowledge retrieval → RAG service: queries
- RAG service → ChromaDB index: indexes and retrieves
- Mongo persistence → MongoDB: stores
- Intent & sentiment → LLM client: LLM call
- Knowledge retrieval → LLM client: LLM call
- Coaching → LLM client: LLM call
- Escalation assessment → LLM client: LLM call
- Customer simulator → LLM client: LLM call
- LLM client → Groq & Gemini: provider requests
