# d10s0vsky-oss/stack-lifecycle-deployment architecture

> Architecture diagram of the GitHub repository d10s0vsky-oss/stack-lifecycle-deployment, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-04). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/d10s0vsky-oss/stack-lifecycle-deployment
- Repository: https://github.com/d10s0vsky-oss/stack-lifecycle-deployment

## Overview

##### Main Components
- API Backend (sld-api-backend): This “brain” of the system exposes a FastAPI REST interface, implements domain-driven design (with dedicated modules for cloud providers such as AWS, Azure, GCP, custom providers, users, tasks, deploys, stacks, etc.), and integrates with external services.
- Dashboard (sld-dashboard): A web-based UI (based on volt-dashboard and Flask) that interacts with the API to let users manage accounts, stacks, deployments, and schedules.
- Remote State Service (sld-remote-state): Manages Terraform state files (with backends like MongoDB, S3, Azure, or local storage) and provides a way to remotely lock/unlock state during deployments.
- Scheduler (sld-schedule): Manages scheduled deployments and infrastructure lifecycle events.
- Workers: These are distributed task executors (using Celery) grouped by “squad” (e.g., worker-squad1, worker-squad2) that process deployment, destroy and other asynchronous tasks.
- Supporting Infrastructure: External service dependencies such as message brokers (RabbitMQ, Redis), databases (MongoDB for remote state), and cloud storage integrations.

##### Out Component Relationships and Interactions
- Users connect to the Dashboard for a front-end experience which, in turn, communicates with the API Backend.
- The API Backend orchestrates deployments, interacts with internal modules (for cloud providers, deploys, users, variables, tasks, etc.), and distributes tasks asynchronously via Celery.
- Workers (task executors) consume tasks from a broker (RabbitMQ, Redis) to run deployments and interact with the infrastructure as code modules (invoking Terraform commands).
- The Remote State service is used by the API and deployment tasks to store and retrieve state files; it interacts with various backends per configuration.
- The Scheduler service triggers periodic deployment or destruction events and calls into the backend services to drive these operations.

##### Architectural Patterns and Design Principles
- Microservices Architecture – Separate services for API, UI, state management, scheduling, and background workers.
- Asynchronous Task Processing – Use of Celery for executing long-running tasks (with separate worker deployments per squad).
- Domain-Driven Design – SLD’s API backend is organized into clear modules (e.g., activity logs, cloud providers, deployment, stacks, users, variables, worker, etc.) following clean boundaries (API, Domain, Infrastructure, and Application layers).
- Containerization & Orchestration – Dockerfiles for individual services and Kubernetes manifests (with Helm/Kustomize patterns) that support deployment, scaling, and service discovery.
- Cloud-Agnostic Integration – Multiple provider directories (aws, azure, gcp, custom) indicating plug-in points for various cloud integrations.

##### Relevant Technologies
- FastAPI (for the API backend)
- Flask with volt-dashboard (for the UI)
- Celery (for task distribution)
- Terraform (for IaC)
- Docker & Kubernetes (as deployment environments)
- Cloud-specific integrations for AWS, Azure, and GCP (in the backend modules)
- Supporting tools: RabbitMQ, Redis, MongoDB, S3 storage, etc.

