# microsoft/azure-ai-search-foundry-iq-live-knowledge-sources architecture

> Architecture diagram of the GitHub repository microsoft/azure-ai-search-foundry-iq-live-knowledge-sources, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-22). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/microsoft/azure-ai-search-foundry-iq-live-knowledge-sources
- Repository: https://github.com/microsoft/azure-ai-search-foundry-iq-live-knowledge-sources

## Overview

#### Purpose and Entry Points
This accelerator deploys, exercises, and inspects Foundry IQ Knowledge Bases that compose Azure AI Search MCP Server and Fabric Ontology knowledge sources. It supports offline replay, MCP-only Azure deployments, BYO Fabric, and greenfield Fabric.

Primary lifecycle entry points are `liveks` and `liveks.ps1`; Python CLI implementation is in `src/liveks/cli.py` and runtime orchestration in `src/liveks/runtime.py`.

#### Configuration and Profile Boundary
A versioned YAML ledger is the canonical deployment input. The CLI validates it, resolves secret environment references, derives names, projects settings into `azd`, and records redacted deployment state. Profiles define the supported deployment modes and prevent incompatible Fabric ownership configurations.

Paths: `config/schema.yaml`, `profiles/mcp-only.yaml`, `profiles/byo-fabric.yaml`, `src/liveks/config.py`.

#### Lifecycle Planner and Safety Controls
The CLI implements bootstrap/init, doctor, plan, up, verify, e2e, and down flows. Planning is intentionally non-mutating; provisioning requires explicit confirmation. Cleanup is ownership-aware: BYO Fabric is retained, while generated full-profile Fabric assets can be removed only when configuration and deployment lock agree.

Paths: `src/liveks/runtime.py`, `src/liveks/diagnostics.py`, `scripts/deploy.sh`, `scripts/destroy.sh`.

#### Knowledge Source and Knowledge Base Construction
Python factory modules construct preview Azure AI Search payloads for:
1. remote HTTPS MCP Server knowledge sources,
2. Fabric Ontology knowledge sources,
3. a Foundry IQ Knowledge Base that routes retrieval to one or both sources.

The resulting retrieve response is the key product contract: one answer plus `activity`, `references`, and `sourceData` evidence. API behavior is tied to Azure AI Search preview APIs.

Paths: `src/ks_factory/mcp_server.py`, `src/ks_factory/fabric_ontology.py`, `src/ks_factory/knowledge_base.py`.

#### Azure and Fabric Provisioning
Azure Developer CLI coordinates infrastructure deployment. Bicep provisions Azure AI Search, Azure OpenAI, Storage, and hosting resources. Post-provision scripts create/configure knowledge-source resources and deployment artifacts. Separate Fabric automation can create capacity, workspace, Lakehouse, ontology, and GraphModel for the `full` profile.

Paths: `azure.yaml`, `infra/main.bicep`, `scripts/postprovision.py`, `scripts/fabric-provision.py`.

#### Retrieval UI and Managed API Boundary
The optional demo is an Azure Static Web Apps frontend backed by managed Node.js Azure Functions. Browser code calls API endpoints for MCP, Fabric, combined retrieval, status, and deployment summary; sensitive Search/OpenAI credentials remain server-side. Offline mode replays checked-in response data rather than asserting live retrieval.

Paths: `static-app/src/main.js`, `static-app/api/retrieve-combined/index.js`, `static-app/api/shared/search.js`, `static-app/api/shared/offline.js`.

#### External Services and Domain Inputs
Material dependencies are Azure AI Search/Foundry IQ, Azure OpenAI, Azure Static Web Apps/Functions, Azure Storage, Azure Developer CLI, and optionally Microsoft Fabric. MCP retrieval requires a remote HTTPS MCP server; the sample uses Microsoft Learn. Fabric retrieval requires an end-user search token. Airline Operations CSVs and ontology contract are synthetic demonstration inputs, not a required runtime data plane.

Paths: `samples/ontology/airline-ops/ontology-contract.yaml`, `samples/data/airline-ops/`, `samples/responses/combined-airline-ops-retrieve.sample.json`.

