# ethernal-tech/cardano-infrastructure architecture

> Architecture diagram of the GitHub repository ethernal-tech/cardano-infrastructure, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ethernal-tech/cardano-infrastructure
- Repository: https://github.com/ethernal-tech/cardano-infrastructure

## Overview

##### Main Components
- Main Application: Represented by main.go which ties together all the modules.
- Indexer Module: Found in the “indexer” directory; it handles block indexing, syncing, parsing raw transactions, and interacts with database storage using different backends (bbolt and leveldb, as seen in “indexer/db”).
- Wallet Module: Located in the “wallet” directory; it covers wallet operations (address management, transaction creation/signing) and has several txprovider subcomponents (supporting services such as Blockfrost, Cats, CLI, Demeter, Gourboros, Ogmios), indicating pluggable external connections.
- Secrets Management: Under “secrets”, which abstracts different secrets handling strategies (AWS, GCP, Hashicorp Vault, and local), ensuring secure handling of credentials and configuration details.
- Common Utilities: Provided by the “common” directory (circular queues, retry logic, etc.) that support shared functionality across modules.
- Rules Engine (gorules): Likely a rule-checking or validation component to enforce business or protocol-specific rules.
- Logging: The “logger” directory provides a centralized logging mechanism used across the system.

##### Relationships and Interactions
- The Main Application (main.go) serves as the entry point, initializing the various modules.
- The Wallet module interacts with external transaction providers (each represented as a separate service) to send transactions and communicate with the Cardano blockchain.
- The Secrets Management system provides secure configuration and credentials to both the Indexer and Wallet (and possibly other components) for external integrations.
- The Gorules module can be shown intersecting with both the Indexer (for validating block data) and the Wallet (for ensuring transaction policies/rules are met).

##### Architectural Patterns and Technologies
- Modularity: Each major feature area (indexer, wallet, secrets, etc.) is separated into its own package.
- Pluggable Providers: Especially within the wallet module, a provider pattern allows different backends (Blockfrost, etc.) to be integrated seamlessly.
- Multiple Database Backends: The indexer supports different storage solutions via different packages.
- Secrets Abstraction: An abstraction layer supports multiple secrets storage mechanisms for flexibility.
- Test Coverage: The presence of a comprehensive set of test files indicates an emphasis on reliability and modular testing.

## Diagram (Mermaid)

