# microsoft/content-processing-solution-accelerator architecture

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

- Interactive diagram: https://gitdiagram.com/microsoft/content-processing-solution-accelerator
- Repository: https://github.com/microsoft/content-processing-solution-accelerator

## Overview

##### Project type and purpose
- This is a full-stack, event-driven content processing accelerator built on Azure.
- It ingests unstructured multi-modal content, applies ML/OCR and schema mapping via Azure AI services, scores results, stores outputs, and exposes APIs and a web UI for integration and human validation.

##### File structure
- Top-level directories:
- infra – Bicep templates and scripts provisioning Azure resources (Container Apps, Blob, Queue, Cosmos DB, Key Vault, App Configuration, AI services, etc.)
- src/ContentProcessor – Python worker application in a container that processes queue messages, calls AI services, writes to storage/Cosmos
- src/ContentProcessorAPI – Python web API container exposing REST endpoints for ingestion and status, interacting with storage, queue, Cosmos
- src/ContentProcessorWeb – React/TypeScript single-page app with MSAL authentication, calling the API
- CI/CD and development configs: GitHub workflows, Dev Containers, Dockerfiles, linting, testing.

##### README for additional insights
- Architecture uses Azure AI Foundry, Content Understanding, OpenAI, Blob Storage, Queue Storage, Cosmos DB, Container Registry, and Container Apps.
- Processing pipeline is event-driven: upload → queue → worker → database → API → UI.
- Human-in-the-loop review when confidence thresholds are not met.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User and Auth
    A["User / Upstream System"]:::user
    AD["Azure AD (MSAL Auth)"]:::service

    %% Storage Layer
    subgraph "Storage & Event Layer"
        direction TB
        Blob["Azure Blob Storage"]:::storage
        Queue["Azure Queue Storage"]:::storage
    end

    %% Compute Layer
    subgraph "Processing Layer (Container Apps)" 
        direction TB
        subgraph "Azure Container Apps Environment"
            direction TB
            Worker["ContentProcessor (Worker)"]:::compute
            API["ContentProcessorAPI (Web API)"]:::compute
        end
    end

    %% Data Layer & Services
    subgraph "Data & AI Services"
        direction TB
        Cosmos["Azure Cosmos DB"]:::storage
        AI1["Azure AI Foundry"]:::service
        AI2["Content Understanding & OpenAI"]:::service
        KV["Azure Key Vault"]:::service
        AppConfig["Azure App Configuration"]:::service
        Insights["Azure Application Insights"]:::service
    end

    %% Container Registry
    ACR["Azure Container Registry"]:::service

    %% Frontend
    subgraph "Presentation Layer"
        direction TB
        UI["ContentProcessorWeb (React SPA)"]:::ui
    end

    %% CI/CD & Infra
    subgraph "Infrastructure as Code & CI/CD"
        direction TB
        Infra["Azure Infra Layer (Bicep)"]:::infra
        CICD["GitHub Actions Pipelines"]:::infra
        DockerCfg["Docker & DevContainer Configs"]:::infra
    end

    %% Relationships
    A -->|"Upload Document"| Blob
    Blob -->|"Event Grid → Enqueue"| Queue
    Queue -->|"Trigger"| Worker
    Worker -->|"Read/Write"| Blob
    Worker -->|"Process via"| AI1
    Worker -->|"Process via"| AI2
    Worker -->|"Write JSON"| Cosmos
    Worker -->|"Use Config/Secrets"| KV
    Worker -->|"Use Config"| AppConfig
    Worker -->|"Logs/Telemetry"| Insights

    API -->|"Read/Write"| Blob
    API -->|"Enqueue"| Queue
    API -->|"Read from"| Cosmos
    API -->|"Use Config/Secrets"| KV
    API -->|"Use Config"| AppConfig
    API -->|"Logs/Telemetry"| Insights

    UI -->|"Auth via MSAL"| AD
    UI -->|"Call REST API"| API

    ACR -->|"Holds Images"| Worker
    ACR -->|"Holds Images"| API
    ACR -->|"Holds Images"| UI

    Infra -->|"Provision Resources"| Blob
    Infra -->|"Provision Resources"| Queue
    Infra -->|"Provision Resources"| ACR
    Infra -->|"Provision Resources"| Cosmos
    Infra -->|"Provision Resources"| KV
    Infra -->|"Provision Resources"| AppConfig
    Infra -->|"Provision Resources"| Insights
    Infra -->|"Provision Resources"| AI1
    Infra -->|"Provision Resources"| AI2
    Infra -->|"Provision Resources"| Worker
    Infra -->|"Provision Resources"| API

    CICD -->|"Build & Deploy"| ACR
    CICD -->|"Deploy to"| Worker
    CICD -->|"Deploy to"| API
    CICD -->|"Deploy to"| UI

    DockerCfg -->|"Defines Images"| Worker
    DockerCfg -->|"Defines Images"| API
    DockerCfg -->|"Defines Images"| UI

    %% Click Events - Infra
    click Infra "https://github.com/microsoft/content-processing-solution-accelerator/tree/main/infra/"
    click Blob "https://github.com/microsoft/content-processing-solution-accelerator/blob/main/infra/deploy_storage_account.bicep"
    click Queue "https://github.com/microsoft/content-processing-solution-accelerator/blob/main/infra/deploy_storage_account.bicep"
    click ACR "https://github.com/microsoft/content-processing-solution-accelerator/blob/main/infra/deploy_container_registry.bicep"
    click Worker "https://github.com/microsoft/content-processing-solution-accelerator/blob/main/infra/container_app/deploy_container_app.bicep"
    click API "https://github.com/microsoft/content-processing-solution-accelerator/blob/main/infra/container_app/deploy_container_app_api_web.bicep"
    click Cosmos "https://github.com/microsoft/content-processing-solution-accelerator/blob/main/infra/deploy_cosmos_db.bicep"
    click KV "https://github.com/microsoft/content-processing-solution-accelerator/blob/main/infra/deploy_keyvault.bicep"
    click AppConfig "https://github.com/microsoft/content-processing-solution-accelerator/blob/main/infra/deploy_app_config_service.bicep"
    click Insights "https://github.com/microsoft/content-processing-solution-accelerator/blob/main/infra/deploy_app_insights.bicep"
    click AI1 "https://github.com/microsoft/content-processing-solution-accelerator/blob/main/infra/deploy_ai_foundry.bicep"
    click AI2 "https://github.com/microsoft/content-processing-solution-accelerator/blob/main/infra/deploy_doc_intelligence.bicep"
    click Infra "https://github.com/microsoft/content-processing-solution-accelerator/blob/main/infra/deploy_managed_identity.bicep"
    click Infra "https://github.com/microsoft/content-processing-solution-accelerator/blob/main/infra/deploy_role_assignments.bicep"

    %% Click Events - Application Code
    click srcMain "https://github.com/microsoft/content-processing-solution-accelerator/blob/main/src/ContentProcessor/src/main.py"
    click srcLibs "https://github.com/microsoft/content-processing-solution-accelerator/tree/main/src/ContentProcessor/src/libs/"
    click apiMain "https://github.com/microsoft/content-processing-solution-accelerator/blob/main/src/ContentProcessorAPI/app/main.py"
    click apiRouter "https://github.com/microsoft/content-processing-solution-accelerator/blob/main/src/ContentProcessorAPI/app/routers/contentprocessor.py"
    click webApp "https://github.com/microsoft/content-processing-solution-accelerator/blob/main/src/ContentProcessorWeb/src/App.tsx"
    click webComp "https://github.com/microsoft/content-processing-solution-accelerator/tree/main/src/ContentProcessorWeb/src/Components/"
    click webAuth "https://github.com/microsoft/content-processing-solution-accelerator/tree/main/src/ContentProcessorWeb/src/msal-auth/"
    click ci1 "https://github.com/microsoft/content-processing-solution-accelerator/blob/main/.github/workflows/build-docker-image.yml"
    click ci2 "https://github.com/microsoft/content-processing-solution-accelerator/blob/main/.github/workflows/deploy.yml"
    click ci3 "https://github.com/microsoft/content-processing-solution-accelerator/blob/main/.github/workflows/azure-dev.yaml"
    click docker1 "https://github.com/microsoft/content-processing-solution-accelerator/tree/main/src/ContentProcessor/Dockerfile"
    click docker2 "https://github.com/microsoft/content-processing-solution-accelerator/tree/main/src/ContentProcessorAPI/Dockerfile"
    click docker3 "https://github.com/microsoft/content-processing-solution-accelerator/tree/main/src/ContentProcessorWeb/Dockerfile"
    click devc "https://github.com/microsoft/content-processing-solution-accelerator/tree/main/.devcontainer/"
    click appConf1 "https://github.com/microsoft/content-processing-solution-accelerator/blob/main/src/ContentProcessor/src/libs/application/application_configuration.py"
    click appConf2 "https://github.com/microsoft/content-processing-solution-accelerator/blob/main/src/ContentProcessorAPI/app/libs/app_configuration/helper.py"

    %% Styles
    classDef storage fill:#D0E8FF,stroke:#0366D6,color:#0366D6;
    classDef compute fill:#D5F5E3,stroke:#28B463,color:#1D8348;
    classDef service fill:#F5EEF8,stroke:#9B59B6,color:#6C3483;
    classDef ui fill:#FCF3CF,stroke:#F1C40F,color:#B7950B;
    classDef infra fill:#E5E7E9,stroke:#566573,color:#2C3E50;
    classDef user fill:#FDEDEC,stroke:#C0392B,color:#922B21;
```
