Files
Sankofa/docs/marketplace/sovereign-stack/ledger-service.md
defiQUG 33d50fb91e
Some checks failed
API CI / API Lint (push) Successful in 47s
API CI / API Type Check (push) Failing after 47s
API CI / API Test (push) Successful in 1m0s
API CI / API Build (push) Failing after 50s
API CI / Build Docker Image (push) Has been skipped
Build Crossplane Provider / build (push) Failing after 5m51s
CD Pipeline / Deploy to Staging (push) Failing after 29s
CI Pipeline / Lint and Type Check (push) Failing after 36s
CI Pipeline / Build (push) Has been skipped
CI Pipeline / Test Backend (push) Failing after 1m33s
CI Pipeline / Test Frontend (push) Failing after 30s
CI Pipeline / Security Scan (push) Failing after 1m16s
Crossplane Provider CI / Go Test (push) Failing after 3m23s
Crossplane Provider CI / Go Lint (push) Failing after 7m27s
Crossplane Provider CI / Go Build (push) Failing after 3m27s
Deploy to Staging / Deploy to Staging (push) Failing after 30s
Portal CI / Portal Lint (push) Failing after 21s
Portal CI / Portal Type Check (push) Failing after 21s
Portal CI / Portal Test (push) Failing after 21s
Portal CI / Portal Build (push) Failing after 22s
Test Suite / frontend-tests (push) Failing after 30s
Test Suite / api-tests (push) Failing after 49s
Test Suite / blockchain-tests (push) Failing after 30s
Type Check / type-check (map[directory:. name:root]) (push) Failing after 23s
Type Check / type-check (map[directory:api name:api]) (push) Failing after 21s
Type Check / type-check (map[directory:portal name:portal]) (push) Failing after 19s
Validate Configuration Files / validate (push) Failing after 1m52s
CD Pipeline / Deploy to Production (push) Has been skipped
chore: consolidate local WIP (repo cleanup 20260707)
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-07 09:41:34 -07:00

3.2 KiB

Phoenix Ledger Service

Category: LEDGER_SERVICES
Publisher: Phoenix Cloud Services
Status: PUBLISHED
Version: 1.0.0

Overview

Phoenix Ledger Service is a sovereign-grade double-entry ledger system with virtual accounts, holds, and multi-asset support. It replaces reliance on external platforms (e.g., Tatum Virtual Accounts) with owned core primitives.

Key Features

  • Double-entry accounting: Every transaction is a balanced journal entry
  • Virtual account abstraction: Subaccounts for multi-currency/asset support
  • Holds and reserves: Reserve funds with expiry and automatic release
  • Multi-asset support: Fiat, stablecoins, tokens in unified system
  • Reconciliation engine: Automated reconciliation and audit trail
  • Idempotent operations: All operations idempotent via correlation_id
  • State machine settlement: Clear settlement states (initiated → authorized → captured → settled → reversed)

API Endpoints

Create Journal Entry

POST /ledger/entries
Content-Type: application/json

{
  "correlationId": "tx_123456",
  "description": "Payment from user",
  "lines": [
    {
      "accountRef": "account:user_123",
      "debit": 100.00,
      "credit": 0,
      "asset": "USD"
    },
    {
      "accountRef": "account:treasury",
      "debit": 0,
      "credit": 100.00,
      "asset": "USD"
    }
  ]
}

Create Hold

POST /ledger/holds
Content-Type: application/json

{
  "accountId": "account:user_123",
  "amount": 50.00,
  "asset": "USD",
  "expiry": "2024-12-31T23:59:59Z"
}

Get Balance

GET /ledger/balances?accountId=account:user_123&asset=USD

Create Transfer

POST /ledger/transfers
Content-Type: application/json

{
  "fromAccountId": "account:user_123",
  "toAccountId": "account:user_456",
  "amount": 25.00,
  "asset": "USD",
  "correlationId": "transfer_789"
}

Data Model

Accounts

  • account_id: Unique account identifier
  • owner_id: User or organization ID
  • type: USER, TREASURY, CLEARING
  • status: ACTIVE, SUSPENDED, CLOSED

Subaccounts (Virtual Accounts)

  • subaccount_id: Unique subaccount identifier
  • account_id: Parent account reference
  • currency/asset: Asset type (USD, USDC, etc.)
  • labels: Key-value metadata

Journal Entries

  • entry_id: Unique entry identifier
  • timestamp: Entry timestamp
  • description: Human-readable description
  • correlation_id: Idempotency key

Journal Lines

  • entry_id: Journal entry reference
  • account_ref: Account or subaccount reference
  • debit: Debit amount
  • credit: Credit amount
  • asset: Asset type

Pricing

  • Model: Usage-based
  • Free Tier: 10,000 journal entries/month
  • Pricing:
    • Journal entry: $0.001
    • Hold operation: $0.0005
    • Transfer: $0.002

Compliance

  • SOC 2 Type II
  • PCI DSS Level 1
  • GDPR compliant

SLA

  • Uptime: 99.9%
  • Latency: <100ms p95

Architecture

The ledger service uses PostgreSQL with:

  • Partitioned journal tables by month
  • Materialized views for balance calculations
  • Event sourcing for audit trail
  • Outbox pattern for event emission

Integration

See Integration Guide for detailed integration examples.