# 0xpolygonid/issuer-node architecture

> Architecture diagram of the GitHub repository 0xpolygonid/issuer-node, 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/0xpolygonid/issuer-node
- Repository: https://github.com/0xpolygonid/issuer-node

## Overview

##### Main components
- Backend API/Microservices: Under directories such as “cmd” and “internal”, you see several distinct services – “platform”, “migrate”, “notifications”, “pending_publisher”, and even a dedicated “kms_priv_key_importer”. These represent microservices or service processes that handle specific parts of the credential lifecycle.
- Frontend UI: The “ui” directory contains all the source code for the web-based user interface, including components, adapters for communicating with backend APIs, and various asset files.
- API Specification and Documentation: The “api” folder with the “api.yaml” and generated “spec.html” provides the OpenAPI specification, which details the available endpoints and request/response schemas.
- Infrastructure Components: The “infrastructure” directory, along with Dockerfiles and Kubernetes charts (“k8s/helm”), defines the containerized deployment of several dependent services such as Postgres (for persistent data), Redis (for caching/pubsub), and Vault (for secure key management, especially if hashicorp Vault is used as a KMS provider).
- External Services & Dependencies: The README and configuration samples indicate dependencies on external blockchain RPC endpoints (Ethereum RPC via various providers), and integration with a mobile wallet, schema builder, and credential marketplace.

##### Internal organization and architectural patterns
- Clean Architecture / Layered design: The separation into “internal/api”, “internal/core”, “internal/db”, “internal/gateways”, “internal/repositories”, and “internal/services” implies a clean separation of concerns. The “ports” subdirectories indicate the use of interfaces to abstract external or infrastructure-related services.
- Domain-Centric Logic: Under “internal/core/domain” there are business model files (such as identity, claim, connection, etc.) which encapsulate the business rules.
- Adaptors/Interfaces: There are adapters in both the backend (for caching, HTTP, KMS integration) and in the UI (in the “ui/src/adapters”) to interact between different layers and external systems.
- Containerization and CI/CD Pipelines: The presence of multiple Dockerfiles and the .github workflows shows that deployment and continuous integration (including checks, linting, and automated deployment steps) are an integral part of the project.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Frontend Layer"
        UI["Issuer Node UI"]:::frontend
    end

    subgraph "API Documentation"
        APISpec["API Specification (api.yaml & spec.html)"]:::docs
    end

    subgraph "Backend Layer"
        subgraph "Issuer Node API"
            P["Platform Service"]:::backend
            N["Notifications Service"]:::backend
            PP["Pending Publisher Service"]:::backend
            M["Migration Utility"]:::backend
            K["KMS Priv Key Importer"]:::backend
            subgraph "Internal Layers"
                APII["Internal API"]:::backend
                CORE["Internal Core"]:::backend
                DBIntr["Internal DB"]:::backend
            end
        end
    end

    subgraph "Infrastructure Layer"
        Infra["Infrastructure Configurations"]:::infra
        Helm["Kubernetes Helm Charts"]:::infra
        DB["PostgreSQL Database"]:::database
        Cache["Redis Cache"]:::database
        KMSNode["Local & Vault KMS"]:::infra
    end

    subgraph "External Services"
        Blockchain["Blockchain RPC Endpoints"]:::external
        ExtTools["External Tools (Wallet_Schema_Marketplace)"]:::external
    end

    UI -->|"REST_Call"| APII
    APISpec -->|"documents"| UI
    APII -->|"queries"| DB
    APII -->|"caches"| Cache
    APII -->|"manages"| KMSNode
    APII -->|"verifies"| Blockchain

    Infra -->|"deploys"| DB
    Infra -->|"deploys"| Cache
    Infra -->|"configures"| KMSNode
    Helm -->|"orchestrates"| Infra

    click P "https://github.com/0xpolygonid/issuer-node/tree/main/cmd/platform"
    click N "https://github.com/0xpolygonid/issuer-node/tree/main/cmd/notifications"
    click PP "https://github.com/0xpolygonid/issuer-node/tree/main/cmd/pending_publisher"
    click M "https://github.com/0xpolygonid/issuer-node/tree/main/cmd/migrate"
    click K "https://github.com/0xpolygonid/issuer-node/tree/main/cmd/kms_priv_key_importer"
    click APII "https://github.com/0xpolygonid/issuer-node/tree/main/internal/api"
    click CORE "https://github.com/0xpolygonid/issuer-node/tree/main/internal/core"
    click DBIntr "https://github.com/0xpolygonid/issuer-node/tree/main/internal/db"
    click UI "https://github.com/0xpolygonid/issuer-node/tree/main/ui"
    click APISpec "https://github.com/0xpolygonid/issuer-node/blob/main/api/api.yaml"
    click Infra "https://github.com/0xpolygonid/issuer-node/tree/main/infrastructure"
    click Helm "https://github.com/0xpolygonid/issuer-node/tree/main/k8s/helm"
    click KMSNode "https://github.com/0xpolygonid/issuer-node/tree/main/internal/kms"

    classDef frontend fill:#85C1E9,stroke:#2E86C1,stroke-width:2px;
    classDef backend fill:#82E0AA,stroke:#27AE60,stroke-width:2px;
    classDef infra fill:#F7DC6F,stroke:#F1C40F,stroke-width:2px;
    classDef database fill:#F5B7B1,stroke:#E74C3C,stroke-width:2px;
    classDef external fill:#D2B4DE,stroke:#8E44AD,stroke-width:2px;
    classDef docs fill:#F9E79F,stroke:#F4D03F,stroke-width:2px;
```
