# azure/apiops-cli architecture

> Architecture diagram of the GitHub repository azure/apiops-cli, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-10). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/azure/apiops-cli
- Repository: https://github.com/azure/apiops-cli

## Overview

apiops is a CLI for extracting Azure API Management configuration into local artifacts, publishing artifacts back to APIM, and scaffolding CI/CD workflows. Its primary workflow runs from an extract or publish command through an orchestration service, resource-specific processing, and Azure/artifact-store operations. Separate branches support API Center backup/restore and repository initialization. The graph follows the sampled call references and README; some deeper publish stages and API Center wiring are documented but their source was not sampled.

Main entry points: [`src/services/extract-service.ts`](https://github.com/azure/apiops-cli/blob/main/src/services/extract-service.ts) (Extract orchestrator), [`src/services/publish-service.ts`](https://github.com/azure/apiops-cli/blob/main/src/services/publish-service.ts) (Publish orchestrator), [`src/clients/artifact-store.ts`](https://github.com/azure/apiops-cli/blob/main/src/clients/artifact-store.ts) (Artifact store), [`src/clients/apim-client.ts`](https://github.com/azure/apiops-cli/blob/main/src/clients/apim-client.ts) (APIM REST client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cli["CLI entrypoints"]
  node_cli["Command router<br/>[index.ts]"]
  node_extract_cmd["Extract command<br/>[extract-command.ts]"]
  node_publish_cmd["Publish command<br/>[publish-command.ts]"]
  node_init_cmd["Init command<br/>[init-command.ts]"]
  node_apic_cmd["APIC commands<br/>[apic-command.ts]"]
end

subgraph group_apim["APIM artifact workflow"]
  node_extract["Extract orchestrator<br/>[extract-service.ts]"]
  node_publish["Publish orchestrator<br/>[publish-service.ts]"]
  node_resource_extract["Resource extraction"]
  node_api_extract["API extraction<br/>[api-extractor.ts]"]
  node_product_extract["Product extraction"]
  node_transitive_extract["Dependency extraction"]
  node_api_publish["API publishing<br/>[api-publisher.ts]"]
  node_resource_publish["Resource publishing"]
  node_transitive_resolve["Reference resolution"]
  node_delete_unmatched["Unmatched deletion"]
  node_filter["Resource filtering<br/>[filter-service.ts]"]
  node_dependency["Dependency ordering"]
  node_apim_client["APIM REST client<br/>[apim-client.ts]"]
  node_artifact_store[("Artifact store<br/>[artifact-store.ts]")]
  node_resource_paths["Artifact path mapping<br/>[resource-path.ts]"]
  node_config["Configuration loading<br/>[config-loader.ts]"]
  node_resource_types["Resource catalog<br/>[resource-types.ts]"]
end

subgraph group_apic["API Center"]
  node_apic_service["API Center operations"]
  node_apic_client["API Center client<br/>[apic-client.ts]"]
end

subgraph group_init["Repository scaffolding"]
  node_init_service["Scaffold service<br/>[init-service.ts]"]
  node_workflow_templates["CI workflow templates"]
end

node_user(("CLI user"))
node_azure_apim[("Azure APIM")]
node_local_artifacts[("Local artifacts")]
node_azure_apic[("Azure API Center")]
node_repository[("Target repository")]

node_user -->|"runs commands"| node_cli
node_cli -->|"routes to"| node_extract_cmd
node_cli -->|"routes to"| node_publish_cmd
node_cli -->|"routes to"| node_init_cmd
node_cli -->|"routes to"| node_apic_cmd
node_extract_cmd -->|"invokes"| node_extract
node_publish_cmd -->|"invokes"| node_publish
node_extract_cmd -->|"configures"| node_filter
node_extract -->|"dispatches"| node_resource_extract
node_extract -->|"dispatches"| node_api_extract
node_extract -->|"dispatches"| node_product_extract
node_extract -->|"dispatches"| node_transitive_extract
node_extract -->|"uses"| node_filter
node_extract -->|"orders resources"| node_dependency
node_resource_extract -.->|"reads resources"| node_apim_client
node_resource_extract -.->|"writes artifacts"| node_artifact_store
node_api_extract -.->|"writes artifacts"| node_artifact_store
node_product_extract -.->|"writes artifacts"| node_artifact_store
node_transitive_extract -.->|"reads dependencies"| node_apim_client
node_publish -->|"dispatches"| node_api_publish
node_publish -.->|"dispatches"| node_resource_publish
node_publish -->|"scans references"| node_transitive_resolve
node_publish -->|"computes deletions"| node_delete_unmatched
node_publish -->|"uses"| node_filter
node_publish -.->|"orders resources"| node_dependency
node_api_publish -.->|"writes resources"| node_apim_client
node_resource_publish -.->|"writes resources"| node_apim_client
node_delete_unmatched -->|"deletes resources"| node_apim_client
node_delete_unmatched -->|"reads artifacts"| node_artifact_store
node_transitive_resolve -->|"scans artifacts"| node_artifact_store
node_extract -.->|"stores output"| node_artifact_store
node_publish -.->|"loads input"| node_artifact_store
node_apim_client -->|"calls REST API"| node_azure_apim
node_artifact_store -.->|"reads and writes"| node_local_artifacts
node_resource_paths -->|"maps resource metadata"| node_resource_types
node_extract -->|"maps artifact paths"| node_resource_paths
node_publish -->|"resolves names"| node_resource_paths
node_extract_cmd -->|"loads configuration"| node_config
node_publish_cmd -->|"loads configuration"| node_config
node_apic_cmd -.->|"runs backup or restore"| node_apic_service
node_apic_service -.->|"uses client"| node_apic_client
node_apic_service -->|"backs up or restores"| node_local_artifacts
node_apic_client -.->|"calls service API"| node_azure_apic
node_init_cmd -.->|"scaffolds repository"| node_init_service
node_init_service -->|"renders templates"| node_workflow_templates
node_init_service -->|"writes scaffold"| node_repository

click node_cli "https://github.com/azure/apiops-cli/blob/main/src/cli/index.ts"
click node_extract_cmd "https://github.com/azure/apiops-cli/blob/main/src/cli/extract-command.ts"
click node_publish_cmd "https://github.com/azure/apiops-cli/blob/main/src/cli/publish-command.ts"
click node_init_cmd "https://github.com/azure/apiops-cli/blob/main/src/cli/init-command.ts"
click node_apic_cmd "https://github.com/azure/apiops-cli/blob/main/src/cli/apic-command.ts"
click node_extract "https://github.com/azure/apiops-cli/blob/main/src/services/extract-service.ts"
click node_publish "https://github.com/azure/apiops-cli/blob/main/src/services/publish-service.ts"
click node_resource_extract "https://github.com/azure/apiops-cli/blob/main/src/services/resource-extractor.ts"
click node_api_extract "https://github.com/azure/apiops-cli/blob/main/src/services/api-extractor.ts"
click node_product_extract "https://github.com/azure/apiops-cli/blob/main/src/services/product-extractor.ts"
click node_transitive_extract "https://github.com/azure/apiops-cli/blob/main/src/services/transitive-extractor.ts"
click node_api_publish "https://github.com/azure/apiops-cli/blob/main/src/services/api-publisher.ts"
click node_resource_publish "https://github.com/azure/apiops-cli/blob/main/src/services/resource-publisher.ts"
click node_transitive_resolve "https://github.com/azure/apiops-cli/blob/main/src/services/transitive-resolver.ts"
click node_delete_unmatched "https://github.com/azure/apiops-cli/blob/main/src/services/delete-unmatched-service.ts"
click node_filter "https://github.com/azure/apiops-cli/blob/main/src/services/filter-service.ts"
click node_dependency "https://github.com/azure/apiops-cli/blob/main/src/lib/dependency-graph.ts"
click node_apim_client "https://github.com/azure/apiops-cli/blob/main/src/clients/apim-client.ts"
click node_artifact_store "https://github.com/azure/apiops-cli/blob/main/src/clients/artifact-store.ts"
click node_resource_paths "https://github.com/azure/apiops-cli/blob/main/src/lib/resource-path.ts"
click node_config "https://github.com/azure/apiops-cli/blob/main/src/lib/config-loader.ts"
click node_resource_types "https://github.com/azure/apiops-cli/blob/main/src/models/resource-types.ts"
click node_apic_service "https://github.com/azure/apiops-cli/blob/main/src/services/apic-extract-service.ts"
click node_apic_client "https://github.com/azure/apiops-cli/blob/main/src/clients/apic-client.ts"
click node_init_service "https://github.com/azure/apiops-cli/blob/main/src/services/init-service.ts"
click node_workflow_templates "https://github.com/azure/apiops-cli/tree/main/src/templates"

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_extract_cmd,node_publish_cmd,node_init_cmd,node_apic_cmd,node_user toneBlue
class node_extract,node_publish,node_resource_extract,node_api_extract,node_product_extract,node_transitive_extract,node_api_publish,node_resource_publish,node_transitive_resolve,node_delete_unmatched,node_filter,node_dependency,node_apim_client,node_artifact_store,node_resource_paths,node_config,node_resource_types,node_azure_apim,node_local_artifacts,node_azure_apic,node_repository toneAmber
class node_apic_service,node_apic_client toneMint
class node_init_service,node_workflow_templates toneRose
```

## Components

### CLI entrypoints

- [Command router](https://github.com/azure/apiops-cli/blob/main/src/cli/index.ts): `src/cli/index.ts`
- [Extract command](https://github.com/azure/apiops-cli/blob/main/src/cli/extract-command.ts): `src/cli/extract-command.ts`
- [Publish command](https://github.com/azure/apiops-cli/blob/main/src/cli/publish-command.ts): `src/cli/publish-command.ts`
- [Init command](https://github.com/azure/apiops-cli/blob/main/src/cli/init-command.ts): `src/cli/init-command.ts`
- [APIC commands](https://github.com/azure/apiops-cli/blob/main/src/cli/apic-command.ts): `src/cli/apic-command.ts`

### APIM artifact workflow

- [Extract orchestrator](https://github.com/azure/apiops-cli/blob/main/src/services/extract-service.ts): `src/services/extract-service.ts`
- [Publish orchestrator](https://github.com/azure/apiops-cli/blob/main/src/services/publish-service.ts): `src/services/publish-service.ts`
- [Resource extraction](https://github.com/azure/apiops-cli/blob/main/src/services/resource-extractor.ts): `src/services/resource-extractor.ts`
- [API extraction](https://github.com/azure/apiops-cli/blob/main/src/services/api-extractor.ts): `src/services/api-extractor.ts`
- [Product extraction](https://github.com/azure/apiops-cli/blob/main/src/services/product-extractor.ts): `src/services/product-extractor.ts`
- [Dependency extraction](https://github.com/azure/apiops-cli/blob/main/src/services/transitive-extractor.ts): `src/services/transitive-extractor.ts`
- [API publishing](https://github.com/azure/apiops-cli/blob/main/src/services/api-publisher.ts): `src/services/api-publisher.ts`
- [Resource publishing](https://github.com/azure/apiops-cli/blob/main/src/services/resource-publisher.ts): `src/services/resource-publisher.ts`
- [Reference resolution](https://github.com/azure/apiops-cli/blob/main/src/services/transitive-resolver.ts): `src/services/transitive-resolver.ts`
- [Unmatched deletion](https://github.com/azure/apiops-cli/blob/main/src/services/delete-unmatched-service.ts): `src/services/delete-unmatched-service.ts`
- [Resource filtering](https://github.com/azure/apiops-cli/blob/main/src/services/filter-service.ts): `src/services/filter-service.ts`
- [Dependency ordering](https://github.com/azure/apiops-cli/blob/main/src/lib/dependency-graph.ts): `src/lib/dependency-graph.ts`
- [APIM REST client](https://github.com/azure/apiops-cli/blob/main/src/clients/apim-client.ts): `src/clients/apim-client.ts`
- [Artifact store](https://github.com/azure/apiops-cli/blob/main/src/clients/artifact-store.ts): `src/clients/artifact-store.ts`
- [Artifact path mapping](https://github.com/azure/apiops-cli/blob/main/src/lib/resource-path.ts): `src/lib/resource-path.ts`
- [Configuration loading](https://github.com/azure/apiops-cli/blob/main/src/lib/config-loader.ts): `src/lib/config-loader.ts`
- [Resource catalog](https://github.com/azure/apiops-cli/blob/main/src/models/resource-types.ts): `src/models/resource-types.ts`

### API Center

- [API Center operations](https://github.com/azure/apiops-cli/blob/main/src/services/apic-extract-service.ts): `src/services/apic-extract-service.ts`
- [API Center client](https://github.com/azure/apiops-cli/blob/main/src/clients/apic-client.ts): `src/clients/apic-client.ts`

### Repository scaffolding

- [Scaffold service](https://github.com/azure/apiops-cli/blob/main/src/services/init-service.ts): `src/services/init-service.ts`
- [CI workflow templates](https://github.com/azure/apiops-cli/tree/main/src/templates): `src/templates`

### Other components

- **CLI user**
- **Azure APIM**
- **Local artifacts**
- **Azure API Center**
- **Target repository**

## Connections

- CLI user → Command router: runs commands (evidence: `README.md`)
- Command router → Extract command: routes to (evidence: `src/cli/index.ts`)
- Command router → Publish command: routes to (evidence: `src/cli/index.ts`)
- Command router → Init command: routes to (evidence: `src/cli/index.ts`)
- Command router → APIC commands: routes to (evidence: `src/cli/index.ts`)
- Extract command → Extract orchestrator: invokes (evidence: `src/cli/extract-command.ts`)
- Publish command → Publish orchestrator: invokes (evidence: `src/cli/publish-command.ts`)
- Extract command → Resource filtering: configures (evidence: `src/cli/extract-command.ts`)
- Extract orchestrator → Resource extraction: dispatches (evidence: `src/services/extract-service.ts`)
- Extract orchestrator → API extraction: dispatches (evidence: `src/services/extract-service.ts`)
- Extract orchestrator → Product extraction: dispatches (evidence: `src/services/extract-service.ts`)
- Extract orchestrator → Dependency extraction: dispatches (evidence: `src/services/extract-service.ts`)
- Extract orchestrator → Resource filtering: uses (evidence: `src/services/extract-service.ts`)
- Extract orchestrator → Dependency ordering: orders resources (evidence: `src/services/extract-service.ts`)
- Resource extraction → APIM REST client: reads resources
- Resource extraction → Artifact store: writes artifacts
- API extraction → Artifact store: writes artifacts
- Product extraction → Artifact store: writes artifacts
- Dependency extraction → APIM REST client: reads dependencies
- Publish orchestrator → API publishing: dispatches (evidence: `src/services/publish-service.ts`)
- Publish orchestrator → Resource publishing: dispatches (evidence: `src/services/publish-service.ts`)
- Publish orchestrator → Reference resolution: scans references (evidence: `src/services/publish-service.ts`)
- Publish orchestrator → Unmatched deletion: computes deletions (evidence: `src/services/publish-service.ts`)
- Publish orchestrator → Resource filtering: uses (evidence: `src/services/publish-service.ts`)
- Publish orchestrator → Dependency ordering: orders resources (evidence: `src/services/publish-service.ts`)
- API publishing → APIM REST client: writes resources
- Resource publishing → APIM REST client: writes resources
- Unmatched deletion → APIM REST client: deletes resources (evidence: `src/services/delete-unmatched-service.ts`)
- Unmatched deletion → Artifact store: reads artifacts (evidence: `src/services/delete-unmatched-service.ts`)
- Reference resolution → Artifact store: scans artifacts
- Extract orchestrator → Artifact store: stores output
- Publish orchestrator → Artifact store: loads input
- APIM REST client → Azure APIM: calls REST API (evidence: `README.md`)
- Artifact store → Local artifacts: reads and writes
- Artifact path mapping → Resource catalog: maps resource metadata (evidence: `src/lib/resource-path.ts`)
- Extract orchestrator → Artifact path mapping: maps artifact paths (evidence: `src/services/extract-service.ts`)
- Publish orchestrator → Artifact path mapping: resolves names (evidence: `src/services/publish-service.ts`)
- Extract command → Configuration loading: loads configuration (evidence: `src/cli/extract-command.ts`)
- Publish command → Configuration loading: loads configuration (evidence: `src/cli/publish-command.ts`)
- APIC commands → API Center operations: runs backup or restore
- API Center operations → API Center client: uses client
- API Center operations → Local artifacts: backs up or restores (evidence: `README.md`)
- API Center client → Azure API Center: calls service API
- Init command → Scaffold service: scaffolds repository
- Scaffold service → CI workflow templates: renders templates (evidence: `src/services/init-service.ts`)
- Scaffold service → Target repository: writes scaffold (evidence: `README.md`)
