# ansible/galaxy_ng architecture

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

- Interactive diagram: https://gitdiagram.com/ansible/galaxy_ng
- Repository: https://github.com/ansible/galaxy_ng

## Overview

##### Main Components

a. Frontend Layer:
- UI Component (under /galaxy_ng/ui)
- API Endpoints:
- V1 API (/galaxy_ng/app/api/v1)
- V3 API (/galaxy_ng/app/api/v3)
- UI API (/galaxy_ng/app/api/ui)

b. Core Services:
- Authentication Services (/galaxy_ng/app/auth)
- LDAP Integration
- Keycloak Integration
- Token Management
- Access Control Layer (/galaxy_ng/app/access_control)
- Task Management System (/galaxy_ng/app/tasks)
- Metrics Collection (/galaxy_ng/app/metrics_collection)

c. Content Management:
- Collection Management
- Execution Environment Management
- Namespace Management
- Repository Management
- Sync Management

d. External Integrations:
- Container Registry Integration
- GitHub Integration
- LDAP/Keycloak Services
- Pulp Core Integration

##### Relationship Flows

- User requests flow through UI/API layers to core services
- Authentication flow between external auth providers and the auth service
- Content synchronization flow between external sources and internal repositories
- Task execution flow from API requests to background workers
- Metrics collection flow from various components to analytics services

##### Architectural Patterns to Highlight

- Plugin architecture (Pulp integration)
- REST API layering (v1, v3, UI)
- Task queue system
- Event-driven components
- Caching mechanisms
- Authentication middleware

##### Infrastructure Components

- Nginx web server
- Database (PostgreSQL)
- Cache layers
- Task workers
- Storage systems

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Frontend
        UI["UI Component"]:::frontend
        APIv1["API v1"]:::api
        APIv3["API v3"]:::api
        UIAPI["UI API"]:::api
    end

    subgraph Core_Services
        Auth["Authentication Services"]:::auth
        ACL["Access Control Layer"]:::core
        TaskMgmt["Task Management"]:::task
        Metrics["Metrics Collection"]:::core
    end

    subgraph Auth_Providers
        LDAP["LDAP Integration"]:::auth
        Keycloak["Keycloak Integration"]:::auth
        TokenMgmt["Token Management"]:::auth
    end

    subgraph Content_Management
        CollMgmt["Collection Management"]:::content
        EEMgmt["Execution Environment"]:::content
        NSMgmt["Namespace Management"]:::content
        RepoMgmt["Repository Management"]:::content
        SyncMgmt["Sync Management"]:::content
    end

    subgraph External_Systems
        ContainerReg["Container Registry"]:::external
        GitHub["GitHub"]:::external
        PulpCore["Pulp Core"]:::external
    end

    subgraph Infrastructure
        Nginx["Nginx"]:::infra
        DB[(PostgreSQL)]:::db
        Cache[(Cache)]:::db
        Workers["Task Workers"]:::infra
        Storage["Storage"]:::infra
    end

    UI --> APIv1
    UI --> APIv3
    UI --> UIAPI
    
    APIv1 & APIv3 & UIAPI --> Auth
    Auth --> Auth_Providers
    Auth --> ACL
    
    APIv1 & APIv3 & UIAPI --> TaskMgmt
    TaskMgmt --> Workers
    Workers --> Content_Management
    
    Content_Management --> PulpCore
    Content_Management --> ContainerReg
    Content_Management --> GitHub
    
    Auth_Providers --> External_Systems
    
    TaskMgmt --> Metrics
    Content_Management --> Metrics
    Auth --> Metrics

    %% Click events for component mapping
    click UI "https://github.com/ansible/galaxy_ng/tree/master/galaxy_ng/ui/"
    click APIv1 "https://github.com/ansible/galaxy_ng/tree/master/galaxy_ng/app/api/v1/"
    click APIv3 "https://github.com/ansible/galaxy_ng/tree/master/galaxy_ng/app/api/v3/"
    click UIAPI "https://github.com/ansible/galaxy_ng/tree/master/galaxy_ng/app/api/ui/"
    click Auth "https://github.com/ansible/galaxy_ng/tree/master/galaxy_ng/app/auth/"
    click ACL "https://github.com/ansible/galaxy_ng/tree/master/galaxy_ng/app/access_control/"
    click TaskMgmt "https://github.com/ansible/galaxy_ng/tree/master/galaxy_ng/app/tasks/"
    click Metrics "https://github.com/ansible/galaxy_ng/tree/master/galaxy_ng/app/metrics_collection/"
    click LDAP "https://github.com/ansible/galaxy_ng/blob/master/galaxy_ng/app/auth/ldap.py"
    click Keycloak "https://github.com/ansible/galaxy_ng/blob/master/galaxy_ng/app/auth/keycloak.py"
    click TokenMgmt "https://github.com/ansible/galaxy_ng/blob/master/galaxy_ng/app/auth/token.py"
    click CollMgmt "https://github.com/ansible/galaxy_ng/blob/master/galaxy_ng/app/api/ui/v1/viewsets/collection.py"
    click NSMgmt "https://github.com/ansible/galaxy_ng/blob/master/galaxy_ng/app/api/ui/v1/viewsets/namespace.py"
    click RepoMgmt "https://github.com/ansible/galaxy_ng/blob/master/galaxy_ng/app/api/ui/v1/viewsets/distribution.py"
    click SyncMgmt "https://github.com/ansible/galaxy_ng/blob/master/galaxy_ng/app/api/ui/v1/views/sync.py"
    click ContainerReg "https://github.com/ansible/galaxy_ng/blob/master/galaxy_ng/app/api/ui/v1/viewsets/execution_environment.py"

    %% Styling
    classDef frontend fill:#e6f3ff,stroke:#333
    classDef api fill:#b3d9ff,stroke:#333
    classDef auth fill:#ffe6cc,stroke:#333
    classDef core fill:#f2f2f2,stroke:#333
    classDef task fill:#e6e6ff,stroke:#333
    classDef content fill:#ffebcc,stroke:#333
    classDef external fill:#d9f2d9,stroke:#333
    classDef infra fill:#e6e6e6,stroke:#333
    classDef db fill:#f2e6ff,stroke:#333
```
