# azure-samples/azure-ai-agent-service-enterprise-demo architecture

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

- Interactive diagram: https://gitdiagram.com/azure-samples/azure-ai-agent-service-enterprise-demo
- Repository: https://github.com/azure-samples/azure-ai-agent-service-enterprise-demo

## Overview

##### Project Type & Purpose
- This is a demo sample showcasing how to build a streaming enterprise agent using the Azure AI Agent Service.
- Its primary goal is to demonstrate programmatically creating or reusing agents with real-time response streaming, document retrieval from enterprise data (e.g., HR policies), and the integration of external services such as Bing Search, OpenWeather, and Azure Logic Apps for tools like email sending.
- It also includes an interactive Gradio UI to display streaming agent responses.

##### File Structure
- Top-level files and directories provide insight into both configuration and functionality:
- .env.example, requirements.txt: Environment setup and dependency management.
- enterprise-functions.py: Likely contains custom Python functions (e.g., weather fetching, stock lookup) that extend agent capabilities.
- enterprise-streaming-agent.ipynb: A Jupyter Notebook that serves as the interactive demonstration and toolset integration example (setting up the agent, connecting to Azure AI Foundry, and launching the Gradio UI).
- Directory "enterprise-data": Contains HR and policy documents that are ingested into a vector store, enabling retrieval-augmented generation (RAG).
- Azure Logic App ARM template file (send_email_logic_app.json): Provides deployment instructions and configuration for sending email via Logic Apps.
- Various GitHub configuration files, LICENSE, CHANGELOG, CONTRIBUTING, etc., are standard for an open-source demo/repository.

##### Main Components & Their Relationships
a. User/Client Interface:
- Gradio-based Chat UI (from the notebook) that users interact with to send queries to the agent.
b. Streaming Enterprise Agent:
- The core service built on the Azure AI Agent Service that processes user queries.
- It is responsible for integrating local enterprise data (HR/policy documents) and performing real-time, streaming responses.
c. Data and Document Management:
- Enterprise Data Store: Represent the "enterprise-data" folder containing HR and company policy documents.
- Vector Store: Automatically created or reused (leveraging Azure AI Search) for embedding documents for RAG.
d. External Integrations/Tools:
- Azure AI Foundry: The connection hub where the agent is created or reused.
- External API Services:
- Bing Search: Integrated as a tool to pull in real-time external data, if configured.
- OpenWeather API: Used in custom Python functions (e.g., fetch_weather) for additional tool functionality.
- Custom Python Functions: Exposed through functions in enterprise_functions.py, such as weather queries or stock price lookups.
- Azure Logic Apps: Shown as an external service for sending emails, integrated via a provided ARM template and configured via environment variables.
e. Configuration and Environment:
- .env file: Acts as the central configuration point for API keys, connection strings, and service parameters.
- The README guides proper setup, ensuring that all environmental connections (Azure AI Foundry, Azure AI Search, Bing, etc.) are active.

##### Architectural Patterns & Design Principles
- Layered / Modular Architecture: Clear separation between the presentation layer (Gradio UI), the business logic (streaming agent and tool orchestration), and infrastructure (external APIs and vector storage).
- Integration Pattern: Use of a ToolSet design where multiple external tools (Bing, file search, custom Python functions, and Logic Apps) are registered and managed.
- Streaming & Real-Time Data Flow: Emphasize the asynchronous, streaming interactions from agent to UI.

##### Final Advice
- Be as detailed as possible: Enumerate every core element even if it seems small (like custom Python functions) to ensure complete clarity.
- Keep the layout logical and intuitive – group related components (backend logic, external integrations, UI) to reflect the layered architecture.
- Verification: Cross-check details against the README (e.g., integration with Azure AI Foundry, Bing, and OpenWeather) and file structure to ensure that every feature and component is captured.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Frontend Layer"
        UI["Gradio Chat UI"]:::frontend
    end

    subgraph "Backend Services"
        Agent["Azure AI Agent"]:::backend
        PythonFunctions["Custom Python Functions"]:::tools
    end

    subgraph "Data Management"
        EnterpriseData["Enterprise Data"]:::data
        VectorStore["Vector Store"]:::data
    end

    subgraph "External Integrations"
        Bing["Bing Search"]:::external
        OpenWeather["OpenWeather API"]:::external
        Foundry["Azure AI Foundry"]:::external
        LogicApps["Azure Logic Apps"]:::external
    end

    subgraph "Configuration & Environment"
        Env[".env Configuration"]:::config
        ARM["Logic Apps ARM Template"]:::config
    end

    %% Data flow connections
    UI -->|"query"| Agent
    Agent -->|"stream_response"| UI

    Agent -->|"invoke"| PythonFunctions
    Agent -->|"access"| EnterpriseData
    Agent -->|"update"| VectorStore

    Agent -->|"call"| Bing
    Agent -->|"call"| OpenWeather
    Agent -->|"deploy"| Foundry
    Agent -->|"trigger"| LogicApps

    Env --> Agent
    ARM --> LogicApps

    %% Click Events
    click UI "https://github.com/azure-samples/azure-ai-agent-service-enterprise-demo/blob/main/enterprise-streaming-agent.ipynb"
    click Agent "https://github.com/azure-samples/azure-ai-agent-service-enterprise-demo/blob/main/enterprise-streaming-agent.ipynb"
    click EnterpriseData "https://github.com/azure-samples/azure-ai-agent-service-enterprise-demo/tree/main/enterprise-data/"
    click PythonFunctions "https://github.com/azure-samples/azure-ai-agent-service-enterprise-demo/blob/main/enterprise_functions.py"
    click Env "https://github.com/azure-samples/azure-ai-agent-service-enterprise-demo/blob/main/.env.example"
    click ARM "https://github.com/azure-samples/azure-ai-agent-service-enterprise-demo/blob/main/send_email_logic_app.json"
    click LogicApps "https://github.com/azure-samples/azure-ai-agent-service-enterprise-demo/blob/main/send_email_logic_app.json"

    %% Styles
    classDef frontend fill:#ffddcc,stroke:#cc3300,stroke-width:2px;
    classDef backend fill:#cce5ff,stroke:#004085,stroke-width:2px;
    classDef data fill:#d4edda,stroke:#155724,stroke-width:2px;
    classDef external fill:#f8d7da,stroke:#721c24,stroke-width:2px;
    classDef config fill:#fff3cd,stroke:#856404,stroke-width:2px;
    classDef tools fill:#d1ecf1,stroke:#0c5460,stroke-width:2px;
```
