# azure-samples/azure-ai-document-processing-samples architecture

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

- Interactive diagram: https://gitdiagram.com/azure-samples/azure-ai-document-processing-samples
- Repository: https://github.com/azure-samples/azure-ai-document-processing-samples

## Overview

##### Project type and purpose
- This is a “sample repository” that demonstrates how to build document-processing workflows using Azure AI services (Azure AI Document Intelligence, Azure OpenAI, Azure AI Language, Azure Translator) and Infrastructure-as-Code (Bicep).
- The repository contains:
- A Dev Container for local/ Codespaces development
- A PowerShell script + Bicep templates under /infra to provision Azure resources
- Sample code and Jupyter notebooks (Python & .NET) under /samples showing classification, extraction, and redaction scenarios.

##### File structure
- Top-level directories:
- .devcontainer – development environment configuration (Docker, VS Code settings, tool installs)
- infra – Bicep templates and deployment scripts to stand up Azure AI Foundry, AI Services, Storage, Key Vault, Monitoring, Container Registry, etc.
- samples – language-specific folders with notebooks and helper modules for each scenario (classification, extraction, redaction)
- Configuration: .env.template, Setup-Environment.ps1, Bicep config files, GitHub CI files, CODEOWNERS, CONTRIBUTING.md.

##### Key architecture points from README
- Dev Container is used to unify tooling and dependencies.
- Setup-Environment.ps1 calls Azure CLI and Bicep to deploy:
- Azure AI Foundry Hub & Project (with serverless GPT, Phi endpoints)
- Azure AI Services (OpenAI, Document Intelligence, Language)
- Azure Storage (for artifacts)
- Azure Monitor (for logs)
- Azure Key Vault + Managed Identity (for secret management)
- Azure Container Registry (for any required containers)
- Sample code runs in that environment and calls AI service endpoints, using credentials stored in Key Vault via Managed Identity.

