# app-vnext/polly architecture

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

- Interactive diagram: https://gitdiagram.com/app-vnext/polly
- Repository: https://github.com/app-vnext/polly

## Overview

##### Main Components / Layers
- Extensions Module: Capture extensions for dependency injection and telemetry, which are found in Polly.Extensions. This component interacts with the core engine by configuring policies and also routes telemetry events.
- Rate Limiting: Highlight the specialized module (Polly.RateLimiting) that integrates with system-level rate limiting approaches, including components based on concurrency and sliding-window algorithms.
- Testing and Benchmarks: Although not part of the runtime architecture, separate modules (Polly.Testing, the “bench” directory, and extensive test projects) indicate how the library is validated. Optionally, you may show these as a “Supporting Infrastructure” layer.
- Samples and Documentation: Illustrate that there is a separate “Samples” folder to help consumers understand integration details.
- Legacy API Support: Optionally denote that a “Polly” package exists to provide backward compatibility (legacy API) relative to the new v8 API.

##### Component Relationships and Interactions
- An interaction between the Extensions module (DI integration) and the core engine. Indicate that the service collection (IServiceCollection) binds and retrieves named resilience pipelines.
- How the registry/lookup mechanism (in namespaces like Registry) provides dynamic access to pipelines – for example, a “Policy Registry” component.

##### Technologies and Frameworks
- .NET Platform: Specify that the library targets .NET and uses asynchronous and thread-safe patterns.
- NuGet Packages: Identify the main NuGet packages (Polly.Core, Polly.Extensions, Polly.RateLimiting, Polly.Testing) and show that they aggregate into the overall service.
- Simmy Integration: Mark the chaos engineering support (Simmy) as an integrated part of the Polly core, enabling chaos fault injection and latency simulation.

## Diagram (Mermaid)

```mermaid
graph TD
    CLIENT["Client/Consumer"]:::client

    subgraph "Core Resilience Engine (Polly.Core)"
        CORE["Resilience Pipeline Builder"]:::core
        RT["Retry Strategy"]:::strategy
        CB["Circuit Breaker Strategy"]:::strategy
        FB["Fallback Strategy"]:::strategy
        HD["Hedging Strategy"]:::strategy
        TO["Timeout Strategy"]:::strategy
        SM["Chaos (Simmy)"]:::strategy
        PR["Policy Registry"]:::strategy
    end

    subgraph "Extensions & DI (Polly.Extensions)"
        EXT["DI & Telemetry Extensions"]:::extension
    end

    RATE["Rate Limiter (Specialized)"]:::rate

    subgraph "Supporting Infrastructure"
        TEST["Testing"]:::infra
        BENCH["Benchmarks"]:::infra
    end

    subgraph "Consumer Support"
        SAMPLES["Samples"]:::sample
        DOCS["Documentation"]:::sample
    end

    LEGACY["Legacy API Support"]:::legacy
    LEGACY_UTIL["Legacy Support Utilities"]:::legacy

    CLIENT -->|"calls"| CORE
    CORE -->|"adds:Retry"| RT
    CORE -->|"adds:CircuitBreaker"| CB
    CORE -->|"adds:Fallback"| FB
    CORE -->|"adds:Hedging"| HD
    CORE -->|"adds:Timeout"| TO
    CORE -->|"adds:Chaos"| SM
    CORE -->|"registers"| PR
    CORE -->|"integrates"| RATE
    CORE -->|"triggersTelemetry"| EXT
    EXT -->|"configuresDI"| CORE
    LEGACY -->|"wraps"| CORE
    LEGACY -->|"uses"| LEGACY_UTIL
    CLIENT -->|"validatedBy"| TEST
    CLIENT -->|"benchmarkedBy"| BENCH
    CLIENT -->|"guidedBy"| SAMPLES
    CLIENT -->|"referDocs"| DOCS
    RT -->|"reports"| EXT
    CB -->|"reports"| EXT
    FB -->|"reports"| EXT
    HD -->|"reports"| EXT
    TO -->|"reports"| EXT
    SM -->|"reports"| EXT
    PR -->|"lookup"| CLIENT

    class CLIENT client;
    class CORE core;
    class RT,CB,FB,HD,TO,SM,PR strategy;
    class EXT extension;
    class RATE rate;
    class TEST,BENCH infra;
    class SAMPLES,DOCS sample;
    class LEGACY,LEGACY_UTIL legacy;

    click CORE "https://github.com/app-vnext/polly/blob/main/src/Polly.Core"
    click EXT "https://github.com/app-vnext/polly/blob/main/src/Polly.Extensions"
    click RATE "https://github.com/app-vnext/polly/blob/main/src/Polly.RateLimiting"
    click LEGACY "https://github.com/app-vnext/polly/tree/main/src/Polly"
    click LEGACY_UTIL "https://github.com/app-vnext/polly/tree/main/src/LegacySupport"
    click TEST "https://github.com/app-vnext/polly/tree/main/test directory"
    click BENCH "https://github.com/app-vnext/polly/tree/main/bench directory"
    click SAMPLES "https://github.com/app-vnext/polly/tree/main/samples directory"
    click DOCS "https://github.com/app-vnext/polly/tree/main/docs directory"
```
