# open-edge-platform/anomalib architecture

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

- Interactive diagram: https://gitdiagram.com/open-edge-platform/anomalib
- Repository: https://github.com/open-edge-platform/anomalib

## Overview

Anomalib is a deep-learning anomaly-detection library for developing, training, benchmarking, and deploying image/video models. Its documented user workflow is to provide a dataset and model through the API or CLI, train or run inference, then optionally export for accelerated deployment. The tree also contains a companion visual-inspection application with pipeline, project, dataset, and model-management capabilities. Edges are limited to relationships supported by the README or supplied source excerpts/index; unsampled application subsystems are represented without inferred links.

Main entry points: [`src/anomalib/engine/engine.py`](https://github.com/open-edge-platform/anomalib/blob/main/src/anomalib/engine/engine.py) (Training Engine), [`application/backend/src/repositories/pipeline_repo.py`](https://github.com/open-edge-platform/anomalib/blob/main/application/backend/src/repositories/pipeline_repo.py) (Pipeline Repository), [`application/backend/src/services/pipeline_service.py`](https://github.com/open-edge-platform/anomalib/blob/main/application/backend/src/services/pipeline_service.py) (Pipeline Service), [`src/anomalib/cli/cli.py`](https://github.com/open-edge-platform/anomalib/blob/main/src/anomalib/cli/cli.py) (CLI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_library["Anomalib Library"]
  node_cli["CLI<br/>[cli.py]"]
  node_engine["Training Engine<br/>[engine.py]"]
  node_models["Anomaly Models"]
end

subgraph group_workflow["Data and Workflows"]
  node_datasets["Datasets"]
  node_dataformats["Data Types"]
  node_metrics["Evaluation Metrics<br/>[aupro.py]"]
  node_pipelines["Benchmark Pipelines<br/>[pipeline.py]"]
  node_tiled["Tiled Ensemble<br/>[train_pipeline.py]"]
  node_visualization["Visualization<br/>[functional.py]"]
end

subgraph group_deploy["Inference and Deployment"]
  node_export["Model Export"]
  node_inferencers["Inference Runtimes"]
end

subgraph group_app["Inspection Application"]
  node_ui["Inspection UI"]
end

subgraph group_appbackend["Application Backend"]
  node_api["Backend API"]
  node_pipeline_service["Pipeline Service"]
  node_active_service["Active Pipeline"]
  node_pipeline_repo["Pipeline Repository<br/>[pipeline_repo.py]"]
  node_database[("Application Database<br/>[schema.py]")]
  node_app_models["API Domain Models<br/>[pipeline.py]"]
  node_workers["Pipeline Workers"]
  node_streams["Video Streams"]
  node_dispatch["Output Dispatch"]
end

node_user(("Library User"))
node_appuser(("Inspection User"))

node_user -->|"invokes"| node_cli
node_user -->|"uses API"| node_engine
node_cli -.->|"runs training"| node_engine
node_engine -->|"uses data"| node_datasets
node_engine -->|"uses models"| node_models
node_engine -->|"uses metrics"| node_metrics
node_datasets -.->|"provides data"| node_dataformats
node_user -->|"benchmarks"| node_pipelines
node_pipelines -->|"specializes"| node_tiled
node_user -->|"runs inference"| node_inferencers
node_engine -->|"exports model"| node_export
node_export -->|"enables runtime"| node_inferencers
node_user -->|"views predictions"| node_visualization
node_appuser -.->|"inspects pipeline"| node_ui
node_ui -.->|"requests pipeline"| node_api
node_api -->|"calls"| node_pipeline_service
node_pipeline_service -->|"reads and updates"| node_pipeline_repo
node_pipeline_service -->|"reloads active config"| node_active_service
node_active_service -->|"loads active pipeline"| node_pipeline_repo
node_pipeline_repo -->|"queries records"| node_database
node_pipeline_repo -->|"maps pipeline"| node_app_models

click node_cli "https://github.com/open-edge-platform/anomalib/blob/main/src/anomalib/cli/cli.py"
click node_engine "https://github.com/open-edge-platform/anomalib/blob/main/src/anomalib/engine/engine.py"
click node_models "https://github.com/open-edge-platform/anomalib/tree/main/src/anomalib/models"
click node_datasets "https://github.com/open-edge-platform/anomalib/tree/main/src/anomalib/data/datamodules"
click node_dataformats "https://github.com/open-edge-platform/anomalib/tree/main/src/anomalib/data/dataclasses"
click node_metrics "https://github.com/open-edge-platform/anomalib/blob/main/src/anomalib/metrics/aupro.py"
click node_pipelines "https://github.com/open-edge-platform/anomalib/blob/main/src/anomalib/pipelines/components/base/pipeline.py"
click node_tiled "https://github.com/open-edge-platform/anomalib/blob/main/src/anomalib/pipelines/tiled_ensemble/train_pipeline.py"
click node_visualization "https://github.com/open-edge-platform/anomalib/blob/main/src/anomalib/visualization/image/functional.py"
click node_export "https://github.com/open-edge-platform/anomalib/tree/main/src/anomalib/deploy"
click node_inferencers "https://github.com/open-edge-platform/anomalib/tree/main/src/anomalib/deploy/inferencers"
click node_ui "https://github.com/open-edge-platform/anomalib/tree/main/application/ui/src/features/inspect"
click node_api "https://github.com/open-edge-platform/anomalib/blob/main/application/backend/src/api/endpoints/pipeline_endpoints.py"
click node_pipeline_service "https://github.com/open-edge-platform/anomalib/blob/main/application/backend/src/services/pipeline_service.py"
click node_active_service "https://github.com/open-edge-platform/anomalib/blob/main/application/backend/src/services/active_pipeline_service.py"
click node_pipeline_repo "https://github.com/open-edge-platform/anomalib/blob/main/application/backend/src/repositories/pipeline_repo.py"
click node_database "https://github.com/open-edge-platform/anomalib/blob/main/application/backend/src/db/schema.py"
click node_app_models "https://github.com/open-edge-platform/anomalib/blob/main/application/backend/src/pydantic_models/pipeline.py"
click node_workers "https://github.com/open-edge-platform/anomalib/tree/main/application/backend/src/workers"
click node_streams "https://github.com/open-edge-platform/anomalib/tree/main/application/backend/src/entities"
click node_dispatch "https://github.com/open-edge-platform/anomalib/tree/main/application/backend/src/services/dispatchers"

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_engine,node_models,node_user,node_appuser toneBlue
class node_datasets,node_dataformats,node_metrics,node_pipelines,node_tiled,node_visualization toneAmber
class node_export,node_inferencers toneMint
class node_ui toneRose
class node_api,node_pipeline_service,node_active_service,node_pipeline_repo,node_database,node_app_models,node_workers,node_streams,node_dispatch toneIndigo
```

## Components

### Anomalib Library

- [CLI](https://github.com/open-edge-platform/anomalib/blob/main/src/anomalib/cli/cli.py): `src/anomalib/cli/cli.py`
- [Training Engine](https://github.com/open-edge-platform/anomalib/blob/main/src/anomalib/engine/engine.py): `src/anomalib/engine/engine.py`
- [Anomaly Models](https://github.com/open-edge-platform/anomalib/tree/main/src/anomalib/models): `src/anomalib/models`

### Data and Workflows

- [Datasets](https://github.com/open-edge-platform/anomalib/tree/main/src/anomalib/data/datamodules): `src/anomalib/data/datamodules`
- [Data Types](https://github.com/open-edge-platform/anomalib/tree/main/src/anomalib/data/dataclasses): `src/anomalib/data/dataclasses`
- [Evaluation Metrics](https://github.com/open-edge-platform/anomalib/blob/main/src/anomalib/metrics/aupro.py): `src/anomalib/metrics/aupro.py`
- [Benchmark Pipelines](https://github.com/open-edge-platform/anomalib/blob/main/src/anomalib/pipelines/components/base/pipeline.py): `src/anomalib/pipelines/components/base/pipeline.py`
- [Tiled Ensemble](https://github.com/open-edge-platform/anomalib/blob/main/src/anomalib/pipelines/tiled_ensemble/train_pipeline.py): `src/anomalib/pipelines/tiled_ensemble/train_pipeline.py`
- [Visualization](https://github.com/open-edge-platform/anomalib/blob/main/src/anomalib/visualization/image/functional.py): `src/anomalib/visualization/image/functional.py`

### Inference and Deployment

- [Model Export](https://github.com/open-edge-platform/anomalib/tree/main/src/anomalib/deploy): `src/anomalib/deploy`
- [Inference Runtimes](https://github.com/open-edge-platform/anomalib/tree/main/src/anomalib/deploy/inferencers): `src/anomalib/deploy/inferencers`

### Inspection Application

- [Inspection UI](https://github.com/open-edge-platform/anomalib/tree/main/application/ui/src/features/inspect): `application/ui/src/features/inspect`

### Application Backend

- [Backend API](https://github.com/open-edge-platform/anomalib/blob/main/application/backend/src/api/endpoints/pipeline_endpoints.py): `application/backend/src/api/endpoints/pipeline_endpoints.py`
- [Pipeline Service](https://github.com/open-edge-platform/anomalib/blob/main/application/backend/src/services/pipeline_service.py): `application/backend/src/services/pipeline_service.py`
- [Active Pipeline](https://github.com/open-edge-platform/anomalib/blob/main/application/backend/src/services/active_pipeline_service.py): `application/backend/src/services/active_pipeline_service.py`
- [Pipeline Repository](https://github.com/open-edge-platform/anomalib/blob/main/application/backend/src/repositories/pipeline_repo.py): `application/backend/src/repositories/pipeline_repo.py`
- [Application Database](https://github.com/open-edge-platform/anomalib/blob/main/application/backend/src/db/schema.py): `application/backend/src/db/schema.py`
- [API Domain Models](https://github.com/open-edge-platform/anomalib/blob/main/application/backend/src/pydantic_models/pipeline.py): `application/backend/src/pydantic_models/pipeline.py`
- [Pipeline Workers](https://github.com/open-edge-platform/anomalib/tree/main/application/backend/src/workers): `application/backend/src/workers`
- [Video Streams](https://github.com/open-edge-platform/anomalib/tree/main/application/backend/src/entities): `application/backend/src/entities`
- [Output Dispatch](https://github.com/open-edge-platform/anomalib/tree/main/application/backend/src/services/dispatchers): `application/backend/src/services/dispatchers`

### Other components

- **Library User**
- **Inspection User**

## Connections

- Library User → CLI: invokes (evidence: `README.md`)
- Library User → Training Engine: uses API (evidence: `README.md`)
- CLI → Training Engine: runs training (evidence: `src/anomalib/engine/engine.py`)
- Training Engine → Datasets: uses data (evidence: `src/anomalib/engine/engine.py`)
- Training Engine → Anomaly Models: uses models (evidence: `src/anomalib/engine/engine.py`)
- Training Engine → Evaluation Metrics: uses metrics (evidence: `src/anomalib/engine/engine.py`)
- Datasets → Data Types: provides data
- Library User → Benchmark Pipelines: benchmarks (evidence: `README.md`)
- Benchmark Pipelines → Tiled Ensemble: specializes (evidence: `src/anomalib/pipelines/tiled_ensemble/train_pipeline.py`)
- Library User → Inference Runtimes: runs inference (evidence: `README.md`)
- Training Engine → Model Export: exports model (evidence: `src/anomalib/engine/engine.py`)
- Model Export → Inference Runtimes: enables runtime (evidence: `README.md`)
- Library User → Visualization: views predictions (evidence: `README.md`)
- Inspection User → Inspection UI: inspects pipeline
- Inspection UI → Backend API: requests pipeline
- Backend API → Pipeline Service: calls (evidence: `application/backend/src/api/endpoints/pipeline_endpoints.py`)
- Pipeline Service → Pipeline Repository: reads and updates (evidence: `application/backend/src/services/pipeline_service.py`)
- Pipeline Service → Active Pipeline: reloads active config (evidence: `application/backend/src/services/pipeline_service.py`)
- Active Pipeline → Pipeline Repository: loads active pipeline (evidence: `application/backend/src/services/active_pipeline_service.py`)
- Pipeline Repository → Application Database: queries records (evidence: `application/backend/src/repositories/pipeline_repo.py`)
- Pipeline Repository → API Domain Models: maps pipeline (evidence: `application/backend/src/repositories/pipeline_repo.py`)
