# orbit-alliance/orbit-backend architecture

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

- Interactive diagram: https://gitdiagram.com/orbit-alliance/orbit-backend
- Repository: https://github.com/orbit-alliance/orbit-backend

## Overview

##### Project type and purpose
- It exposes an HTTP API for “user” operations (e.g., transferring coins) and has infrastructure adapters for a database (MongoDB) and a Web3 provider (blockchain node).

##### File structure
- Top-level files: go.mod/go.sum define dependencies; RFC01-Architecture likely contains design notes.
- internal/domain: core business objects (User entity, Commands, Events, Repository interface, shared types like MongoID).
- internal/application: “use case” or “service” layer—application logic (e.g., TransferCoins service).
- internal/infra: concrete adapters—db (Mongo) and web3 (blockchain) implementations.
- internal/interface: entry-points or “driving adapters”: HTTP controllers/routes and Web3 interface stubs.

##### Key insights from the README
- Project is a backend service that manages user accounts and coin transfers, integrating with a database and blockchain via Web3.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Client
    HTTPClient["HTTP Client"]:::external

    %% Interface Layer
    subgraph "Interface Layer"
        Controllers["HTTP Controllers"]:::interface
        Routes["HTTP Routes"]:::interface
        Web3Stub["Web3 Interface Stub"]:::interface
    end

    %% Application Layer
    subgraph "Application Layer"
        TransferCoins["TransferCoinsService"]:::application
    end

    %% Domain Layer
    subgraph "Domain Layer"
        UserEntity["User Entity"]:::domain
        Commands["Commands"]:::domain
        Events["Events"]:::domain
        RepositoryInterface["UserRepository Interface"]:::domain
        Errors["Domain Errors"]:::domain
        SharedMongoID["Shared MongoID"]:::domain
        SharedEvents["Shared Events"]:::domain
    end

    %% Infrastructure Adapters
    subgraph "Infrastructure Adapters"
        MongoDBAdapter["MongoDB Adapter"]:::infra
        Web3Adapter["Web3 Adapter"]:::infra
    end

    %% External Systems
    MongoDB["MongoDB"]:::external
    Web3Node["Web3 Node"]:::external

    %% Connections
    HTTPClient --> Routes
    Routes --> Controllers
    Controllers --> TransferCoins
    Controllers --> Web3Stub
    TransferCoins --> UserEntity
    TransferCoins --> Commands
    TransferCoins --> Events
    TransferCoins --> Errors
    TransferCoins --> SharedMongoID
    TransferCoins --> SharedEvents
    TransferCoins --> RepositoryInterface
    TransferCoins --> Web3Stub
    RepositoryInterface -.-> MongoDBAdapter
    Web3Stub -.-> Web3Adapter
    MongoDBAdapter --> MongoDB
    Web3Adapter --> Web3Node

    %% Click Events
    click Controllers "https://github.com/orbit-alliance/orbit-backend/tree/main/internal/interface/http/controllers"
    click Routes "https://github.com/orbit-alliance/orbit-backend/tree/main/internal/interface/http/routes"
    click Web3Stub "https://github.com/orbit-alliance/orbit-backend/tree/main/internal/interface/web3"
    click TransferCoins "https://github.com/orbit-alliance/orbit-backend/blob/main/internal/application/user/services/transfer_coins.go"
    click UserEntity "https://github.com/orbit-alliance/orbit-backend/blob/main/internal/domain/user/user.go"
    click Commands "https://github.com/orbit-alliance/orbit-backend/blob/main/internal/domain/user/commands.go"
    click Events "https://github.com/orbit-alliance/orbit-backend/blob/main/internal/domain/user/events.go"
    click RepositoryInterface "https://github.com/orbit-alliance/orbit-backend/blob/main/internal/domain/user/repository.go"
    click Errors "https://github.com/orbit-alliance/orbit-backend/blob/main/internal/domain/user/errors.go"
    click SharedMongoID "https://github.com/orbit-alliance/orbit-backend/blob/main/internal/domain/shared/mongo_id.go"
    click SharedEvents "https://github.com/orbit-alliance/orbit-backend/blob/main/internal/domain/shared/events.go"
    click MongoDBAdapter "https://github.com/orbit-alliance/orbit-backend/tree/main/internal/infra/db"
    click Web3Adapter "https://github.com/orbit-alliance/orbit-backend/tree/main/internal/infra/web3"

    %% Styles
    classDef interface fill:#bbdefb,stroke:#1e88e5,color:#0d47a1;
    classDef application fill:#c8e6c9,stroke:#43a047,color:#1b5e20;
    classDef domain fill:#fff9c4,stroke:#fdd835,color:#f57f17;
    classDef infra fill:#ffcdd2,stroke:#e53935,color:#b71c1c;
    classDef external fill:#eceff1,stroke:#546e7a,color:#263238;
```
