# cloud-barista/cb-tumblebug architecture

> Architecture diagram of the GitHub repository cloud-barista/cb-tumblebug, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-02-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/cloud-barista/cb-tumblebug
- Repository: https://github.com/cloud-barista/cb-tumblebug

## Overview

##### Project Type and Purpose
- This project is a full‑stack system for managing multi‑cloud infrastructure resources.
- The README clearly states that CB‑Tumblebug is “a system for managing multi‑cloud infrastructure” and that it provisions resources (like virtual machines, networks, storage, etc.) across numerous cloud providers.
- It integrates with other components such as CB‑Spider (cloud API controller) and CB‑MapUI (graphical user interface), uses ETCD as a key–value data store, and provides a REST API (with Swagger documentation).

##### File Structure
- Notice that there are distinct directories for:
– API servers and REST endpoints (under “src/api/rest”) where you see server, middleware, docs (e.g., Swagger YAML/JSON) and different resource handlers.
– Core business logic and domain models (in “src/core”) which include modules for orchestration, provisioning, load balancing, and common utility functions.
– Command entry points in “cmd” (for example, there is a “bcrypt” command which is likely a utility for credential encryption/decryption).
– Initialization scripts and credential management (in “init”) that cover operations for secure registration of cloud credentials via encryption (using hybrid encryption, i.e. RSA and AES).
– Deployment and operational scripts (in “scripts”), including many use-case scenarios (for NLB, ceph, kubernetes clusters, and various cloud operations). These also hint at how the API server is invoked during integration tests.
– Docker and containerization artifacts (Dockerfile, docker-compose.yaml) that indicate this is deployed as multiple containers.
- This structured separation suggests a layered (or microservice‐like) architecture with clear divisions between API (REST endpoints), business core logic and infrastructure (cloud resource management), and external integration (CB‑Spider and MapUI).

##### README for Further Architectural Insights
- The README outlines the system’s external interactions:
– It explains how the REST API server (running on port 1323) is one of the core components.
– It also details how CB‑MapUI (a visual front end) communicates with the system, and how ETCD is used as the key–value database for storing state.
– The credential management flow is described in detail: credentials in a YAML file are encrypted (using AES and then RSA encrypted AES keys), then registered with the API server.
- In addition, the README references how Docker Compose is used to orchestrate the running containers (ETCD, CB‑Spider, CB‑MapUI, and the CB‑Tumblebug API server).

##### Summary
- To capture both the runtime deployment architecture (multiple Docker containers, service orchestration) as well as the software architecture (layered API server, core services, persistence, and external integrations).
- Be detailed so that every piece—from API endpoints and core logic to credential management and cloud interactions—is represented.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Nodes
    A["Client/Users"]:::clients
    B["CB-Tumblebug REST API Server"]:::apiServer
    C["Core Service Modules"]:::core
    D["ETCD (Key-Value DB)"]:::database
    E["CB-Spider (Cloud API Controller)"]:::cloudAPI
    F["CB-MapUI (GUI Interface)"]:::ui
    G["Credential/Initialization Module"]:::security
    H["Auxiliary Scripts"]:::scripts
    I["Containerization & Deployment"]:::container
    J["Cloud Providers"]:::external

    %% Connections (vertical layout)
    A -->|"REST_call"| B
    B -->|"orchestrates"| C
    C -->|"persists_state"| D
    C -->|"invokes_cloud"| E
    B -->|"updates_UI"| F
    G -->|"registers_credentials"| B
    E -->|"calls_API"| J
    H -->|"triggers_use_cases"| B

    %% Container orchestration flows: deployment manages components
    I -->|"deploys"| B
    I -->|"deploys"| D
    I -->|"deploys"| E
    I -->|"deploys"| F
    I -->|"deploys"| H

    %% Click Events
    click B "https://github.com/cloud-barista/cb-tumblebug/tree/main/src/api/rest/server"
    click C "https://github.com/cloud-barista/cb-tumblebug/tree/main/src/core"
    click D "https://github.com/cloud-barista/cb-tumblebug/blob/main/src/kvstore/etcd/etcd.go"
    click E "https://github.com/cloud-barista/cb-tumblebug/blob/main/scripts/runSpider.sh"
    click F "https://github.com/cloud-barista/cb-tumblebug/blob/main/scripts/runMapUI.sh"
    click G "https://github.com/cloud-barista/cb-tumblebug/tree/main/init"
    click H "https://github.com/cloud-barista/cb-tumblebug/tree/main/scripts"
    click I "https://github.com/cloud-barista/cb-tumblebug/tree/main/Dockerfile"
    click I "https://github.com/cloud-barista/cb-tumblebug/blob/main/docker-compose.yaml"

    %% Styles
    classDef clients fill:#FFD700,stroke:#333,stroke-width:2px;
    classDef apiServer fill:#ffcc00,stroke:#333,stroke-width:2px;
    classDef core fill:#ccffcc,stroke:#333,stroke-width:2px;
    classDef database fill:#f9f,stroke:#333,stroke-width:2px;
    classDef cloudAPI fill:#add8e6,stroke:#333,stroke-width:2px;
    classDef ui fill:#ffa07a,stroke:#333,stroke-width:2px;
    classDef security fill:#d3d3d3,stroke:#333,stroke-width:2px;
    classDef scripts fill:#eed,stroke:#333,stroke-width:2px;
    classDef container fill:#b0e0e6,stroke:#333,stroke-width:2px;
    classDef external fill:#e6e6fa,stroke:#333,stroke-width:2px;
```