##### Detail
- Every IaC module folder under infra (ai_ml, storage, security, governance, containers)
- How key Bicep parameters (main.parameters.json) feed into the deployment
- Authentication flow (Managed Identity → Key Vault → AI Services)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Development Environment
    subgraph "Development Environment"
        DevWorkstation["Developer Workstation / Codespace<br/>(Dev Container)"]:::dev
    end

    %% Infrastructure as Code
    subgraph "Infrastructure as Code"
        SetupPS["Setup-Environment.ps1"]:::iac
        DeployPS["Deploy-Infrastructure.ps1"]:::iac
        MainBicep["main.bicep"]:::iac
        MainParams["main.parameters.json"]:::iac
    end

    %% Azure Subscription
    subgraph "Azure Subscription"
        subgraph "Resource Group"
            AIHubHub["Azure AI Foundry Hub"]:::azure
            AIHubProj["Azure AI Foundry Project"]:::azure
            OpenAI["OpenAI Service"]:::azure
            DocInt["Document Intelligence"]:::azure
            LangSvc["Language Service"]:::azure
            Translator["Translator Service"]:::azure
            Storage["Storage Account"]:::azure
            KeyVault["Key Vault"]:::azure
            MI["Managed Identity"]:::azure
            ACR["Container Registry"]:::azure
            LogLA["Log Analytics Workspace"]:::azure
            AppInsights["Application Insights"]:::azure
        end
    end

    %% Runtime Samples
    subgraph "Runtime Samples"
        subgraph ".NET Samples"
            DotNetClass["Classification"]:::runtime
            DotNetExtract["Extraction"]:::runtime
            DotNetRedact["Redaction"]:::runtime
        end
        subgraph "Python Samples"
            PyClass["Classification"]:::runtime
            PyExtract["Extraction"]:::runtime
            PyRedact["Redaction"]:::runtime
        end
        subgraph "Sample Assets"
            Inv["Invoices"]:::runtime
            Veh["Vehicle Insurance"]:::runtime
        end
    end

    %% Connections
    DevWorkstation -->|runs| SetupPS
    SetupPS -->|calls| DeployPS
    SetupPS -->|invokes| MainBicep
    SetupPS -->|uses parameters| MainParams

    MainBicep --> AIHubHub
    MainBicep --> AIHubProj
    MainBicep --> OpenAI
    MainBicep --> DocInt
    MainBicep --> LangSvc
    MainBicep --> Translator
    MainBicep --> Storage
    MainBicep --> KeyVault
    MainBicep --> MI
    MainBicep --> ACR
    MainBicep --> LogLA
    MainBicep --> AppInsights

    MI -->|auth| KeyVault
    MI -->|auth| OpenAI
    MI -->|auth| DocInt
    MI -->|auth| LangSvc
    MI -->|auth| Translator

    Inv -->|read| DotNetClass
    Inv -->|read| PyClass
    Veh -->|read| DotNetExtract
    Veh -->|read| PyExtract

    DotNetClass -->|stores results| Storage
    PyClass -->|stores results| Storage
    DotNetExtract -->|stores results| Storage
    PyExtract -->|stores results| Storage
    DotNetRedact -->|writes back| Storage
    PyRedact -->|writes back| Storage

    DotNetClass -->|calls| OpenAI
    DotNetExtract -->|calls| DocInt
    DotNetRedact -->|calls| LangSvc
    PyClass -->|calls| OpenAI
    PyExtract -->|calls| DocInt
    PyRedact -->|calls| LangSvc

    OpenAI -->|returns results| DotNetClass
    DocInt -->|returns results| DotNetExtract
    LangSvc -->|returns results| DotNetRedact
    OpenAI -->|returns results| PyClass
    DocInt -->|returns results| PyExtract
    LangSvc -->|returns results| PyRedact

    ACR -->|stores images| DevWorkstation
    LogLA -->|collects logs| OpenAI
    AppInsights -->|monitors| AIHubHub

    %% Click Events
    click DevWorkstation "https://github.com/azure-samples/azure-ai-document-processing-samples/blob/main/.devcontainer/devcontainer.json"
    click DevWorkstation "https://github.com/azure-samples/azure-ai-document-processing-samples/blob/main/.devcontainer/post-create.sh"
    click DevWorkstation "https://github.com/azure-samples/azure-ai-document-processing-samples/blob/main/.devcontainer/local-features/dev-tools/devcontainer-feature.json"
    click SetupPS "https://github.com/azure-samples/azure-ai-document-processing-samples/blob/main/Setup-Environment.ps1"
    click DeployPS "https://github.com/azure-samples/azure-ai-document-processing-samples/blob/main/infra/Deploy-Infrastructure.ps1"
    click MainBicep "https://github.com/azure-samples/azure-ai-document-processing-samples/blob/main/infra/main.bicep"
    click MainParams "https://github.com/azure-samples/azure-ai-document-processing-samples/blob/main/infra/main.parameters.json"
    click AIHubHub "https://github.com/azure-samples/azure-ai-document-processing-samples/blob/main/infra/ai_ml/ai-hub.bicep"
    click AIHubProj "https://github.com/azure-samples/azure-ai-document-processing-samples/blob/main/infra/ai_ml/ai-hub-project.bicep"
    click OpenAI "https://github.com/azure-samples/azure-ai-document-processing-samples/blob/main/infra/ai_ml/ai-hub-connection.bicep"
    click DocInt "https://github.com/azure-samples/azure-ai-document-processing-samples/blob/main/infra/ai_ml/ai-services.bicep"
    click LangSvc "https://github.com/azure-samples/azure-ai-document-processing-samples/blob/main/infra/ai_ml/ai-hub-model-serverless-endpoint.bicep"
    click Storage "https://github.com/azure-samples/azure-ai-document-processing-samples/blob/main/infra/storage/storage-account.bicep"
    click KeyVault "https://github.com/azure-samples/azure-ai-document-processing-samples/blob/main/infra/security/key-vault.bicep"
    click KeyVault "https://github.com/azure-samples/azure-ai-document-processing-samples/blob/main/infra/security/key-vault-secret.bicep"
    click MI "https://github.com/azure-samples/azure-ai-document-processing-samples/blob/main/infra/security/managed-identity.bicep"
    click MI "https://github.com/azure-samples/azure-ai-document-processing-samples/blob/main/infra/security/resource-group-role-assignment.bicep"
    click ACR "https://github.com/azure-samples/azure-ai-document-processing-samples/blob/main/infra/containers/container-registry.bicep"
    click LogLA "https://github.com/azure-samples/azure-ai-document-processing-samples/blob/main/infra/management_governance/log-analytics-workspace.bicep"
    click AppInsights "https://github.com/azure-samples/azure-ai-document-processing-samples/blob/main/infra/management_governance/application-insights.bicep"
    click Inv "https://github.com/azure-samples/azure-ai-document-processing-samples/tree/main/samples/assets/invoices/"
    click Veh "https://github.com/azure-samples/azure-ai-document-processing-samples/tree/main/samples/assets/vehicle_insurance/"
    click DotNetClass "https://github.com/azure-samples/azure-ai-document-processing-samples/tree/main/samples/dotnet/classification/"
    click DotNetExtract "https://github.com/azure-samples/azure-ai-document-processing-samples/tree/main/samples/dotnet/extraction/"
    click DotNetRedact "https://github.com/azure-samples/azure-ai-document-processing-samples/tree/main/samples/dotnet/redaction/"
    click PyClass "https://github.com/azure-samples/azure-ai-document-processing-samples/tree/main/samples/python/classification/"
    click PyExtract "https://github.com/azure-samples/azure-ai-document-processing-samples/tree/main/samples/python/extraction/"
    click PyRedact "https://github.com/azure-samples/azure-ai-document-processing-samples/tree/main/samples/python/redaction/"

    %% Styles
    classDef dev fill:#dddddd,stroke:#888888,stroke-width:1px
    classDef iac fill:#bbe1fa,stroke:#1b98e0,stroke-width:1px
    classDef azure fill:#d4f5d4,stroke:#2d9a2d,stroke-width:1px
    classDef runtime fill:#fff3b0,stroke:#e09f3e,stroke-width:1px
```
