# waldur/waldur-mastermind architecture

> Architecture diagram of the GitHub repository waldur/waldur-mastermind, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/waldur/waldur-mastermind
- Repository: https://github.com/waldur/waldur-mastermind

## Overview

##### Main Components Architecture

The system should be represented as a layered architecture with the following main components:

a. Frontend Layer:
- Web interface (not visible in the source but mentioned in README)
- API endpoints (visible in core/urls.py and other modules)

b. Core Services Layer:
- Authentication & Authorization (waldur_auth_*)
- Core functionality (waldur_core/)
- Marketplace services (waldur_mastermind/marketplace/)
- Support system integration (waldur_mastermind/support/)
- Billing and invoicing (waldur_mastermind/invoices/)

c. Infrastructure Providers Layer:
- OpenStack integration (waldur_openstack/)
- VMware integration (waldur_vmware/)
- Rancher integration (waldur_rancher/)
- SLURM integration (waldur_slurm/)
- Azure integration (waldur_azure/)
- AWS integration (waldur_aws/)

d. Supporting Services:
- Logging system (waldur_core/logging/)
- Task execution system (visible in executors.py files)
- Notification system (waldur_mastermind/notifications/)
- Quota management (waldur_core/quotas/)

##### Key Relationships to Highlight

- Authentication flow from frontend through auth services to core
- Relationship between billing system and resource usage
- Demonstrate task execution flow across components

##### Integration Points

External service integrations:
- JIRA/Atlassian Service Desk
- SAML2 authentication
- Social authentication providers
- Payment systems
- Monitoring systems

##### Data Flow

Main data flows:
- User requests through API
- Resource provisioning workflows
- Usage data collection
- Billing information flow
- Notification routing

##### Technical Details

- Celery task execution system
- Django REST framework API layer
- Database interactions
- Caching mechanisms
- Message queue system

## Diagram (Mermaid)

```mermaid
%%{init: {'theme': 'base', 'themeVariables': { 'primaryColor': '#007bff', 'primaryTextColor': '#fff', 'primaryBorderColor': '#007bff', 'lineColor': '#333', 'secondaryColor': '#f8f9fa', 'tertiaryColor': '#fff'}}}%%

flowchart TB
    subgraph Frontend["Frontend Layer"]
        WEB[Web Interface]
        API["API Gateway"]:::api
    end

    subgraph CoreServices["Core Services Layer"]
        direction TB
        CORE["Core Functionality"]:::core
        AUTH["Authentication & Authorization"]:::auth
        MARKET["Marketplace"]:::marketplace
        SUPPORT["Support System"]:::support
        BILLING["Billing & Invoicing"]:::billing
    end

    subgraph Infrastructure["Infrastructure Providers Layer"]
        direction TB
        OPENSTACK["OpenStack"]:::infra
        VMWARE["VMware"]:::infra
        RANCHER["Rancher"]:::infra
        SLURM["SLURM"]:::infra
        AZURE["Azure"]:::infra
        AWS["AWS"]:::infra
    end

    subgraph Support["Supporting Services"]
        direction TB
        LOG["Logging System"]:::support
        TASK["Task Execution"]:::support
        NOTIFY["Notification System"]:::support
        QUOTA["Quota Management"]:::support
    end

    subgraph External["External Services"]
        direction TB
        JIRA["JIRA"]:::external
        SAML["SAML2"]:::external
        SOCIAL["Social Auth"]:::external
        PAYMENT["Payment Systems"]:::external
        MONITOR["Monitoring"]:::external
    end

    %% Frontend connections
    WEB --> API
    API --> AUTH
    API --> CORE

    %% Core service connections
    AUTH --> CORE
    MARKET --> CORE
    SUPPORT --> CORE
    BILLING --> CORE

    %% Infrastructure connections
    MARKET <--> OPENSTACK
    MARKET <--> VMWARE
    MARKET <--> RANCHER
    MARKET <--> SLURM
    MARKET <--> AZURE
    MARKET <--> AWS

    %% Support service connections
    CORE --> LOG
    CORE --> TASK
    CORE --> NOTIFY
    CORE --> QUOTA

    %% External service connections
    SUPPORT --> JIRA
    AUTH --> SAML
    AUTH --> SOCIAL
    BILLING --> PAYMENT
    CORE --> MONITOR

    %% Click events for component mapping
    click CORE "https://github.com/waldur/waldur-mastermind/tree/develop/src/waldur_core/core/"
    click AUTH "https://github.com/waldur/waldur-mastermind/tree/develop/src/waldur_auth_saml2/"
    click MARKET "https://github.com/waldur/waldur-mastermind/tree/develop/src/waldur_mastermind/marketplace/"
    click SUPPORT "https://github.com/waldur/waldur-mastermind/tree/develop/src/waldur_mastermind/support/"
    click BILLING "https://github.com/waldur/waldur-mastermind/tree/develop/src/waldur_mastermind/invoices/"
    click OPENSTACK "https://github.com/waldur/waldur-mastermind/tree/develop/src/waldur_openstack/"
    click VMWARE "https://github.com/waldur/waldur-mastermind/tree/develop/src/waldur_vmware/"
    click RANCHER "https://github.com/waldur/waldur-mastermind/tree/develop/src/waldur_rancher/"
    click SLURM "https://github.com/waldur/waldur-mastermind/tree/develop/src/waldur_slurm/"
    click AZURE "https://github.com/waldur/waldur-mastermind/tree/develop/src/waldur_azure/"
    click AWS "https://github.com/waldur/waldur-mastermind/tree/develop/src/waldur_aws/"
    click LOG "https://github.com/waldur/waldur-mastermind/tree/develop/src/waldur_core/logging/"
    click TASK "https://github.com/waldur/waldur-mastermind/blob/develop/src/waldur_core/core/executors.py"
    click NOTIFY "https://github.com/waldur/waldur-mastermind/tree/develop/src/waldur_mastermind/notifications/"
    click QUOTA "https://github.com/waldur/waldur-mastermind/tree/develop/src/waldur_core/quotas/"
    click API "https://github.com/waldur/waldur-mastermind/blob/develop/src/waldur_core/core/urls.py"

    %% Styling
    classDef core fill:#007bff,color:white
    classDef auth fill:#ffa500,color:white
    classDef marketplace fill:#800080,color:white
    classDef support fill:#ffeb3b,color:black
    classDef billing fill:#4caf50,color:white
    classDef infra fill:#4caf50,color:white
    classDef api fill:#ff4081,color:white
    classDef external fill:#9e9e9e,color:white

    %% Legend
    subgraph Legend
        L_CORE["Core Services"]:::core
        L_AUTH["Auth Services"]:::auth
        L_MARKET["Marketplace"]:::marketplace
        L_SUP["Support Services"]:::support
        L_INFRA["Infrastructure"]:::infra
        L_API["API"]:::api
        L_EXT["External"]:::external
    end
```
