# richie-rk/rag-app-azure architecture

> Architecture diagram of the GitHub repository richie-rk/rag-app-azure, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/richie-rk/rag-app-azure
- Repository: https://github.com/richie-rk/rag-app-azure

## Overview

This is a multi-tenant Azure RAG application: users authenticate, select a project, upload documents for parsing and indexing, then ask questions and receive streamed, cited answers. The graph preserves the documented UI, chat, ingestion, project/access, and storage capabilities. Sampled source supports the chat and per-file ingestion calls; some utils endpoints and several UI flows are documented but unsampled, so their internal wiring is not expanded.

Main entry points: [`services/chat/main.py`](https://github.com/richie-rk/rag-app-azure/blob/main/services/chat/main.py) (Chat endpoint), [`services/ingestion/orchestrator.py`](https://github.com/richie-rk/rag-app-azure/blob/main/services/ingestion/orchestrator.py) (File processing), [`ui/src/api/client.ts`](https://github.com/richie-rk/rag-app-azure/blob/main/ui/src/api/client.ts) (API client), [`services/shared/azure_clients.py`](https://github.com/richie-rk/rag-app-azure/blob/main/services/shared/azure_clients.py) (Azure client factory)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web client"]
  node_ui["React application<br/>[App.tsx]"]
  node_auth["Sign-in and identity<br/>[graph-service.ts]"]
  node_chat_ui["Chat and streaming UI<br/>[useStreamChat.ts]"]
  node_project_ui["Project management UI<br/>[ProjectsPage.tsx]"]
  node_upload_ui["Data loader UI<br/>[DataLoaderPage.tsx]"]
  node_api["API client<br/>[client.ts]"]
end

subgraph group_services["Application services"]
  node_chat_api["Chat endpoint<br/>[main.py]"]
  node_retrieval["Hybrid retrieval<br/>[search.py]"]
  node_prompt["Prompt assembly<br/>[prompt.py]"]
  node_completion["Streaming completion<br/>[llm.py]"]
  node_citations["Citations and follow-ups<br/>[citations.py]"]
  node_stream["NDJSON formatting<br/>[streaming.py]"]
  node_utils["Project and utility API<br/>[projects.py]"]
  node_sessions["Session and feedback APIs<br/>[sessions.py]"]
  node_documents["Document APIs<br/>[documents.py]"]
end

subgraph group_ingestion["Document ingestion"]
  node_ingest_api["Ingestion trigger<br/>[function_app.py]"]
  node_orchestrator["File processing<br/>[orchestrator.py]"]
  node_parsers["Document parsers<br/>[__init__.py]"]
  node_chunking["Chunking strategies<br/>[__init__.py]"]
  node_embedding["Text embeddings<br/>[embedding.py]"]
  node_indexer["Search indexing<br/>[indexer.py]"]
end

subgraph group_shared["Shared backend"]
  node_shared_auth["Authentication and authorization<br/>[authz.py]"]
  node_models["Domain models<br/>[models.py]"]
  node_database["SQL database access<br/>[database.py]"]
  node_clients["Azure client factory<br/>[azure_clients.py]"]
end

subgraph group_azure["Azure services"]
  node_entra["Microsoft Entra ID"]
  node_search[("Azure AI Search")]
  node_openai["Azure OpenAI"]
  node_blob[("Blob Storage")]
  node_table[("Table Storage")]
  node_sql[("Azure SQL")]
end

node_user(("User"))

node_user -->|"uses"| node_ui
node_ui -->|"authenticates through"| node_auth
node_auth -->|"signs in with"| node_entra
node_chat_ui -->|"sends chat"| node_api
node_api -->|"posts request"| node_chat_api
node_chat_api -->|"authorizes index"| node_shared_auth
node_chat_api -->|"queries"| node_retrieval
node_retrieval -->|"hybrid searches"| node_search
node_chat_api -->|"builds messages"| node_prompt
node_chat_api -->|"streams prompt"| node_completion
node_completion -->|"requests tokens"| node_openai
node_chat_api -->|"extracts follow-ups"| node_citations
node_chat_api -->|"formats chunks"| node_stream
node_stream -->|"streams NDJSON"| node_chat_ui
node_project_ui -->|"calls project APIs"| node_api
node_upload_ui -->|"calls upload APIs"| node_api
node_api -->|"manages projects"| node_utils
node_api -->|"accesses documents"| node_documents
node_api -->|"manages sessions"| node_sessions
node_upload_ui -->|"starts ingestion"| node_ingest_api
node_ingest_api -->|"dispatches files"| node_orchestrator
node_orchestrator -->|"downloads files"| node_blob
node_orchestrator -->|"extracts content"| node_parsers
node_orchestrator -->|"creates chunks"| node_chunking
node_orchestrator -->|"embeds chunks"| node_embedding
node_embedding -->|"creates embeddings"| node_openai
node_orchestrator -->|"indexes chunks"| node_indexer
node_indexer -->|"writes documents"| node_search
node_orchestrator -->|"records audit"| node_database
node_database -->|"reads and writes"| node_sql
node_utils -->|"accesses records"| node_database
node_sessions -->|"stores chat history"| node_table
node_documents -->|"reads documents"| node_blob
node_chat_api -->|"checks project access"| node_database
node_clients -->|"creates clients"| node_search
node_clients -->|"creates clients"| node_openai
node_clients -->|"creates clients"| node_blob
node_clients -->|"creates clients"| node_table
node_shared_auth -->|"validates identity"| node_entra

click node_ui "https://github.com/richie-rk/rag-app-azure/blob/main/ui/src/App.tsx"
click node_auth "https://github.com/richie-rk/rag-app-azure/blob/main/ui/src/auth/graph-service.ts"
click node_chat_ui "https://github.com/richie-rk/rag-app-azure/blob/main/ui/src/hooks/useStreamChat.ts"
click node_project_ui "https://github.com/richie-rk/rag-app-azure/blob/main/ui/src/pages/ProjectsPage.tsx"
click node_upload_ui "https://github.com/richie-rk/rag-app-azure/blob/main/ui/src/pages/DataLoaderPage.tsx"
click node_api "https://github.com/richie-rk/rag-app-azure/blob/main/ui/src/api/client.ts"
click node_chat_api "https://github.com/richie-rk/rag-app-azure/blob/main/services/chat/main.py"
click node_retrieval "https://github.com/richie-rk/rag-app-azure/blob/main/services/chat/pipeline/search.py"
click node_prompt "https://github.com/richie-rk/rag-app-azure/blob/main/services/chat/pipeline/prompt.py"
click node_completion "https://github.com/richie-rk/rag-app-azure/blob/main/services/chat/pipeline/llm.py"
click node_citations "https://github.com/richie-rk/rag-app-azure/blob/main/services/chat/pipeline/citations.py"
click node_stream "https://github.com/richie-rk/rag-app-azure/blob/main/services/chat/streaming.py"
click node_utils "https://github.com/richie-rk/rag-app-azure/blob/main/services/utils/endpoints/projects.py"
click node_sessions "https://github.com/richie-rk/rag-app-azure/blob/main/services/utils/endpoints/sessions.py"
click node_documents "https://github.com/richie-rk/rag-app-azure/blob/main/services/utils/endpoints/documents.py"
click node_ingest_api "https://github.com/richie-rk/rag-app-azure/blob/main/services/ingestion/function_app.py"
click node_orchestrator "https://github.com/richie-rk/rag-app-azure/blob/main/services/ingestion/orchestrator.py"
click node_parsers "https://github.com/richie-rk/rag-app-azure/blob/main/services/ingestion/parsers/__init__.py"
click node_chunking "https://github.com/richie-rk/rag-app-azure/blob/main/services/ingestion/chunking/__init__.py"
click node_embedding "https://github.com/richie-rk/rag-app-azure/blob/main/services/ingestion/embedding.py"
click node_indexer "https://github.com/richie-rk/rag-app-azure/blob/main/services/ingestion/indexer.py"
click node_shared_auth "https://github.com/richie-rk/rag-app-azure/blob/main/services/shared/authz.py"
click node_models "https://github.com/richie-rk/rag-app-azure/blob/main/services/shared/models.py"
click node_database "https://github.com/richie-rk/rag-app-azure/blob/main/services/shared/database.py"
click node_clients "https://github.com/richie-rk/rag-app-azure/blob/main/services/shared/azure_clients.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_ui,node_auth,node_chat_ui,node_project_ui,node_upload_ui,node_api,node_user toneBlue
class node_chat_api,node_retrieval,node_prompt,node_completion,node_citations,node_stream,node_utils,node_sessions,node_documents toneAmber
class node_ingest_api,node_orchestrator,node_parsers,node_chunking,node_embedding,node_indexer toneMint
class node_shared_auth,node_models,node_database,node_clients toneRose
class node_entra,node_search,node_openai,node_blob,node_table,node_sql toneIndigo
```

## Components

### Web client

- [React application](https://github.com/richie-rk/rag-app-azure/blob/main/ui/src/App.tsx): `ui/src/App.tsx`
- [Sign-in and identity](https://github.com/richie-rk/rag-app-azure/blob/main/ui/src/auth/graph-service.ts): `ui/src/auth/graph-service.ts`
- [Chat and streaming UI](https://github.com/richie-rk/rag-app-azure/blob/main/ui/src/hooks/useStreamChat.ts): `ui/src/hooks/useStreamChat.ts`
- [Project management UI](https://github.com/richie-rk/rag-app-azure/blob/main/ui/src/pages/ProjectsPage.tsx): `ui/src/pages/ProjectsPage.tsx`
- [Data loader UI](https://github.com/richie-rk/rag-app-azure/blob/main/ui/src/pages/DataLoaderPage.tsx): `ui/src/pages/DataLoaderPage.tsx`
- [API client](https://github.com/richie-rk/rag-app-azure/blob/main/ui/src/api/client.ts): `ui/src/api/client.ts`

### Application services

- [Chat endpoint](https://github.com/richie-rk/rag-app-azure/blob/main/services/chat/main.py): `services/chat/main.py`
- [Hybrid retrieval](https://github.com/richie-rk/rag-app-azure/blob/main/services/chat/pipeline/search.py): `services/chat/pipeline/search.py`
- [Prompt assembly](https://github.com/richie-rk/rag-app-azure/blob/main/services/chat/pipeline/prompt.py): `services/chat/pipeline/prompt.py`
- [Streaming completion](https://github.com/richie-rk/rag-app-azure/blob/main/services/chat/pipeline/llm.py): `services/chat/pipeline/llm.py`
- [Citations and follow-ups](https://github.com/richie-rk/rag-app-azure/blob/main/services/chat/pipeline/citations.py): `services/chat/pipeline/citations.py`
- [NDJSON formatting](https://github.com/richie-rk/rag-app-azure/blob/main/services/chat/streaming.py): `services/chat/streaming.py`
- [Project and utility API](https://github.com/richie-rk/rag-app-azure/blob/main/services/utils/endpoints/projects.py): `services/utils/endpoints/projects.py`
- [Session and feedback APIs](https://github.com/richie-rk/rag-app-azure/blob/main/services/utils/endpoints/sessions.py): `services/utils/endpoints/sessions.py`
- [Document APIs](https://github.com/richie-rk/rag-app-azure/blob/main/services/utils/endpoints/documents.py): `services/utils/endpoints/documents.py`

### Document ingestion

- [Ingestion trigger](https://github.com/richie-rk/rag-app-azure/blob/main/services/ingestion/function_app.py): `services/ingestion/function_app.py`
- [File processing](https://github.com/richie-rk/rag-app-azure/blob/main/services/ingestion/orchestrator.py): `services/ingestion/orchestrator.py`
- [Document parsers](https://github.com/richie-rk/rag-app-azure/blob/main/services/ingestion/parsers/__init__.py): `services/ingestion/parsers/__init__.py`
- [Chunking strategies](https://github.com/richie-rk/rag-app-azure/blob/main/services/ingestion/chunking/__init__.py): `services/ingestion/chunking/__init__.py`
- [Text embeddings](https://github.com/richie-rk/rag-app-azure/blob/main/services/ingestion/embedding.py): `services/ingestion/embedding.py`
- [Search indexing](https://github.com/richie-rk/rag-app-azure/blob/main/services/ingestion/indexer.py): `services/ingestion/indexer.py`

### Shared backend

- [Authentication and authorization](https://github.com/richie-rk/rag-app-azure/blob/main/services/shared/authz.py): `services/shared/authz.py`
- [Domain models](https://github.com/richie-rk/rag-app-azure/blob/main/services/shared/models.py): `services/shared/models.py`
- [SQL database access](https://github.com/richie-rk/rag-app-azure/blob/main/services/shared/database.py): `services/shared/database.py`
- [Azure client factory](https://github.com/richie-rk/rag-app-azure/blob/main/services/shared/azure_clients.py): `services/shared/azure_clients.py`

### Azure services

- **Microsoft Entra ID**
- **Azure AI Search**
- **Azure OpenAI**
- **Blob Storage**
- **Table Storage**
- **Azure SQL**

### Other components

- **User**

## Connections

- User → React application: uses
- React application → Sign-in and identity: authenticates through
- Sign-in and identity → Microsoft Entra ID: signs in with
- Chat and streaming UI → API client: sends chat
- API client → Chat endpoint: posts request
- Chat endpoint → Authentication and authorization: authorizes index
- Chat endpoint → Hybrid retrieval: queries
- Hybrid retrieval → Azure AI Search: hybrid searches
- Chat endpoint → Prompt assembly: builds messages
- Chat endpoint → Streaming completion: streams prompt
- Streaming completion → Azure OpenAI: requests tokens
- Chat endpoint → Citations and follow-ups: extracts follow-ups
- Chat endpoint → NDJSON formatting: formats chunks
- NDJSON formatting → Chat and streaming UI: streams NDJSON
- Project management UI → API client: calls project APIs
- Data loader UI → API client: calls upload APIs
- API client → Project and utility API: manages projects
- API client → Document APIs: accesses documents
- API client → Session and feedback APIs: manages sessions
- Data loader UI → Ingestion trigger: starts ingestion
- Ingestion trigger → File processing: dispatches files
- File processing → Blob Storage: downloads files
- File processing → Document parsers: extracts content
- File processing → Chunking strategies: creates chunks
- File processing → Text embeddings: embeds chunks
- Text embeddings → Azure OpenAI: creates embeddings
- File processing → Search indexing: indexes chunks
- Search indexing → Azure AI Search: writes documents
- File processing → SQL database access: records audit
- SQL database access → Azure SQL: reads and writes
- Project and utility API → SQL database access: accesses records
- Session and feedback APIs → Table Storage: stores chat history
- Document APIs → Blob Storage: reads documents
- Chat endpoint → SQL database access: checks project access
- Azure client factory → Azure AI Search: creates clients
- Azure client factory → Azure OpenAI: creates clients
- Azure client factory → Blob Storage: creates clients
- Azure client factory → Table Storage: creates clients
- Authentication and authorization → Microsoft Entra ID: validates identity
