# openstack/blazar architecture

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

- Interactive diagram: https://gitdiagram.com/openstack/blazar
- Repository: https://github.com/openstack/blazar

## Overview

##### Main Components Identification
The system should be represented with these key components:

a) API Layer
- REST API (v1 and v2)
- API Middleware
- Authentication/Authorization

b) Core Services
- Lease Manager
- Resource Managers
- Host Manager
- Floating IP Manager
- Instance Manager

c) Plugin System
- Host Plugin
- Instance Plugin
- Floating IP Plugin
- Flavor Plugin

d) Monitoring System
- Notification Monitor
- Polling Monitor

e) Database Layer
- SQLAlchemy Models
- Migration Management

f) External Integration Points
- OpenStack Services
- Nova
- Neutron
- Keystone
- Placement

##### Component Relationships

a) Client Interactions
- External clients → API Layer (REST endpoints)
- API Layer → Authentication/Policy Enforcement

b) Core Flow
- API Layer → Manager Services
- Manager Services → Plugins
- Plugins → Database Layer
- Plugins → External OpenStack Services

c) Monitoring Flow
- Monitoring System → Resource Managers
- Monitoring System → External OpenStack Services

##### Specific Design Elements

Use these visual elements:

a) Components:
- Hexagons for plugins
- Clouds for external OpenStack services

- Blue: Core services
- Green: API components
- Yellow: Plugins
- Gray: External services
- Red: Monitoring components

c) Connection Types:

##### Key Architectural Patterns to Highlight

a) Plugin Architecture
- Extensibility points
- Plugin manager connections

b) Resource Management
- Reservation workflow
- Resource allocation flow

c) Monitoring System
- Event monitoring
- Status updates

##### Implementation Details

a) Service Components:
**API → Manager Services → Plugins → External Services**
- ↓
**Database Layer**

b) Authentication Flow:
**Client → API → Policy Enforcement → Core Services**

c) Resource Management Flow:
**Lease Request → Validation → Resource Allocation → Monitoring**

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles
    classDef api fill:#90EE90,stroke:#333,stroke-width:2px
    classDef core fill:#87CEEB,stroke:#333,stroke-width:2px
    classDef plugin fill:#FFD700,stroke:#333,stroke-width:2px
    classDef monitor fill:#FF6B6B,stroke:#333,stroke-width:2px
    classDef db fill:#C0C0C0,stroke:#333,stroke-width:2px
    classDef external fill:#D3D3D3,stroke:#333,stroke-width:2px

    %% API Layer
    subgraph API
        APIv1["REST API v1"]:::api
        APIv2["REST API v2"]:::api
        APIMid["API Middleware"]:::api
        Auth["Authentication/Policy"]:::api
    end

    %% Core Services
    subgraph Core
        LM["Lease Manager"]:::core
        HM["Host Manager"]:::core
        FIM["Floating IP Manager"]:::core
    end

    %% Plugin System
    subgraph Plugins
        HP["Host Plugin"]:::plugin
        IP["Instance Plugin"]:::plugin
        FIP["Floating IP Plugin"]:::plugin
        FP["Flavor Plugin"]:::plugin
    end

    %% Monitoring System
    subgraph Monitoring
        NM["Notification Monitor"]:::monitor
        PM["Polling Monitor"]:::monitor
    end

    %% Database Layer
    DB[(Database)]:::db
    DBModels["SQLAlchemy Models"]:::db
    DBMigration["Migration Management"]:::db

    %% External Services
    subgraph OpenStack
        Nova["Nova"]:::external
        Neutron["Neutron"]:::external
        Keystone["Keystone"]:::external
        Placement["Placement"]:::external
    end

    %% Relationships
    Client --> APIv1 & APIv2
    APIv1 & APIv2 --> APIMid
    APIMid --> Auth
    Auth --> LM & HM & FIM
    
    LM --> HP & IP & FIP & FP
    HM --> HP
    FIM --> FIP
    
    HP & IP & FIP & FP --> DBModels
    DBModels --> DB
    DBMigration --> DB
    
    HP --> Nova & Placement
    IP --> Nova
    FIP --> Neutron
    Auth --> Keystone
    
    NM & PM --> Nova & Neutron
    NM & PM --> HM & FIM

    %% Click Events
    click APIv1 "https://github.com/openstack/blazar/tree/master/blazar/api/v1/"
    click APIv2 "https://github.com/openstack/blazar/tree/master/blazar/api/v2/"
    click APIMid "https://github.com/openstack/blazar/tree/master/blazar/api/v2/middleware/"
    click Auth "https://github.com/openstack/blazar/tree/master/blazar/policies/"
    click LM "https://github.com/openstack/blazar/tree/master/blazar/manager/leases/"
    click HM "https://github.com/openstack/blazar/tree/master/blazar/manager/oshosts/"
    click FIM "https://github.com/openstack/blazar/tree/master/blazar/manager/floatingips/"
    click HP "https://github.com/openstack/blazar/blob/master/blazar/plugins/oshosts/host_plugin.py"
    click IP "https://github.com/openstack/blazar/blob/master/blazar/plugins/instances/instance_plugin.py"
    click FIP "https://github.com/openstack/blazar/blob/master/blazar/plugins/floatingips/floatingip_plugin.py"
    click FP "https://github.com/openstack/blazar/blob/master/blazar/plugins/flavor/flavor_plugin.py"
    click NM "https://github.com/openstack/blazar/blob/master/blazar/monitor/notification_monitor.py"
    click PM "https://github.com/openstack/blazar/blob/master/blazar/monitor/polling_monitor.py"
    click DBModels "https://github.com/openstack/blazar/blob/master/blazar/db/sqlalchemy/models.py"
    click DBMigration "https://github.com/openstack/blazar/tree/master/blazar/db/migration/"
    click Nova "https://github.com/openstack/blazar/blob/master/blazar/utils/openstack/nova.py"
    click Neutron "https://github.com/openstack/blazar/blob/master/blazar/utils/openstack/neutron.py"
    click Keystone "https://github.com/openstack/blazar/blob/master/blazar/utils/openstack/keystone.py"
    click Placement "https://github.com/openstack/blazar/blob/master/blazar/utils/openstack/placement.py"

    %% Legend
    subgraph Legend
        L1["API Components"]:::api
        L2["Core Services"]:::core
        L3["Plugins"]:::plugin
        L4["Monitoring"]:::monitor
        L5["Database"]:::db
        L6["External Services"]:::external
    end
```