```mermaid
flowchart TD
    A["Main Application (main.go)"]:::mainApp

    subgraph "Indexer Service"
        I["Indexer (indexer/)"]:::module
        IB["Bbolt DB (indexer/db/bbolt)"]:::database
        IL["LevelDB DB (indexer/db/leveldb)"]:::database
        I -->|"stores"| IB
        I -->|"stores"| IL
    end

    subgraph "Wallet Service"
        W["Wallet (wallet/)"]:::module
        T1["TxProvider_Blockfrost (wallet/txprovider_blockfrost.go)"]:::module
        T2["TxProvider_Cats (wallet/txprovider_cats.go)"]:::module
        T3["TxProvider_CLI (wallet/txprovider_cli.go)"]:::module
        T4["TxProvider_Demeter (wallet/txprovider_demeter.go)"]:::module
        T5["TxProvider_Gourboros (wallet/txprovider_gourboros.go)"]:::module
        T6["TxProvider_Ogmios (wallet/txprovider_ogmios.go)"]:::module
        W -->|"initializes"| T1
        W -->|"initializes"| T2
        W -->|"initializes"| T3
        W -->|"initializes"| T4
        W -->|"initializes"| T5
        W -->|"initializes"| T6
        CN["Cardano Network"]:::external
        T1 -->|"dispatch"| CN
        T2 -->|"dispatch"| CN
        T3 -->|"dispatch"| CN
        T4 -->|"dispatch"| CN
        T5 -->|"dispatch"| CN
        T6 -->|"dispatch"| CN
    end

    subgraph "Secrets Management"
        S["Secrets (secrets/)"]:::secret
        S1["AWS SSM (secrets/awsssm)"]:::secret
        S2["GCP SSM (secrets/gcpssm)"]:::secret
        S3["Hashicorp Vault (secrets/hashicorpvault)"]:::secret
        S4["Local Secrets (secrets/local)"]:::secret
        S -->|"includes"| S1
        S -->|"includes"| S2
        S -->|"includes"| S3
        S -->|"includes"| S4
    end

    C["Common Utilities (common/)"]:::common
    L["Logging (logger/)"]:::logger
    R["Rules Engine (gorules/)"]:::rule

    %% Main Application Initialization
    A -->|"initializes"| I
    A -->|"initializes"| W
    A -->|"initializes"| S
    A -->|"initializes"| C
    A -->|"initializes"| L
    A -->|"initializes"| R

    %% Module Dependencies
    I -->|"uses"| S
    I -->|"logsTo"| L
    I -->|"utilizes"| C

    W -->|"uses"| S
    W -->|"logsTo"| L
    W -->|"utilizes"| C
    W -->|"validates"| R

    %% Database and Rule Validations
    I -->|"validates"| R

    %% Click Events
    click A "https://github.com/ethernal-tech/cardano-infrastructure/blob/main/main.go"
    click I "https://github.com/ethernal-tech/cardano-infrastructure/tree/main/indexer/"
    click IB "https://github.com/ethernal-tech/cardano-infrastructure/tree/main/indexer/db/bbolt"
    click IL "https://github.com/ethernal-tech/cardano-infrastructure/tree/main/indexer/db/leveldb"
    click W "https://github.com/ethernal-tech/cardano-infrastructure/tree/main/wallet/"
    click T1 "https://github.com/ethernal-tech/cardano-infrastructure/blob/main/wallet/txprovider_blockfrost.go"
    click T2 "https://github.com/ethernal-tech/cardano-infrastructure/blob/main/wallet/txprovider_cats.go"
    click T3 "https://github.com/ethernal-tech/cardano-infrastructure/blob/main/wallet/txprovider_cli.go"
    click T4 "https://github.com/ethernal-tech/cardano-infrastructure/blob/main/wallet/txprovider_demeter.go"
    click T5 "https://github.com/ethernal-tech/cardano-infrastructure/blob/main/wallet/txprovider_gourboros.go"
    click T6 "https://github.com/ethernal-tech/cardano-infrastructure/blob/main/wallet/txprovider_ogmios.go"
    click S "https://github.com/ethernal-tech/cardano-infrastructure/tree/main/secrets/"
    click S1 "https://github.com/ethernal-tech/cardano-infrastructure/tree/main/secrets/awsssm"
    click S2 "https://github.com/ethernal-tech/cardano-infrastructure/tree/main/secrets/gcpssm"
    click S3 "https://github.com/ethernal-tech/cardano-infrastructure/tree/main/secrets/hashicorpvault"
    click S4 "https://github.com/ethernal-tech/cardano-infrastructure/tree/main/secrets/local"
    click C "https://github.com/ethernal-tech/cardano-infrastructure/tree/main/common/"
    click L "https://github.com/ethernal-tech/cardano-infrastructure/tree/main/logger/"
    click R "https://github.com/ethernal-tech/cardano-infrastructure/tree/main/gorules/"

    %% Styles
    classDef mainApp fill:#ffcc00,stroke:#333,stroke-width:2px;
    classDef module fill:#cce5ff,stroke:#333,stroke-width:2px;
    classDef database fill:#d4edda,stroke:#333,stroke-width:2px,stroke-dasharray:5,5;
    classDef secret fill:#f8d7da,stroke:#333,stroke-width:2px;
    classDef external fill:#e2e3e5,stroke:#333,stroke-width:2px,stroke-dasharray:2,2;
    classDef logger fill:#fff3cd,stroke:#333,stroke-width:2px;
    classDef rule fill:#d1ecf1,stroke:#333,stroke-width:2px;
    classDef common fill:#d6d8db,stroke:#333,stroke-width:2px;
```
