# regro/cf-scripts architecture

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

- Interactive diagram: https://gitdiagram.com/regro/cf-scripts
- Repository: https://github.com/regro/cf-scripts

## Overview

##### High-Level Architecture Components

The system should be represented with these main components:

a) Core Bot Services (represented as separate containers/processes):
- Version Update Service (bot-versions.yml)
- PR Management Service (bot-prs.yml)
- Feedstock Management Service (bot-feedstocks.yml)
- Graph Builder Service (bot-make-graph.yml)
- Migration Generator Service (bot-make-migrators.yml)
- PyPI Mapping Service (bot-pypi-mapping.yml)
- Status Page Update Service (bot-update-status-page.yml)
- Main Bot Service (bot-bot.yml)

b) Data Storage Layer:
- Graph Data Store (cf-graph-countyfair repository)
- MongoDB Backend (optional)
- Local File Cache
- GitHub Raw Content Backend

c) External Services Integration:
- GitHub API
- PyPI API
- Conda Repositories
- Docker Container Registry

##### Data Flow Relationships

a) Data Collection Flows:
- Feedstock Service → Graph Data Store (feedstock metadata)
- Version Service → Graph Data Store (package versions)
- PyPI Mapping Service → Graph Data Store (package mappings)

b) Processing Flows:
- Graph Builder → Graph Data Store (dependency graph)
- Migration Generator → Graph Data Store (migration definitions)
- Main Bot → Graph Data Store (PR status and updates)

c) Output Flows:
- Main Bot → GitHub (PRs and comments)
- Status Page Service → Web (status updates)

##### Key Architectural Elements

Specific components:

a) LazyJson Backend System:
- File Backend
- MongoDB Backend
- GitHub Backend
- Caching Layer

b) Migration System:
- Migration Classes
- YAML Parser
- Version Update Logic
- Recipe Parser

##### Important Subsystems to Detail

a) Migration System:
- YAML Parser
- Jinja2 Processing
- Version Update Algorithm
- Selector Management

b) Data Management:
- LazyJson Implementation
- Backend Synchronization
- Caching Strategy

##### Operational Flow

Event-driven and cron-based execution model:

a) Scheduled Jobs:
- 15-minute keepalive checks
- Version update cycles
- PR status updates

b) Event-Driven Operations:
- PR creation triggers
- Feedstock updates
- Migration processing

##### Deployment Context

Deployment-specific elements:

a) Container Infrastructure:
- Docker container relationships
- GitHub Actions runners
- Resource allocation

