# microsoft/deploy-your-ai-application-in-production architecture

> Architecture diagram of the GitHub repository microsoft/deploy-your-ai-application-in-production, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-31). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/microsoft/deploy-your-ai-application-in-production
- Repository: https://github.com/microsoft/deploy-your-ai-application-in-production

## Overview

##### Main Components
- Infrastructure orchestration: The “infra” directory holds the Bicep files and JSON templates that provision core resources.
- Network components: Virtual Network, private endpoints (see infra/modules/virtualNetwork.bicep, privateEndpoints.bicep).
- Compute resources: The jumpbox virtual machine is used for admin access (as mentioned in the README) and potentially other managed compute resources (e.g., serverless functions from modules/functions.bicep).
- Data and storage: Includes optional databases such as Cosmos DB (modules/cosmosDb.bicep), SQL Server (modules/sqlServer.bicep) and storage account.
- Security components: Managed Identity, Key Vault, Microsoft Entra ID for authentication, API Management (as per the architecture steps outlined in the README).
- Additional modules: Custom types and VM provisioning modules (modules/customTypes, virtualMachine.bicep) and developer tooling support files (Dev Containers, GitHub workflows).

##### Relationships and Interactions
- Data flows from tenant users (logging in via Microsoft Entra ID and MFA) to the jumpbox VM and onward to the managed network.
- Communication between resources happens through private endpoints ensuring that external public traffic is blocked.
- API Management acts as the gateway between backend services and client applications.
- The infrastructure as code components (Bicep/JSON templates) tie together each resource, ensuring that network, compute, and storage resources are cohesively provisioned.
- Managed identities are used to secure communications among services without needing static credentials.

##### Architectural Patterns
- Infrastructure-as-Code: The extensive use of Bicep and JSON files indicates a declarative approach for resource provisioning.
- Network Isolation: The design follows a fully isolated production environment using virtual networking, jumpbox access and private endpoints.
- Security-by-Design: Incorporates role-based access control (via Entra ID), managed identities, and private endpoints to adhere to best practices.
- Modularity: The infra directory is modularized into separate components (Cosmos DB, SQL Server, VM, etc.) which supports extensibility and clarity.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Provisioning Layer
    subgraph "Provisioning Layer (Deployment Automation)"
        A["Infrastructure Orchestration"]:::provisioning
        subgraph "Infra Modules"
            A1["Virtual Network Module"]:::network
            A2["Private Endpoints Module"]:::network
            A3["Jumpbox VM Module"]:::compute
            A4["Serverless Functions Module"]:::compute
            A5["Cosmos DB Module (Optional)"]:::data
            A6["SQL Server Module (Optional)"]:::data
            A7["Custom Types Module"]:::additional
        end
    end

    %% Secure Network Layer
    subgraph "Secure Network Layer"
        B["Virtual Network (vNet)"]:::network
        C["Private Endpoints"]:::network
        D["Jumpbox VM"]:::compute
    end

    %% Application/Data Layer
    subgraph "Application/Data Layer"
        E["API Management"]:::app
        F["Cosmos DB (Optional)"]:::data
        G["SQL Server (Optional)"]:::data
        H["Key Vault"]:::security
        I["Managed Identity"]:::security
        J["Microsoft Entra ID"]:::security
    end

    %% Other Components
    K["Developer Tooling Support"]:::dev
    K2["GitHub Workflows"]:::dev
    L["Tenant Users (with MFA)"]:::user

    %% Relationships within Provisioning Layer
    A --> A1
    A --> A2
    A --> A3
    A --> A4
    A --> A5
    A --> A6
    A --> A7

    %% Provisioning layer provisions runtime components
    A1 -->|"provisions"| B
    A2 -->|"provisions"| C
    A3 -->|"provisions"| D
    A5 -->|"provisions"| F
    A6 -->|"provisions"| G
    A -->|"orchestrates"| E

    %% User and Security Flow
    L -->|"authenticates"| J
    L -->|"accesses"| D
    J -->|"secures"| D

    %% Network and Application Flow
    C -->|"connects"| E
    E -->|"routesTo"| F
    E -->|"routesTo"| G
    I -->|"secures"| H
    I -->|"secures"| F
    I -->|"secures"| G

    %% Class Definitions with Colors
    classDef provisioning fill:#FAD7A0,stroke:#E67E22,stroke-width:2px;
    classDef network fill:#AED6F1,stroke:#5DADE2,stroke-width:2px;
    classDef compute fill:#F5B7B1,stroke:#EC7063,stroke-width:2px;
    classDef data fill:#A9DFBF,stroke:#58D68D,stroke-width:2px;
    classDef additional fill:#D7BDE2,stroke:#AF7AC5,stroke-width:2px;
    classDef app fill:#F9E79F,stroke:#F4D03F,stroke-width:2px;
    classDef security fill:#D1F2EB,stroke:#48C9B0,stroke-width:2px;
    classDef dev fill:#E8DAEF,stroke:#AF7AC5,stroke-width:2px;
    classDef user fill:#FCF3CF,stroke:#F7DC6F,stroke-width:2px;

    %% Click Events for Component Mapping
    click A1 "https://github.com/microsoft/deploy-your-ai-application-in-production/blob/main/infra/modules/virtualNetwork.bicep"
    click A2 "https://github.com/microsoft/deploy-your-ai-application-in-production/blob/main/infra/modules/privateEndpoints.bicep"
    click A3 "https://github.com/microsoft/deploy-your-ai-application-in-production/blob/main/infra/modules/virtualMachine.bicep"
    click A4 "https://github.com/microsoft/deploy-your-ai-application-in-production/blob/main/infra/modules/functions.bicep"
    click A5 "https://github.com/microsoft/deploy-your-ai-application-in-production/blob/main/infra/modules/cosmosDb.bicep"
    click A6 "https://github.com/microsoft/deploy-your-ai-application-in-production/blob/main/infra/modules/sqlServer.bicep"
    click A7 "https://github.com/microsoft/deploy-your-ai-application-in-production/blob/main/infra/modules/customTypes.bicep"
    click A "https://github.com/microsoft/deploy-your-ai-application-in-production/blob/main/infra/main.bicep"
    click K "https://github.com/microsoft/deploy-your-ai-application-in-production/blob/main/devcontainer/devcontainer.json"
    click K2 "https://github.com/microsoft/deploy-your-ai-application-in-production/blob/main/.github/workflows/azd-template-validation.yml"
```
