# woedem24/azure-ai-chatbot architecture

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

- Interactive diagram: https://gitdiagram.com/woedem24/azure-ai-chatbot
- Repository: https://github.com/woedem24/azure-ai-chatbot

## Overview

Cirrus is an Azure-hosted, multi-mode AI chatbot. A user submits a message through the web demo or REST API; the Function App rate-limits chat requests and delegates them to the conversation handler, which resolves a session, loads recent history, selects a prompt persona, calls Azure OpenAI, records usage and saves the conversation before returning a reply. Terraform provisions the Azure services. The README documents the demo, health check, persistence, cost monitoring, and deployment; sampled source confirms handler integrations, but does not show the infrastructure configuration details.

Main entry points: [`function_app/function_app.py`](https://github.com/woedem24/azure-ai-chatbot/blob/main/function_app/function_app.py) (Function App), [`function_app/ConversationHandler/conversation_handler.py`](https://github.com/woedem24/azure-ai-chatbot/blob/main/function_app/ConversationHandler/conversation_handler.py) (Chat handler), [`terraform/main.tf`](https://github.com/woedem24/azure-ai-chatbot/blob/main/terraform/main.tf) (Azure infrastructure), [`webchat/index.html`](https://github.com/woedem24/azure-ai-chatbot/blob/main/webchat/index.html) (Web chat)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Chat clients"]
  node_webchat["Web chat<br/>[index.html]"]
end

subgraph group_api["Function API"]
  node_function_app["Function App<br/>[function_app.py]"]
  node_rate_limiter["Rate limiter<br/>[rate_limiter.py]"]
  node_health["Health check<br/>[function_app.py]"]
end

subgraph group_conversation["Conversation handling"]
  node_handler["Chat handler"]
  node_session["Session identity<br/>[session.py]"]
  node_intent["Intent detector<br/>[intent_detector.py]"]
  node_prompts["Mode prompts<br/>[prompts.py]"]
  node_openai_client["AI client<br/>[openai_client.py]"]
  node_token_counter["Usage and cost<br/>[token_counter.py]"]
  node_cosmos_client["Conversation storage<br/>[cosmos_client.py]"]
end

subgraph group_azure["Azure services"]
  node_cosmos[("Cosmos DB")]
  node_openai["Azure OpenAI"]
  node_key_vault["Key Vault"]
  node_app_insights["Application Insights"]
  node_terraform["Azure infrastructure<br/>[main.tf]"]
end

node_user(("Chat user"))

node_user -->|"uses"| node_webchat
node_user -->|"calls REST API"| node_function_app
node_webchat -->|"sends chat"| node_function_app
node_function_app -->|"checks limit"| node_rate_limiter
node_function_app -->|"delegates chat"| node_handler
node_handler -->|"resolves session"| node_session
node_handler -->|"loads and saves"| node_cosmos_client
node_cosmos_client -.->|"reads and writes"| node_cosmos
node_handler -->|"detects intent"| node_intent
node_handler -->|"gets prompt"| node_prompts
node_handler -->|"generates reply"| node_openai_client
node_openai_client -.->|"requests completion"| node_openai
node_handler -->|"counts and estimates"| node_token_counter
node_function_app -->|"serves health"| node_health
node_function_app -.->|"sends telemetry"| node_app_insights
node_function_app -.->|"resolves secrets"| node_key_vault
node_terraform -.->|"provisions"| node_function_app
node_terraform -.->|"provisions"| node_cosmos
node_terraform -.->|"provisions"| node_key_vault
node_terraform -.->|"provisions"| node_app_insights

click node_webchat "https://github.com/woedem24/azure-ai-chatbot/blob/main/webchat/index.html"
click node_function_app "https://github.com/woedem24/azure-ai-chatbot/blob/main/function_app/function_app.py"
click node_rate_limiter "https://github.com/woedem24/azure-ai-chatbot/blob/main/function_app/ConversationHandler/rate_limiter.py"
click node_health "https://github.com/woedem24/azure-ai-chatbot/blob/main/function_app/function_app.py"
click node_handler "https://github.com/woedem24/azure-ai-chatbot/blob/main/function_app/ConversationHandler/conversation_handler.py"
click node_session "https://github.com/woedem24/azure-ai-chatbot/blob/main/function_app/ConversationHandler/session.py"
click node_intent "https://github.com/woedem24/azure-ai-chatbot/blob/main/function_app/ConversationHandler/intent_detector.py"
click node_prompts "https://github.com/woedem24/azure-ai-chatbot/blob/main/function_app/ConversationHandler/prompts.py"
click node_openai_client "https://github.com/woedem24/azure-ai-chatbot/blob/main/function_app/ConversationHandler/openai_client.py"
click node_token_counter "https://github.com/woedem24/azure-ai-chatbot/blob/main/function_app/ConversationHandler/token_counter.py"
click node_cosmos_client "https://github.com/woedem24/azure-ai-chatbot/blob/main/function_app/ConversationHandler/cosmos_client.py"
click node_terraform "https://github.com/woedem24/azure-ai-chatbot/blob/main/terraform/main.tf"

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_webchat,node_user toneBlue
class node_function_app,node_rate_limiter,node_health toneAmber
class node_handler,node_session,node_intent,node_prompts,node_openai_client,node_token_counter,node_cosmos_client toneMint
class node_cosmos,node_openai,node_key_vault,node_app_insights,node_terraform toneRose
```

## Components

### Chat clients

- [Web chat](https://github.com/woedem24/azure-ai-chatbot/blob/main/webchat/index.html): `webchat/index.html`

### Function API

- [Function App](https://github.com/woedem24/azure-ai-chatbot/blob/main/function_app/function_app.py): `function_app/function_app.py`
- [Rate limiter](https://github.com/woedem24/azure-ai-chatbot/blob/main/function_app/ConversationHandler/rate_limiter.py): `function_app/ConversationHandler/rate_limiter.py`
- [Health check](https://github.com/woedem24/azure-ai-chatbot/blob/main/function_app/function_app.py): `function_app/function_app.py`

### Conversation handling

- [Chat handler](https://github.com/woedem24/azure-ai-chatbot/blob/main/function_app/ConversationHandler/conversation_handler.py): `function_app/ConversationHandler/conversation_handler.py`
- [Session identity](https://github.com/woedem24/azure-ai-chatbot/blob/main/function_app/ConversationHandler/session.py): `function_app/ConversationHandler/session.py`
- [Intent detector](https://github.com/woedem24/azure-ai-chatbot/blob/main/function_app/ConversationHandler/intent_detector.py): `function_app/ConversationHandler/intent_detector.py`
- [Mode prompts](https://github.com/woedem24/azure-ai-chatbot/blob/main/function_app/ConversationHandler/prompts.py): `function_app/ConversationHandler/prompts.py`
- [AI client](https://github.com/woedem24/azure-ai-chatbot/blob/main/function_app/ConversationHandler/openai_client.py): `function_app/ConversationHandler/openai_client.py`
- [Usage and cost](https://github.com/woedem24/azure-ai-chatbot/blob/main/function_app/ConversationHandler/token_counter.py): `function_app/ConversationHandler/token_counter.py`
- [Conversation storage](https://github.com/woedem24/azure-ai-chatbot/blob/main/function_app/ConversationHandler/cosmos_client.py): `function_app/ConversationHandler/cosmos_client.py`

### Azure services

- **Cosmos DB**
- **Azure OpenAI**
- **Key Vault**
- **Application Insights**
- [Azure infrastructure](https://github.com/woedem24/azure-ai-chatbot/blob/main/terraform/main.tf): `terraform/main.tf`

### Other components

- **Chat user**

## Connections

- Chat user → Web chat: uses (evidence: `README.md`)
- Chat user → Function App: calls REST API (evidence: `README.md`)
- Web chat → Function App: sends chat (evidence: `README.md`)
- Function App → Rate limiter: checks limit (evidence: `function_app/function_app.py`)
- Function App → Chat handler: delegates chat (evidence: `function_app/function_app.py`)
- Chat handler → Session identity: resolves session (evidence: `function_app/ConversationHandler/conversation_handler.py`)
- Chat handler → Conversation storage: loads and saves (evidence: `function_app/ConversationHandler/conversation_handler.py`)
- Conversation storage → Cosmos DB: reads and writes (evidence: `README.md`)
- Chat handler → Intent detector: detects intent (evidence: `function_app/ConversationHandler/conversation_handler.py`)
- Chat handler → Mode prompts: gets prompt (evidence: `function_app/ConversationHandler/conversation_handler.py`)
- Chat handler → AI client: generates reply (evidence: `function_app/ConversationHandler/conversation_handler.py`)
- AI client → Azure OpenAI: requests completion (evidence: `README.md`)
- Chat handler → Usage and cost: counts and estimates (evidence: `function_app/ConversationHandler/conversation_handler.py`)
- Function App → Health check: serves health (evidence: `function_app/function_app.py`)
- Function App → Application Insights: sends telemetry (evidence: `README.md`)
- Function App → Key Vault: resolves secrets (evidence: `README.md`)
- Azure infrastructure → Function App: provisions (evidence: `README.md`)
- Azure infrastructure → Cosmos DB: provisions (evidence: `README.md`)
- Azure infrastructure → Key Vault: provisions (evidence: `README.md`)
- Azure infrastructure → Application Insights: provisions (evidence: `README.md`)