b) Security Boundaries:
- Token management
- API access controls
- Data persistence zones

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Core Bot Services
    subgraph BotServices
        VUS["Version Update Service"]:::service
        PMS["PR Management Service"]:::service
        FMS["Feedstock Management Service"]:::service
        GBS["Graph Builder Service"]:::service
        MGS["Migration Generator Service"]:::service
        PYM["PyPI Mapping Service"]:::service
        SPS["Status Page Update Service"]:::service
        MBS["Main Bot Service"]:::service
    end

    %% Data Storage Layer
    subgraph DataStorage
        GDS[("Graph Data Store")]:::storage
        MDB[("MongoDB")]:::storage
        LFC[("Local File Cache")]:::storage
        GRB[("GitHub Raw Content")]:::storage
    end

    %% External Services
    subgraph ExternalServices
        GAPI{{"GitHub API"}}:::external
        PAPI{{"PyPI API"}}:::external
        CREP{{"Conda Repositories"}}:::external
        DCREG{{"Docker Registry"}}:::external
    end

    %% Core Processing Components
    subgraph ProcessingCore
        direction TB
        MR["Migration Runner"]:::process
        VU["Version Updates"]:::process
        PRU["PR Updates"]:::process
        FP["Feedstock Parser"]:::process
    end

    %% Migration System
    subgraph MigrationSystem
        direction TB
        MC["Migration Classes"]:::migration
        YP["YAML Parser"]:::migration
        VUL["Version Update Logic"]:::migration
        RP["Recipe Parser"]:::migration
    end

    %% Data Management
    subgraph DataManagement
        direction TB
        LJB["LazyJson Backend"]:::data
        BS["Backend Synchronization"]:::data
        GM["Graph Management"]:::data
    end

    %% Models
    subgraph Models
        direction TB
        NA["Node Attributes"]:::model
        PRI["PR Information"]:::model
        VI["Version Information"]:::model
        MY["Meta YAML"]:::model
    end

    %% Relationships
    VUS --> GDS
    PMS --> GDS
    FMS --> GDS
    GBS --> GDS
    MGS --> GDS
    PYM --> GDS
    MBS --> GDS

    GDS --> MDB
    GDS --> LFC
    GDS --> GRB

    MBS --> GAPI
    PYM --> PAPI
    VUS --> CREP
    MBS --> DCREG

    MR --> MC
    VU --> VUL
    PRU --> PRI
    FP --> RP

    %% Click Events
    click VUS "https://github.com/regro/cf-scripts/blob/main/.github/workflows/bot-versions.yml"
    click PMS "https://github.com/regro/cf-scripts/blob/main/.github/workflows/bot-prs.yml"
    click FMS "https://github.com/regro/cf-scripts/blob/main/.github/workflows/bot-feedstocks.yml"
    click GBS "https://github.com/regro/cf-scripts/blob/main/.github/workflows/bot-make-graph.yml"
    click MGS "https://github.com/regro/cf-scripts/blob/main/.github/workflows/bot-make-migrators.yml"
    click PYM "https://github.com/regro/cf-scripts/blob/main/.github/workflows/bot-pypi-mapping.yml"
    click SPS "https://github.com/regro/cf-scripts/blob/main/.github/workflows/bot-update-status-page.yml"
    click MBS "https://github.com/regro/cf-scripts/blob/main/.github/workflows/bot-bot.yml"
    click MC "https://github.com/regro/cf-scripts/tree/main/conda_forge_tick/migrators/"
    click YP "https://github.com/regro/cf-scripts/tree/main/conda_forge_tick/recipe_parser/"
    click VUL "https://github.com/regro/cf-scripts/blob/main/conda_forge_tick/update_recipe/version.py"
    click RP "https://github.com/regro/cf-scripts/blob/main/conda_forge_tick/recipe_parser/_parser.py"
    click LJB "https://github.com/regro/cf-scripts/blob/main/conda_forge_tick/lazy_json_backends.py"
    click BS "https://github.com/regro/cf-scripts/blob/main/conda_forge_tick/lazy_json_backups.py"
    click GM "https://github.com/regro/cf-scripts/blob/main/conda_forge_tick/make_graph.py"
    click MR "https://github.com/regro/cf-scripts/blob/main/conda_forge_tick/migration_runner.py"
    click VU "https://github.com/regro/cf-scripts/blob/main/conda_forge_tick/update_upstream_versions.py"
    click PRU "https://github.com/regro/cf-scripts/blob/main/conda_forge_tick/update_prs.py"
    click FP "https://github.com/regro/cf-scripts/blob/main/conda_forge_tick/feedstock_parser.py"
    click NA "https://github.com/regro/cf-scripts/blob/main/conda_forge_tick/models/node_attributes.py"
    click PRI "https://github.com/regro/cf-scripts/blob/main/conda_forge_tick/models/pr_info.py"
    click VI "https://github.com/regro/cf-scripts/blob/main/conda_forge_tick/models/versions.py"
    click MY "https://github.com/regro/cf-scripts/blob/main/conda_forge_tick/models/meta_yaml.py"

    %% Styles
    classDef service fill:#3498db,stroke:#2980b9,color:white
    classDef storage fill:#2ecc71,stroke:#27ae60,color:white
    classDef external fill:#e67e22,stroke:#d35400,color:white
    classDef process fill:#f1c40f,stroke:#f39c12,color:black
    classDef migration fill:#9b59b6,stroke:#8e44ad,color:white
    classDef data fill:#1abc9c,stroke:#16a085,color:white
    classDef model fill:#34495e,stroke:#2c3e50,color:white
```
