# azure-samples/azure-search-openai-demo architecture

> Architecture diagram of the GitHub repository azure-samples/azure-search-openai-demo, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/azure-samples/azure-search-openai-demo
- Repository: https://github.com/azure-samples/azure-search-openai-demo

## Overview

This is an Azure-backed RAG chat application: employees ask questions over indexed documents and receive generated answers with citations and reasoning details. The main path runs from the chat UI through the API and retrieval approach to Azure AI Search and Azure OpenAI, then renders the response. A separate ingestion path parses and chunks documents, creates embeddings, and indexes them; cloud ingestion can delegate processing to Azure Functions. The README also describes optional speech, multimodal processing, Entra authentication, persistent history, and monitoring. Some subsystem links are documented capabilities rather than inspected call paths.

Main entry points: [`app/backend/prepdocslib/cloudingestionstrategy.py`](https://github.com/azure-samples/azure-search-openai-demo/blob/main/app/backend/prepdocslib/cloudingestionstrategy.py) (Cloud ingestion strategy), [`app/backend/approaches/approach.py`](https://github.com/azure-samples/azure-search-openai-demo/blob/main/app/backend/approaches/approach.py) (Retrieval approach), [`app/frontend/src/pages/chat/Chat.tsx`](https://github.com/azure-samples/azure-search-openai-demo/blob/main/app/frontend/src/pages/chat/Chat.tsx) (Chat UI), [`app/backend/app.py`](https://github.com/azure-samples/azure-search-openai-demo/blob/main/app/backend/app.py) (HTTP API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["Chat experience"]
  node_chat["Chat UI<br/>[Chat.tsx]"]
  node_settings["Chat settings<br/>[Settings.tsx]"]
  node_answer["Answer and citations<br/>[AnswerParser.tsx]"]
  node_speech["Speech input/output<br/>[SpeechInput.tsx]"]
  node_analysis["Reasoning display<br/>[AnalysisPanel.tsx]"]
  node_api["Frontend API<br/>[api.ts]"]
end

subgraph group_backend["Chat backend"]
  node_apiapp["HTTP API<br/>[app.py]"]
  node_approach["Retrieval approach<br/>[approach.py]"]
  node_prompt["Prompt manager<br/>[promptmanager.py]"]
  node_search[("Azure AI Search")]
end

subgraph group_ingestion["Document ingestion"]
  node_ingestsetup["Ingestion setup"]
  node_cloudingest["Cloud ingestion strategy"]
  node_localingest["Local document preparation<br/>[prepdocs.py]"]
  node_files["File listing and storage"]
  node_processing["Parsing and chunking<br/>[servicesetup.py]"]
  node_embeddings["Text and image embeddings<br/>[embeddings.py]"]
  node_indexmanager["Search index manager<br/>[searchmanager.py]"]
  node_blob[("Blob storage<br/>[blobmanager.py]")]
  node_extractor["Document extractor<br/>[function_app.py]"]
  node_figureprocessor["Figure processor<br/>[function_app.py]"]
  node_textprocessor["Text processor<br/>[function_app.py]"]
end

subgraph group_identity["Identity and history"]
  node_auth["Authentication<br/>[authentication.py]"]
  node_history[("Chat history<br/>[cosmosdb.py]")]
  node_historyui["History providers<br/>[HistoryManager.ts]"]
end

node_employee(("Employee"))
node_openai["Azure OpenAI"]
node_vision["Azure AI Vision"]
node_cosmos[("Azure Cosmos DB")]
node_monitor["Application Insights"]

node_employee -->|"asks questions"| node_chat
node_chat -->|"sends requests"| node_api
node_api -.->|"calls API"| node_apiapp
node_apiapp -->|"invokes"| node_approach
node_approach -->|"builds prompts"| node_prompt
node_approach -.->|"retrieves documents"| node_search
node_approach -.->|"generates answers"| node_openai
node_approach -->|"uses embeddings"| node_embeddings
node_apiapp -->|"authenticates requests"| node_auth
node_chat -->|"configures chat"| node_settings
node_apiapp -.->|"persists history"| node_history
node_chat -->|"manages history"| node_historyui
node_historyui -.->|"selects provider"| node_cosmos
node_approach -.->|"returns response"| node_answer
node_answer -->|"renders reasoning"| node_analysis
node_chat -.->|"accepts speech"| node_speech
node_ingestsetup -->|"configures and runs"| node_cloudingest
node_cloudingest -->|"configures indexing"| node_indexmanager
node_cloudingest -->|"uses file strategy"| node_files
node_cloudingest -->|"uses storage"| node_blob
node_cloudingest -->|"uses embeddings"| node_embeddings
node_localingest -.->|"prepares documents"| node_processing
node_processing -->|"reads files"| node_files
node_processing -.->|"creates vectors"| node_embeddings
node_cloudingest -.->|"dispatches skill"| node_extractor
node_cloudingest -.->|"dispatches skill"| node_figureprocessor
node_cloudingest -.->|"dispatches skill"| node_textprocessor
node_textprocessor -->|"creates vectors"| node_embeddings
node_figureprocessor -.->|"creates image vectors"| node_vision
node_indexmanager -.->|"creates index"| node_search
node_apiapp -.->|"traces activity"| node_monitor

click node_chat "https://github.com/azure-samples/azure-search-openai-demo/blob/main/app/frontend/src/pages/chat/Chat.tsx"
click node_settings "https://github.com/azure-samples/azure-search-openai-demo/blob/main/app/frontend/src/components/Settings/Settings.tsx"
click node_answer "https://github.com/azure-samples/azure-search-openai-demo/blob/main/app/frontend/src/components/Answer/AnswerParser.tsx"
click node_speech "https://github.com/azure-samples/azure-search-openai-demo/blob/main/app/frontend/src/components/QuestionInput/SpeechInput.tsx"
click node_analysis "https://github.com/azure-samples/azure-search-openai-demo/blob/main/app/frontend/src/components/AnalysisPanel/AnalysisPanel.tsx"
click node_api "https://github.com/azure-samples/azure-search-openai-demo/blob/main/app/frontend/src/api/api.ts"
click node_apiapp "https://github.com/azure-samples/azure-search-openai-demo/blob/main/app/backend/app.py"
click node_approach "https://github.com/azure-samples/azure-search-openai-demo/blob/main/app/backend/approaches/approach.py"
click node_prompt "https://github.com/azure-samples/azure-search-openai-demo/blob/main/app/backend/approaches/promptmanager.py"
click node_auth "https://github.com/azure-samples/azure-search-openai-demo/blob/main/app/backend/core/authentication.py"
click node_history "https://github.com/azure-samples/azure-search-openai-demo/blob/main/app/backend/chat_history/cosmosdb.py"
click node_historyui "https://github.com/azure-samples/azure-search-openai-demo/blob/main/app/frontend/src/components/HistoryProviders/HistoryManager.ts"
click node_ingestsetup "https://github.com/azure-samples/azure-search-openai-demo/blob/main/app/backend/setup_cloud_ingestion.py"
click node_cloudingest "https://github.com/azure-samples/azure-search-openai-demo/blob/main/app/backend/prepdocslib/cloudingestionstrategy.py"
click node_localingest "https://github.com/azure-samples/azure-search-openai-demo/blob/main/app/backend/prepdocs.py"
click node_files "https://github.com/azure-samples/azure-search-openai-demo/blob/main/app/backend/prepdocslib/listfilestrategy.py"
click node_processing "https://github.com/azure-samples/azure-search-openai-demo/blob/main/app/backend/prepdocslib/servicesetup.py"
click node_embeddings "https://github.com/azure-samples/azure-search-openai-demo/blob/main/app/backend/prepdocslib/embeddings.py"
click node_indexmanager "https://github.com/azure-samples/azure-search-openai-demo/blob/main/app/backend/prepdocslib/searchmanager.py"
click node_blob "https://github.com/azure-samples/azure-search-openai-demo/blob/main/app/backend/prepdocslib/blobmanager.py"
click node_extractor "https://github.com/azure-samples/azure-search-openai-demo/blob/main/app/functions/document_extractor/function_app.py"
click node_figureprocessor "https://github.com/azure-samples/azure-search-openai-demo/blob/main/app/functions/figure_processor/function_app.py"
click node_textprocessor "https://github.com/azure-samples/azure-search-openai-demo/blob/main/app/functions/text_processor/function_app.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_chat,node_settings,node_answer,node_speech,node_analysis,node_api toneBlue
class node_apiapp,node_approach,node_prompt,node_search,node_cosmos toneAmber
class node_ingestsetup,node_cloudingest,node_localingest,node_files,node_processing,node_embeddings,node_indexmanager,node_blob,node_extractor,node_figureprocessor,node_textprocessor toneMint
class node_auth,node_history,node_historyui toneRose
class node_employee,node_openai,node_vision,node_monitor toneIndigo
```

## Components

### Chat experience

- [Chat UI](https://github.com/azure-samples/azure-search-openai-demo/blob/main/app/frontend/src/pages/chat/Chat.tsx): `app/frontend/src/pages/chat/Chat.tsx`
- [Chat settings](https://github.com/azure-samples/azure-search-openai-demo/blob/main/app/frontend/src/components/Settings/Settings.tsx): `app/frontend/src/components/Settings/Settings.tsx`
- [Answer and citations](https://github.com/azure-samples/azure-search-openai-demo/blob/main/app/frontend/src/components/Answer/AnswerParser.tsx): `app/frontend/src/components/Answer/AnswerParser.tsx`
- [Speech input/output](https://github.com/azure-samples/azure-search-openai-demo/blob/main/app/frontend/src/components/QuestionInput/SpeechInput.tsx): `app/frontend/src/components/QuestionInput/SpeechInput.tsx`
- [Reasoning display](https://github.com/azure-samples/azure-search-openai-demo/blob/main/app/frontend/src/components/AnalysisPanel/AnalysisPanel.tsx): `app/frontend/src/components/AnalysisPanel/AnalysisPanel.tsx`
- [Frontend API](https://github.com/azure-samples/azure-search-openai-demo/blob/main/app/frontend/src/api/api.ts): `app/frontend/src/api/api.ts`

### Chat backend

- [HTTP API](https://github.com/azure-samples/azure-search-openai-demo/blob/main/app/backend/app.py): `app/backend/app.py`
- [Retrieval approach](https://github.com/azure-samples/azure-search-openai-demo/blob/main/app/backend/approaches/approach.py): `app/backend/approaches/approach.py`
- [Prompt manager](https://github.com/azure-samples/azure-search-openai-demo/blob/main/app/backend/approaches/promptmanager.py): `app/backend/approaches/promptmanager.py`
- **Azure AI Search**

### Document ingestion

- [Ingestion setup](https://github.com/azure-samples/azure-search-openai-demo/blob/main/app/backend/setup_cloud_ingestion.py): `app/backend/setup_cloud_ingestion.py`
- [Cloud ingestion strategy](https://github.com/azure-samples/azure-search-openai-demo/blob/main/app/backend/prepdocslib/cloudingestionstrategy.py): `app/backend/prepdocslib/cloudingestionstrategy.py`
- [Local document preparation](https://github.com/azure-samples/azure-search-openai-demo/blob/main/app/backend/prepdocs.py): `app/backend/prepdocs.py`
- [File listing and storage](https://github.com/azure-samples/azure-search-openai-demo/blob/main/app/backend/prepdocslib/listfilestrategy.py): `app/backend/prepdocslib/listfilestrategy.py`
- [Parsing and chunking](https://github.com/azure-samples/azure-search-openai-demo/blob/main/app/backend/prepdocslib/servicesetup.py): `app/backend/prepdocslib/servicesetup.py`
- [Text and image embeddings](https://github.com/azure-samples/azure-search-openai-demo/blob/main/app/backend/prepdocslib/embeddings.py): `app/backend/prepdocslib/embeddings.py`
- [Search index manager](https://github.com/azure-samples/azure-search-openai-demo/blob/main/app/backend/prepdocslib/searchmanager.py): `app/backend/prepdocslib/searchmanager.py`
- [Blob storage](https://github.com/azure-samples/azure-search-openai-demo/blob/main/app/backend/prepdocslib/blobmanager.py): `app/backend/prepdocslib/blobmanager.py`
- [Document extractor](https://github.com/azure-samples/azure-search-openai-demo/blob/main/app/functions/document_extractor/function_app.py): `app/functions/document_extractor/function_app.py`
- [Figure processor](https://github.com/azure-samples/azure-search-openai-demo/blob/main/app/functions/figure_processor/function_app.py): `app/functions/figure_processor/function_app.py`
- [Text processor](https://github.com/azure-samples/azure-search-openai-demo/blob/main/app/functions/text_processor/function_app.py): `app/functions/text_processor/function_app.py`

### Identity and history

- [Authentication](https://github.com/azure-samples/azure-search-openai-demo/blob/main/app/backend/core/authentication.py): `app/backend/core/authentication.py`
- [Chat history](https://github.com/azure-samples/azure-search-openai-demo/blob/main/app/backend/chat_history/cosmosdb.py): `app/backend/chat_history/cosmosdb.py`
- [History providers](https://github.com/azure-samples/azure-search-openai-demo/blob/main/app/frontend/src/components/HistoryProviders/HistoryManager.ts): `app/frontend/src/components/HistoryProviders/HistoryManager.ts`

### Other components

- **Employee**
- **Azure OpenAI**
- **Azure AI Vision**
- **Azure Cosmos DB**
- **Application Insights**

## Connections

- Employee → Chat UI: asks questions (evidence: `README.md`)
- Chat UI → Frontend API: sends requests (evidence: `app/frontend/src/pages/chat/Chat.tsx`)
- Frontend API → HTTP API: calls API
- HTTP API → Retrieval approach: invokes (evidence: `app/backend/app.py`)
- Retrieval approach → Prompt manager: builds prompts (evidence: `app/backend/approaches/approach.py`)
- Retrieval approach → Azure AI Search: retrieves documents
- Retrieval approach → Azure OpenAI: generates answers
- Retrieval approach → Text and image embeddings: uses embeddings (evidence: `app/backend/approaches/approach.py`)
- HTTP API → Authentication: authenticates requests (evidence: `app/backend/app.py`)
- Chat UI → Chat settings: configures chat (evidence: `app/frontend/src/pages/chat/Chat.tsx`)
- HTTP API → Chat history: persists history (evidence: `app/backend/app.py`)
- Chat UI → History providers: manages history (evidence: `app/frontend/src/pages/chat/Chat.tsx`)
- History providers → Azure Cosmos DB: selects provider
- Retrieval approach → Answer and citations: returns response
- Answer and citations → Reasoning display: renders reasoning (evidence: `app/frontend/src/components/Answer/AnswerParser.tsx`)
- Chat UI → Speech input/output: accepts speech
- Ingestion setup → Cloud ingestion strategy: configures and runs (evidence: `app/backend/setup_cloud_ingestion.py`)
- Cloud ingestion strategy → Search index manager: configures indexing (evidence: `app/backend/prepdocslib/cloudingestionstrategy.py`)
- Cloud ingestion strategy → File listing and storage: uses file strategy (evidence: `app/backend/prepdocslib/cloudingestionstrategy.py`)
- Cloud ingestion strategy → Blob storage: uses storage (evidence: `app/backend/prepdocslib/cloudingestionstrategy.py`)
- Cloud ingestion strategy → Text and image embeddings: uses embeddings (evidence: `app/backend/prepdocslib/cloudingestionstrategy.py`)
- Local document preparation → Parsing and chunking: prepares documents
- Parsing and chunking → File listing and storage: reads files
- Parsing and chunking → Text and image embeddings: creates vectors (evidence: `app/backend/prepdocslib/servicesetup.py`)
- Cloud ingestion strategy → Document extractor: dispatches skill
- Cloud ingestion strategy → Figure processor: dispatches skill
- Cloud ingestion strategy → Text processor: dispatches skill
- Text processor → Text and image embeddings: creates vectors (evidence: `app/functions/text_processor/function_app.py`)
- Figure processor → Azure AI Vision: creates image vectors
- Search index manager → Azure AI Search: creates index
- HTTP API → Application Insights: traces activity
