# fiverr/readiness-manager architecture

> Architecture diagram of the GitHub repository fiverr/readiness-manager, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/fiverr/readiness-manager
- Repository: https://github.com/fiverr/readiness-manager

## Overview

##### Project Type and Core Components

a. Main Components:
- ReadinessManager Core
- Action Registry
- Event System
- Error Handling System
- Status Management

**┌─────────────────────────────────┐**
- ReadinessManager         │
- ┤
- ready: boolean               │
- register()                   │
- run()                        │
- onReady()                    │
- onActionReady()              │
- onError()                    │
- status()                     │
- ┘

**┌─────────────────┐    ┌─────────────────┐**
- Action Registry │    │   Event System  │
- ┘    └─────────────────┘

**┌─────────────────┐    ┌─────────────────┐**
- Error Handler  │    │ Status Manager  │
- ┘    └─────────────────┘

##### Flow Representation

- Registration flow (→)
- Event propagation (⇢)
- Error handling flow (⇢)
- Status updates (→)

##### State Management

**┌─────────────────────────────────┐**
- Action States           │
- ┤
- ○ not_started                   │
- ◇ pending                       │
- ● resolved                      │
- ✕ rejected                      │
- ┘

**┌─────────────────┐**
- Client App     │
- ┬─────────┘

**┌───────▼─────────┐    ┌─────────────────┐**
- Readiness      │    │  External       │
- Manager        │───▶│  Dependencies   │
- ┬─────────┘    └─────────────────┘

**┌───────▼─────────┐**
- Health Check   │
- Endpoint       │
- ┘

**┌─────────────────────────────────┐**
- ┤
- → Synchronous flow             │
- ⇢ Asynchronous flow           │
- ⇄ Bi-directional communication │
- ● Active state                │
- ○ Inactive state              │
- ┘

##### The event subscription system

This will provide a clear visualization of how the library orchestrates application readiness across multiple dependent services while maintaining a clean and understandable architecture.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Core
        RM[ReadinessManager]
        AR[Action Registry]
        ES[Event System]
        EH[Error Handler]
        SM[Status Manager]
    end

    subgraph States
        S1[("not_started")]:::inactive
        S2[("pending")]:::pending
        S3[("resolved")]:::success
        S4[("rejected")]:::error
    end

    subgraph Integration
        CA[Client App]
        ED[External Dependencies]
        HC[Health Check Endpoint]
    end

    subgraph Legend
        L1[("→ Synchronous")]
        L2[("⇢ Async")]
        L3[("⇄ Bi-directional")]
        L4[("● Active")]
        L5[("○ Inactive")]
    end

    %% Core Component Relationships
    RM --> AR
    RM --> ES
    RM --> EH
    RM --> SM

    %% State Transitions
    S1 --> S2
    S2 --> S3
    S2 --> S4
    S4 -.-> S2

    %% Integration Flow
    CA --> RM
    RM --> ED
    RM --> HC

    %% Event System Flow
    ES -.-> AR
    AR -.-> SM
    EH -.-> ES

    %% Styling
    classDef default fill:#f9f9f9,stroke:#333,stroke-width:2px
    classDef success fill:#90EE90,stroke:#333
    classDef error fill:#FFB6C1,stroke:#333
    classDef pending fill:#FFE4B5,stroke:#333
    classDef inactive fill:#D3D3D3,stroke:#333
    classDef core fill:#B0E0E6,stroke:#333

    %% Click Events
    click RM "https://github.com/fiverr/readiness-manager/blob/master/src/index.js"
    click EH "https://github.com/fiverr/readiness-manager/blob/master/src/error.js"
    click SM "https://github.com/fiverr/readiness-manager/blob/master/src/constants.js"
    click CA "https://github.com/fiverr/readiness-manager/blob/master/index.js"
    click AR "https://github.com/fiverr/readiness-manager/blob/master/src/spec.js"
    click ES "https://github.com/fiverr/readiness-manager/blob/master/src/types.d.ts"
    click HC "https://github.com/fiverr/readiness-manager/blob/master/tests/mock.js"
```