##### Elements
- A labeled block for the “Dashboard” (user-facing web UI).
- A labeled block for the “API Backend” (with modules for cloud provider integration, deployment, users, stacks, etc.).
- Separate blocks for “Remote State” and “Scheduler” services.
- Blocks for “Worker” services with annotations indicating “squad1”, “squad2”, etc.
- External dependencies (message brokers, databases, storage backends).
- User interactions flowing into the Dashboard.
- Dashboard communicating with the API.
- API dispatching tasks to the workers.
- API and Workers interacting with the Remote State service.
- Scheduling events triggering deployments via the API.
- Annotations for container orchestration and deployment environments (Docker-compose and Kubernetes namespaces).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User Interaction
    subgraph "User Interaction"
        U("User"):::frontend
        D("Dashboard (Flask,Volt)"):::frontend
    end

    %% Backend Services
    subgraph "Backend Services"
        API("API Backend (FastAPI)"):::backend
        RS("Remote State (Terraform)"):::backend
        SCH("Scheduler (Deployment)"):::backend
    end

    %% Worker Services
    subgraph "Worker Services"
        WL("Worker Library"):::worker
        WD("Worker (Default)"):::worker
        WS1("Worker (Squad1)"):::worker
        WS2("Worker (Squad2)"):::worker
    end

    %% Container Orchestration
    subgraph "Container Orchestration"
        DOC("Docker Manifests"):::orch
        K8S("Kubernetes Configs"):::orch
    end

    %% Supporting Infrastructure
    subgraph "Supporting Infrastructure"
        INF("MessageBrokers & Databases"):::infra
    end

    %% Interactions
    U -->|"accesses"| D
    D -->|"calls"| API
    SCH -->|"triggers"| API
    API -->|"manages state"| RS
    API -->|"dispatches tasks"| WL
    WL -->|"executes tasks"| WD
    WL -->|"executes tasks"| WS1
    WL -->|"executes tasks"| WS2
    API -->|"DB/MQ operations"| INF
    WD -->|"state update"| RS
    WS1 -->|"state update"| RS
    WS2 -->|"state update"| RS
    WD -->|"communicates"| INF
    WS1 -->|"communicates"| INF
    WS2 -->|"communicates"| INF

    %% Container Orchestration Deployment (dotted lines indicating deployment/scaling)
    DOC -.-> API
    DOC -.-> D
    DOC -.-> RS
    DOC -.-> SCH
    DOC -.-> WL
    K8S -.-> API
    K8S -.-> D
    K8S -.-> RS
    K8S -.-> SCH
    K8S -.-> WL

    %% Click Events
    click API "https://github.com/d10s0vsky-oss/stack-lifecycle-deployment/tree/master/sld-api-backend"
    click D "https://github.com/d10s0vsky-oss/stack-lifecycle-deployment/tree/master/sld-dashboard"
    click RS "https://github.com/d10s0vsky-oss/stack-lifecycle-deployment/tree/master/sld-remote-state"
    click SCH "https://github.com/d10s0vsky-oss/stack-lifecycle-deployment/tree/master/sld-schedule"
    click WD "https://github.com/d10s0vsky-oss/stack-lifecycle-deployment/blob/master/play-with-sld/kubernetes/k8s/sld-worker-default.yml"
    click WS1 "https://github.com/d10s0vsky-oss/stack-lifecycle-deployment/blob/master/play-with-sld/kubernetes/k8s/sld-worker-squad1.yml"
    click WS2 "https://github.com/d10s0vsky-oss/stack-lifecycle-deployment/blob/master/play-with-sld/kubernetes/k8s/sld-worker-squad2.yml"
    click WL "https://github.com/d10s0vsky-oss/stack-lifecycle-deployment/tree/master/sld-api-backend/src/worker"
    click DOC "https://github.com/d10s0vsky-oss/stack-lifecycle-deployment/tree/master/play-with-sld/docker"
    click K8S "https://github.com/d10s0vsky-oss/stack-lifecycle-deployment/tree/master/play-with-sld/kubernetes"
    click INF "https://github.com/d10s0vsky-oss/stack-lifecycle-deployment/tree/master/play-with-sld/kubernetes/k8s"

    %% Styles
    classDef frontend fill:#ffcccc,stroke:#333,stroke-width:2px;
    classDef backend fill:#ccffcc,stroke:#333,stroke-width:2px;
    classDef worker fill:#ccccff,stroke:#333,stroke-width:2px;
    classDef orch fill:#ffffcc,stroke:#333,stroke-width:2px;
    classDef infra fill:#ccffff,stroke:#333,stroke-width:2px;
```