Main entry points: [`src/liveks/runtime.py`](https://github.com/microsoft/azure-ai-search-foundry-iq-live-knowledge-sources/blob/main/src/liveks/runtime.py) (Runtime orchestrator), [`src/ks_factory/mcp_server.py`](https://github.com/microsoft/azure-ai-search-foundry-iq-live-knowledge-sources/blob/main/src/ks_factory/mcp_server.py) (Knowledge source factories), [`static-app/api/retrieve-combined/index.js`](https://github.com/microsoft/azure-ai-search-foundry-iq-live-knowledge-sources/blob/main/static-app/api/retrieve-combined/index.js) (Managed retrieval API), [`src/liveks/config.py`](https://github.com/microsoft/azure-ai-search-foundry-iq-live-knowledge-sources/blob/main/src/liveks/config.py) (Config ledger)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_lifecycle["Lifecycle Control"]
  node_cli["liveks CLI<br/>Python CLI<br/>[cli.py]"]
  node_runtime["Runtime orchestrator<br/>Python runtime<br/>[runtime.py]"]
  node_config["Config ledger<br/>YAML configuration<br/>[config.py]"]
  node_schema["Config schema<br/>YAML schema<br/>[schema.yaml]"]
  node_profiles["Deployment profiles<br/>YAML profiles<br/>[mcp-only.yaml]"]
  node_diagnostics["Doctor and safety checks<br/>runtime safeguards<br/>[runtime.py]"]
end

subgraph group_construction["Knowledge Construction"]
  node_factories["Knowledge source factories<br/>Python factories<br/>[mcp_server.py]"]
  node_knowledge_base["Knowledge Base factory<br/>Python factory<br/>[knowledge_base.py]"]
end

subgraph group_provisioning["Provisioning"]
  node_azd{{"Azure Developer CLI<br/>deployment tool<br/>[azure.yaml]"}}
  node_bicep["Azure infrastructure<br/>Bicep<br/>[main.bicep]"]
  node_postprovision["Post-provision setup<br/>Python automation<br/>[postprovision.py]"]
  node_fabric_provision["Fabric provisioner<br/>Python automation"]
end

subgraph group_demo["Retrieval Demo"]
  node_api["Managed retrieval API<br/>Node.js Functions<br/>[index.js]"]
  node_web["Retrieval UI<br/>Static Web App<br/>[main.js]"]
  node_offline["Offline replay<br/>response replay<br/>[offline.js]"]
end

node_search[("Azure AI Search / Foundry IQ<br/>managed retrieval service")]
node_openai{{"Azure OpenAI<br/>managed AI service"}}
node_fabric[("Microsoft Fabric<br/>optional knowledge source")]
node_mcp{{"Remote HTTPS MCP server<br/>external knowledge source"}}
node_sample_response["Sample retrieve response<br/>JSON fixture"]
node_ontology_input["Airline ontology input<br/>synthetic sample"]

node_cli -->|"invokes"| node_runtime
node_runtime -->|"loads and resolves"| node_config
node_config -->|"validates against"| node_schema
node_config -->|"selects"| node_profiles
node_runtime -->|"runs"| node_diagnostics
node_runtime -->|"projects settings and deploys"| node_azd
node_azd -->|"deploys"| node_bicep
node_bicep -->|"provisions"| node_search
node_bicep -->|"provisions"| node_openai
node_azd -->|"runs"| node_postprovision
node_postprovision -->|"uses payloads from"| node_factories
node_postprovision -->|"uses payload from"| node_knowledge_base
node_factories -->|"creates knowledge sources"| node_search
node_knowledge_base -->|"creates Knowledge Base"| node_search
node_factories -->|"configures remote source"| node_mcp
node_factories -->|"configures ontology source"| node_fabric
node_profiles -.->|"full profile enables"| node_fabric_provision
node_fabric_provision -->|"creates Fabric assets"| node_fabric
node_ontology_input -.->|"supplies demo ontology"| node_fabric_provision
node_web -->|"calls retrieval endpoints"| node_api
node_api -->|"executes retrieval"| node_search
node_api -->|"uses server-side credentials"| node_openai
node_api -.->|"uses in offline mode"| node_offline
node_offline -->|"replays"| node_sample_response

click node_cli "https://github.com/microsoft/azure-ai-search-foundry-iq-live-knowledge-sources/blob/main/src/liveks/cli.py"
click node_runtime "https://github.com/microsoft/azure-ai-search-foundry-iq-live-knowledge-sources/blob/main/src/liveks/runtime.py"
click node_config "https://github.com/microsoft/azure-ai-search-foundry-iq-live-knowledge-sources/blob/main/src/liveks/config.py"
click node_schema "https://github.com/microsoft/azure-ai-search-foundry-iq-live-knowledge-sources/blob/main/config/schema.yaml"
click node_profiles "https://github.com/microsoft/azure-ai-search-foundry-iq-live-knowledge-sources/blob/main/profiles/mcp-only.yaml"
click node_diagnostics "https://github.com/microsoft/azure-ai-search-foundry-iq-live-knowledge-sources/blob/main/src/liveks/runtime.py"
click node_azd "https://github.com/microsoft/azure-ai-search-foundry-iq-live-knowledge-sources/blob/main/azure.yaml"
click node_bicep "https://github.com/microsoft/azure-ai-search-foundry-iq-live-knowledge-sources/blob/main/infra/main.bicep"
click node_postprovision "https://github.com/microsoft/azure-ai-search-foundry-iq-live-knowledge-sources/blob/main/scripts/postprovision.py"
click node_fabric_provision "https://github.com/microsoft/azure-ai-search-foundry-iq-live-knowledge-sources/blob/main/scripts/fabric-provision.py"
click node_factories "https://github.com/microsoft/azure-ai-search-foundry-iq-live-knowledge-sources/blob/main/src/ks_factory/mcp_server.py"
click node_knowledge_base "https://github.com/microsoft/azure-ai-search-foundry-iq-live-knowledge-sources/blob/main/src/ks_factory/knowledge_base.py"
click node_api "https://github.com/microsoft/azure-ai-search-foundry-iq-live-knowledge-sources/blob/main/static-app/api/retrieve-combined/index.js"
click node_web "https://github.com/microsoft/azure-ai-search-foundry-iq-live-knowledge-sources/blob/main/static-app/src/main.js"
click node_offline "https://github.com/microsoft/azure-ai-search-foundry-iq-live-knowledge-sources/blob/main/static-app/api/shared/offline.js"
click node_sample_response "https://github.com/microsoft/azure-ai-search-foundry-iq-live-knowledge-sources/blob/main/samples/responses/combined-airline-ops-retrieve.sample.json"
click node_ontology_input "https://github.com/microsoft/azure-ai-search-foundry-iq-live-knowledge-sources/blob/main/samples/ontology/airline-ops/ontology-contract.yaml"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_cli,node_runtime,node_config,node_schema,node_profiles,node_diagnostics toneBlue
class node_factories,node_knowledge_base toneAmber
class node_azd,node_bicep,node_postprovision,node_fabric_provision toneMint
class node_api,node_web,node_offline toneRose
class node_search,node_openai,node_fabric,node_mcp,node_sample_response,node_ontology_input toneNeutral
```

## Components

### Lifecycle Control

- [liveks CLI](https://github.com/microsoft/azure-ai-search-foundry-iq-live-knowledge-sources/blob/main/src/liveks/cli.py): Python CLI · Lifecycle entry point. · `src/liveks/cli.py`
- [Runtime orchestrator](https://github.com/microsoft/azure-ai-search-foundry-iq-live-knowledge-sources/blob/main/src/liveks/runtime.py): Python runtime · Runs init, plan, up, verify, e2e, and down flows. · `src/liveks/runtime.py`
- [Config ledger](https://github.com/microsoft/azure-ai-search-foundry-iq-live-knowledge-sources/blob/main/src/liveks/config.py): YAML configuration · Validated deployment input with secret references and derived names. · `src/liveks/config.py`
- [Config schema](https://github.com/microsoft/azure-ai-search-foundry-iq-live-knowledge-sources/blob/main/config/schema.yaml): YAML schema · `config/schema.yaml`
- [Deployment profiles](https://github.com/microsoft/azure-ai-search-foundry-iq-live-knowledge-sources/blob/main/profiles/mcp-only.yaml): YAML profiles · Constrain MCP-only and BYO Fabric ownership modes. · `profiles/mcp-only.yaml`
- [Doctor and safety checks](https://github.com/microsoft/azure-ai-search-foundry-iq-live-knowledge-sources/blob/main/src/liveks/runtime.py): runtime safeguards · Supports non-mutating planning and ownership-aware cleanup. · `src/liveks/runtime.py`

### Knowledge Construction

- [Knowledge source factories](https://github.com/microsoft/azure-ai-search-foundry-iq-live-knowledge-sources/blob/main/src/ks_factory/mcp_server.py): Python factories · Builds MCP and Fabric Ontology preview payloads. · `src/ks_factory/mcp_server.py`
- [Knowledge Base factory](https://github.com/microsoft/azure-ai-search-foundry-iq-live-knowledge-sources/blob/main/src/ks_factory/knowledge_base.py): Python factory · Builds Foundry IQ retrieval routing payloads. · `src/ks_factory/knowledge_base.py`

### Provisioning

- [Azure Developer CLI](https://github.com/microsoft/azure-ai-search-foundry-iq-live-knowledge-sources/blob/main/azure.yaml): deployment tool · `azure.yaml`
- [Azure infrastructure](https://github.com/microsoft/azure-ai-search-foundry-iq-live-knowledge-sources/blob/main/infra/main.bicep): Bicep · Provisions Search, OpenAI, Storage, and hosting. · `infra/main.bicep`
- [Post-provision setup](https://github.com/microsoft/azure-ai-search-foundry-iq-live-knowledge-sources/blob/main/scripts/postprovision.py): Python automation · Creates knowledge-source resources and deployment artifacts. · `scripts/postprovision.py`
- [Fabric provisioner](https://github.com/microsoft/azure-ai-search-foundry-iq-live-knowledge-sources/blob/main/scripts/fabric-provision.py): Python automation · Creates full-profile Fabric capacity, workspace, Lakehouse, ontology, and GraphModel. · `scripts/fabric-provision.py`

### Retrieval Demo

- [Managed retrieval API](https://github.com/microsoft/azure-ai-search-foundry-iq-live-knowledge-sources/blob/main/static-app/api/retrieve-combined/index.js): Node.js Functions · Keeps Search and OpenAI credentials server-side. · `static-app/api/retrieve-combined/index.js`
- [Retrieval UI](https://github.com/microsoft/azure-ai-search-foundry-iq-live-knowledge-sources/blob/main/static-app/src/main.js): Static Web App · Calls MCP, Fabric, combined retrieval, status, and summary endpoints. · `static-app/src/main.js`
- [Offline replay](https://github.com/microsoft/azure-ai-search-foundry-iq-live-knowledge-sources/blob/main/static-app/api/shared/offline.js): response replay · Returns checked-in retrieval responses without live assertions. · `static-app/api/shared/offline.js`

### Other components

- **Azure AI Search / Foundry IQ**: managed retrieval service · Hosts preview knowledge sources and Knowledge Bases.
- **Azure OpenAI**: managed AI service
- **Microsoft Fabric**: optional knowledge source · Provides ontology retrieval for BYO or full profiles.
- **Remote HTTPS MCP server**: external knowledge source · Microsoft Learn is the sample source.
- [Sample retrieve response](https://github.com/microsoft/azure-ai-search-foundry-iq-live-knowledge-sources/blob/main/samples/responses/combined-airline-ops-retrieve.sample.json): JSON fixture · Defines answer, activity, references, and sourceData evidence. · `samples/responses/combined-airline-ops-retrieve.sample.json`
- [Airline ontology input](https://github.com/microsoft/azure-ai-search-foundry-iq-live-knowledge-sources/blob/main/samples/ontology/airline-ops/ontology-contract.yaml): synthetic sample · Demonstration ontology contract and CSV inputs. · `samples/ontology/airline-ops/ontology-contract.yaml`

## Connections

- liveks CLI → Runtime orchestrator: invokes
- Runtime orchestrator → Config ledger: loads and resolves
- Config ledger → Config schema: validates against
- Config ledger → Deployment profiles: selects
- Runtime orchestrator → Doctor and safety checks: runs
- Runtime orchestrator → Azure Developer CLI: projects settings and deploys
- Azure Developer CLI → Azure infrastructure: deploys
- Azure infrastructure → Azure AI Search / Foundry IQ: provisions
- Azure infrastructure → Azure OpenAI: provisions
- Azure Developer CLI → Post-provision setup: runs
- Post-provision setup → Knowledge source factories: uses payloads from
- Post-provision setup → Knowledge Base factory: uses payload from
- Knowledge source factories → Azure AI Search / Foundry IQ: creates knowledge sources
- Knowledge Base factory → Azure AI Search / Foundry IQ: creates Knowledge Base
- Knowledge source factories → Remote HTTPS MCP server: configures remote source
- Knowledge source factories → Microsoft Fabric: configures ontology source
- Deployment profiles → Fabric provisioner: full profile enables
- Fabric provisioner → Microsoft Fabric: creates Fabric assets
- Airline ontology input → Fabric provisioner: supplies demo ontology
- Retrieval UI → Managed retrieval API: calls retrieval endpoints
- Managed retrieval API → Azure AI Search / Foundry IQ: executes retrieval
- Managed retrieval API → Azure OpenAI: uses server-side credentials
- Managed retrieval API → Offline replay: uses in offline mode
- Offline replay → Sample retrieve response: replays
