# akachain/akc-mamba architecture

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

- Interactive diagram: https://gitdiagram.com/akachain/akc-mamba
- Repository: https://github.com/akachain/akc-mamba

## Overview

##### Project type and purpose
- This is an open-source, CLI-driven **infrastructure-as-code tool** (“AKC-Mamba”) for automating the deployment and management of a **Hyperledger Fabric 1.4** blockchain network on **AWS EKS** (Kubernetes). It bundles Fabric components (CAs, ordering service, peers, sample chaincode), custom administrative APIs, and monitoring stacks (Explorer, Prometheus, Grafana).

##### File structure
- Top-level modules:
- mamba/cli – the Python CLI entry point
- mamba/blockchain – commands to bootstrap, register orgs/peers/orderers, generate artifacts, start/terminate the Fabric network
- mamba/k8s – wrappers to install Kubernetes components (EFS, ingress, autoscaler, VPN, secrets)
- mamba/template – YAML templates for Kubernetes Deployments/StatefulSets/Jobs for every Fabric component and auxiliary services
- mamba/scripts – shell scripts invoked by the CLI for low-level tasks (cryptogen, configtxgen, registrations)
- eks/, efs/ – provider-specific setup guides and policies for AWS EKS & EFS
- CI/CD: .github workflows for issue labeling; setup.py, requirements.txt, packaging.

##### README for additional insights
- **System Model**:
– 1 Root CA + 1 Intermediate CA per organization
– Kafka-based ordering service (Kafka + Zookeeper)
– A pre-configured number of peer nodes per org
– Bootstrapped sample chaincode
– In-house tools: AKC-Admin (REST API), Fabric Explorer, Prometheus, Grafana
- **Deploy targets**: AWS EKS cluster, EFS for shared storage, Bastion host as the operator’s client.

##### Final advice
- Be as **detailed** as possible: block out each StatefulSet/Deployment with its PVCs and Services.
- Both the **static topology** (how many pods, storage attachments) and the **dynamic interactions** (workflow phases and data flows).
- Don’t overthink—maximally decompose into logical components, then annotate connections clearly.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Operator Side
    subgraph "Operator Side"
        CLI["Bastion Host / Operator CLI"]:::control
    end

    %% Cloud Infrastructure
    subgraph "Cloud Provider" 
        EKS["AWS EKS Control Plane"]:::infra
        EFS["AWS EFS Filesystem"]:::storage
    end

    CLI -->|"kubectl apply / AWS API"| EKS

    EFS -->|"PVC Storage"| rootca
    EFS -->|"PVC Storage"| orderer
    EFS -->|"PVC Storage"| peers

    EKS --> K8sCluster

    %% Kubernetes Cluster Components
    subgraph "Kubernetes Cluster"
        subgraph "Certificate Authorities"
            rootca["Root CA StatefulSet"]:::blockchain
            ica["Intermediate CA StatefulSets"]:::blockchain
        end

        subgraph "Ordering Service"
            kafka["Kafka StatefulSet"]:::blockchain
            zookeeper["Zookeeper StatefulSet"]:::blockchain
            orderer["Orderer StatefulSet + Service"]:::blockchain
        end

        subgraph "Peer Network"
            peers["Peer StatefulSets + Services"]:::blockchain
        end

        subgraph "Chaincode"
            chaincodeJobs["External Chaincode Jobs & Deployments"]:::blockchain
        end

        subgraph "Admin & Monitoring"
            AKCAdmin["AKC-Admin Deployment + Service"]:::monitoring
            Explorer["Explorer Deployment + Service"]:::monitoring
            ExplorerDB["Explorer DB Deployment"]:::monitoring
            Prometheus["Prometheus StatefulSet + Service"]:::monitoring
            Grafana["Grafana StatefulSet + Service"]:::monitoring
        end
    end

    %% Interactions
    rootca -->|"issues TLS/MSP certs"| ica
    rootca -->|"issues TLS/MSP certs"| peers
    rootca -->|"issues TLS/MSP certs"| orderer

    peers -->|"transactions"| orderer
    orderer -->|"consensus"| kafka
    kafka -->|"coordination"| zookeeper

    AKCAdmin -->|"Fabric SDK calls"| peers
    AKCAdmin -->|"Fabric SDK calls"| orderer

    Explorer -->|"reads blocks/events"| peers
    Explorer -->|"reads blocks/events"| orderer
    Explorer -->|"stores data"| ExplorerDB

    Prometheus -->|"scrapes metrics"| rootca
    Prometheus -->|"scrapes metrics"| ica
    Prometheus -->|"scrapes metrics"| peers
    Prometheus -->|"scrapes metrics"| orderer
    Prometheus -->|"scrapes metrics"| kafka
    Prometheus -->|"scrapes metrics"| zookeeper

    Grafana -->|"visualizes"| Prometheus

    CLI -->|"triggers chaincode jobs"| chaincodeJobs

    %% Click Events
    click CLI "https://github.com/akachain/akc-mamba/blob/develop/mamba/cli/mamba.py"
    click BlockchainCmds "https://github.com/akachain/akc-mamba/tree/develop/mamba/blockchain/"
    click Chaincodes "https://github.com/akachain/akc-mamba/tree/develop/mamba/blockchain/artifacts/src/chaincodes/"
    click K8sWrappers "https://github.com/akachain/akc-mamba/tree/develop/mamba/k8s/"
    click Template "https://github.com/akachain/akc-mamba/tree/develop/mamba/template/"
    click Scripts "https://github.com/akachain/akc-mamba/tree/develop/mamba/scripts/"
    click EKS "https://github.com/akachain/akc-mamba/tree/develop/eks/"
    click EFS "https://github.com/akachain/akc-mamba/tree/develop/efs/"
    click Setup "https://github.com/akachain/akc-mamba/blob/develop/setup.py"
    click Labeler "https://github.com/akachain/akc-mamba/blob/develop/.github/workflows/label.yml"

    %% Styling
    classDef control fill:#cce5ff,stroke:#004085,color:#004085
    classDef blockchain fill:#d4edda,stroke:#155724,color:#155724
    classDef infra fill:#e2e3e5,stroke:#6c757d,color:#6c757d
    classDef monitoring fill:#fff3cd,stroke:#856404,color:#856404
    classDef storage fill:#f8d7da,stroke:#721c24,color:#721c24

    class rootca,ica,kafka,zookeeper,orderer,peers,chaincodeJobs blockchain
    class AKCAdmin,Explorer,ExplorerDB,Prometheus,Grafana monitoring
    class EKS infra
    class CLI control
    class EFS storage
```
