> ## Documentation Index
> Fetch the complete documentation index at: https://docs.khanhng.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 2.1 Building Block View

The backend blocks below are implemented in the repository; the Azure hosting arrangement is a deployment design, not a verified deployed inventory. The Next.js frontend is under active development.

```mermaid theme={null}
flowchart TB
    CustomerUI[Container: Next.js customer and reviewer UI<br/>Azure Static Web Apps]
    API[Container: FastAPI application<br/>Azure Container Apps Consumption]
    Workflow[Container: Durable refund workflow<br/>Azure Functions Flex Consumption]
    Agent[Component: Bounded assessment graph<br/>Microsoft Agent Framework]
    Repos[Component: Claim and order repositories<br/>Python interfaces and Cosmos adapters]
    Quarantine[Container: Quarantine and evidence blobs<br/>Azure Blob Storage]
    Cosmos[Container: Claim and order state<br/>Cosmos DB for NoSQL serverless]
    Search[External System: Refund policy index<br/>Azure AI Search]
    AI[External System: Content Safety, Document Intelligence, Foundry]
    Stripe[External System: Stripe test mode]
    Email[External System: Communication Services Email]
    Telemetry[Container: Application telemetry<br/>Application Insights and Log Analytics]
    KeyVault[Container: Secrets and runtime configuration<br/>Azure Key Vault]

    CustomerUI -->|HTTPS API requests and status| API
    API -->|Claim and order reads/writes| Repos
    Repos -->|Partitioned claim records| Cosmos
    CustomerUI -->|Short-lived upload grant| Quarantine
    Workflow -->|Scan, validate, extract, promote| Quarantine
    Workflow -->|Workflow state and activity data| Cosmos
    Workflow -->|Policy retrieval| Search
    Workflow -->|Safety and extraction requests| AI
    Workflow -->|Assessment request| Agent
    Agent -->|Bounded model response| AI
    Workflow -->|Approved idempotent refund| Stripe
    Stripe -->|Signed refund status webhook| API
    Workflow -->|Customer status email| Email
    API -->|Trace and business-safe status| Telemetry
    Workflow -->|Trace and business-safe status| Telemetry
    API -->|Runtime secrets| KeyVault
    Workflow -->|Runtime secrets| KeyVault
```

## Responsibilities

| Building block | Responsibility | Owned data or state |
| - | - | - |
| Web client | Next.js customer, reviewer, and operations experience under active development. | Browser state only. |
| FastAPI application | Authenticate callers, enforce roles and claim ownership, expose claim, upload, review, admin, and webhook routes. | API request handling; persistent state belongs to repositories. |
| Durable workflow | Coordinate scans, extraction, assessment, reviewer wait, timeout, refund, and status notification. | Workflow instance and durable event state. |
| Assessment graph | Run deterministic prechecks and a bounded policy-grounded model assessment. | Assessment output and trace metadata. |
| Claim repository | Store claims and claim aggregate items; partition claim data by claim ID. | Claims, documents, assessments, approvals, refunds, audit items. |
| Order repository | Verify ownership and paid amount before claim creation and refund execution. | Showcase order record and PaymentIntent reference. |
| Blob storage | Keep uploads quarantined until checks pass; store promoted evidence. | Uploaded files and processing tags. |
| AI and payment adapters | Call selected Azure AI services and Stripe test mode. | No authority to approve a claim. |

The agent is deliberately not given approval, payment, email, storage, or database tools.

The repository supplies Azure infrastructure definitions and configuration requirements. This diagram does not establish that the resources are deployed. Account-specific endpoints and credentials must be supplied through the approved environment configuration.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.