> For the complete documentation index, see [llms.txt](https://docs.spendl.money/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.spendl.money/spendl-architecture/spendl-architecture.md). Agents can also search and read this documentation through its [MCP server](https://docs.spendl.money/~gitbook/mcp).

# Spendl Architecture

Version: 2.0

> **Last Updated**: May 2026

## Platform Overview

Spendl Money is a **unified Financial Operating System** that consolidates accounts, cards, payments, digital assets, vouchers, payroll, treasury, remittances, tokenised services, and business tooling into a single regulated platform.

Spendl is not a single consumer product - it is a modular financial infrastructure layer designed so that individuals, businesses, and embedded partners all operate on the same underlying system through different access layers.

### What Spendl Does

| For             | Capability                                                                                                                                 |
| --------------- | ------------------------------------------------------------------------------------------------------------------------------------------ |
| **Individuals** | One app to hold balances, send/receive money, load a card, purchase vouchers, convert digital assets to fiat, and manage everyday spending |
| **Businesses**  | One infrastructure layer to run payroll, issue cards, manage accounts, control spending, launch branded products, and manage treasury      |
| **Partners**    | Access to embedded financial products (wallets, cards, payments, KYC) without building regulated infrastructure                            |

### Access Layers

| Layer               | Purpose                                                                         |
| ------------------- | ------------------------------------------------------------------------------- |
| **Consumer App**    | Direct-to-consumer wallet, card, transfers, vouchers, digital assets            |
| **Admin Dashboard** | Business operations, user management, treasury, payroll, compliance             |
| **Partner API**     | Programmatic user onboarding, KYC, wallet operations, debt management, webhooks |
| **White Label**     | Branded wallet experiences powered by Spendl infrastructure                     |

### Product Features

| Feature                           | Description                                                                                                                                                    |
| --------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Spendl Wallet**                 | Digital wallet with real-time balances, transfers, and payment rails                                                                                           |
| **Spendl Card**                   | Physical and virtual cards for in-store and online spending                                                                                                    |
| **Digital Assets**                | Deposit supported crypto assets, convert to fiat, manage alongside regular balances                                                                            |
| **Payments & EFT**                | Send money to bank accounts, manage beneficiaries, real-time settlement                                                                                        |
| **Vouchers**                      | Purchase, distribute, and manage vouchers for rewards, allowances, and benefits                                                                                |
| **Remittance** *(in development)* | Cross-border payments to dozens of African countries through regulated rails                                                                                   |
| **Payroll** *(in development)*    | Automated salary payments into employee wallets with immediate card access                                                                                     |
| **Treasury Management**           | Real-time visibility of funds, reconciliation, and settlement across the platform                                                                              |
| **Tokenised Services**            | On-chain proof-of-reserves and blockchain-backed financial attestation                                                                                         |
| **Acquiring** *(in development)*  | Accept payments from customers across multiple channels                                                                                                        |
| **Branded Solutions**             | White-label wallet and card programs for businesses launching their own products                                                                               |
| **B2B Operating Layer**           | Programmatic partner access to wallet, KYC, and payment operations via API - or fully branded tenant experiences through white-label app and admin deployments |

## Architecture Principles

| Principle                                    | Implication                                                                                                               |
| -------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- |
| **Single ledger of truth**                   | Every unit of value is tracked through one double-entry engine - no shadow ledgers, no reconciliation gaps                |
| **Prove, don't promise**                     | Pool account movements are cryptographically attested on a public blockchain - reserves are verifiable by any third party |
| **Secure by default**                        | Services are internal unless explicitly exposed; all inter-service traffic is mutually authenticated                      |
| **Tenant isolation without duplication**     | Multiple brands run on shared infrastructure with hard network boundaries - one codebase, zero data leakage               |
| **Deploy independently, fail independently** | Each service owns its own lifecycle, namespace, and scaling profile                                                       |
| **No long-lived secrets**                    | All workloads and pipelines use short-lived, federated credentials                                                        |

## System Architecture

```mermaid
graph TB
    %% Users
    Individuals([Individuals])
    Businesses([Businesses])
    Partners([Partners / B2B2C])

    %% Access Layers
    subgraph Access["Access Layers"]
        APP[Consumer App]
        ADMIN[Admin Dashboard]
        API_EXT[Partner API]
        WHITELABEL[White Label]
    end

    %% Edge
    subgraph Edge["Edge & Delivery"]
        CDN[Global CDN]
        LB[Load Balancer<br/>TLS Termination]
    end

    %% Platform
    subgraph Platform["Spendl Platform"]
        MESH[Service Mesh<br/>mTLS · Rate Limiting]

        subgraph Public["Gateway Services"]
            REST[API Gateway]
            INGEST[Partner Ingestor]
            TENANT[Tenant Configuration]
        end

        subgraph Core["Financial Core (Internal DMZ)"]
            LEDGER[Treasury Ledger]
            ATTEST[Attestation Engine]
            NOTIF[Notification Dispatch]
        end
    end

    %% Data
    subgraph Data["Data & Security"]
        DB[(Encrypted Database)]
        STORE[(Encrypted Object Storage)]
        KMS[Hardware Key Management]
        AUTH[Identity Provider<br/>OAuth 2.0 PKCE]
    end

    %% External
    subgraph External["External Partners"]
        BANKING[Banking & Card Partners]
        EXCHANGE[Digital Asset Exchange]
        CHAIN[Public Blockchain]
        COMMS[Communication Providers]
        REMIT[Remittance Partners]
    end

    %% Connections
    Individuals --> APP
    Businesses --> ADMIN
    Partners --> API_EXT
    Businesses --> WHITELABEL

    APP --> CDN
    ADMIN --> CDN
    WHITELABEL --> CDN
    API_EXT --> LB
    CDN --> LB

    LB --> MESH
    MESH --> Public
    MESH --> Core

    REST --> LEDGER
    INGEST --> LEDGER
    LEDGER --> ATTEST
    REST --> NOTIF

    Public --> DB
    Core --> DB
    INGEST --> STORE
    ATTEST --> KMS
    ATTEST --> CHAIN
    REST --> BANKING
    REST --> EXCHANGE
    REST --> REMIT
    NOTIF --> COMMS
    APP -.-> AUTH
    ADMIN -.-> AUTH
```

## Platform Capabilities

### Financial Operating System

At the core of Spendl is a **double-entry treasury ledger** that tracks every unit of value movement. All operations - deposits, transfers, withdrawals, card loads, voucher purchases, debt repayments, payroll disbursements - produce balanced journal entries.

This design provides:

* **Real-time balances:** Account balances are always consistent and auditable
* **Atomic operations:** Multi-party transactions (fees, splits) are processed as single entries
* **Full auditability:** Every cent that enters or leaves the system is traceable
* **Idempotency:** Duplicate-safe mutation operations prevent double-processing
* **On-chain attestation:** Pool account movements are cryptographically proven on a public blockchain

### How Money Flows

```mermaid
graph LR
    subgraph Funding["Funding Sources"]
        BANK[Bank Deposit]
        CRYPTO[Digital Asset Conversion]
        PAYROLL_IN[Payroll Funding]
    end

    subgraph Ledger["Treasury Ledger"]
        JOURNAL[Double-Entry<br/>Journal Engine]
    end

    subgraph Spending["Spending Channels"]
        CARD[Card Payment]
        EFT[Bank Transfer / EFT]
        TRANSFER[Peer Transfer]
        VOUCHER[Voucher Purchase]
        REMIT_OUT[Remittance]
        DEBT[Debt Repayment]
    end

    subgraph Proof["Proof Layer"]
        CHAIN_ATTEST[Blockchain Attestation]
    end

    BANK --> JOURNAL
    CRYPTO --> JOURNAL
    PAYROLL_IN --> JOURNAL

    JOURNAL --> CARD
    JOURNAL --> EFT
    JOURNAL --> TRANSFER
    JOURNAL --> VOUCHER
    JOURNAL --> REMIT_OUT
    JOURNAL --> DEBT

    JOURNAL --> CHAIN_ATTEST
```

## Service Architecture

The platform is composed of independently deployable microservices, each with a single responsibility. The table below highlights the primary service groupings - in practice, the platform comprises **30+ specialised services** spanning payments, scheduling, reconciliation, identity, and more, each independently scaled and deployed.

| Service Layer             | Responsibility                                                                              | Exposure      |
| ------------------------- | ------------------------------------------------------------------------------------------- | ------------- |
| **API Gateway**           | User-facing operations - authentication, accounts, orders, payments, admin                  | Public        |
| **Partner Ingestor**      | B2B API - user onboarding, KYC document intake, debt obligations, wallet proxying, webhooks | Public        |
| **Tenant Configuration**  | Multi-tenant lifecycle - brand manifests, feature flags, themes                             | Public        |
| **Treasury Ledger**       | Financial core - double-entry journaling, settlement, reconciliation, scheduling            | Internal only |
| **Attestation Engine**    | Blockchain operations - mint/burn attestations, hardware-backed signing                     | Internal only |
| **Notification Dispatch** | Communication - email/messaging delivery, tenant-branded templates                          | Internal only |

### Communication Model

* **Public-facing services** accept authenticated external traffic and delegate to internal services
* **Internal DMZ services** have no external network route - they are unreachable from the internet and can only be invoked by other authenticated platform services via mutual TLS
* **Event-driven processing** handles asynchronous workflows (scheduling, retries, notifications)
* **Namespace isolation** prevents unintended coupling between services

## Security

### Defence-in-Depth

| Layer            | Controls                                                                                                       |
| ---------------- | -------------------------------------------------------------------------------------------------------------- |
| **Edge**         | TLS 1.2+ termination, per-route rate limiting, CORS enforcement                                                |
| **Ingress**      | Authorization policies, circuit breakers on upstream connections                                               |
| **Network**      | Namespace isolation, cross-namespace traffic denied by default, egress restricted to allow-listed destinations |
| **Service Mesh** | Strict mutual TLS between all services, automatic certificate rotation, cryptographic workload identity        |
| **Application**  | Input validation at every boundary, XSS sanitisation, idempotency keys, parameter validation                   |
| **Data**         | AES-256 encryption at rest on all stores, TLS 1.2+ in transit everywhere                                       |
| **Secrets**      | Hardware-backed signing keys, short-lived federated credentials, automated rotation                            |

### Identity & Access

| Mechanism                       | Scope                | Purpose                                                      |
| ------------------------------- | -------------------- | ------------------------------------------------------------ |
| **OAuth 2.0 PKCE**              | End users            | Secure login without client secrets                          |
| **JWT + API Key/Secret**        | Partners (B2B)       | Authenticated, scoped API access with token expiry           |
| **Federated workload identity** | Internal services    | Fine-grained permissions, no static credentials in workloads |
| **Federated CI/CD identity**    | Deployment pipelines | Credential-less deployment via identity federation           |
| **Mutual TLS**                  | Pod-to-pod           | Cryptographic service identity verification                  |
| **Hardware security modules**   | Blockchain signing   | Keys never leave tamper-resistant hardware                   |
| **Zero-trust network access**   | Engineers            | Identity-aware access without VPN                            |

### Zero-Trust Principles

* **No implicit trust:** Every service proves its identity cryptographically before communicating
* **Least privilege:** Workloads receive only the permissions they require
* **No long-lived secrets:** Pipelines use federated identity; tokens expire in under 1 hour
* **Private-by-default:** Compute nodes have no public IPs; financial services have no external route
* **Credential isolation:** Sensitive configuration is stored per-tenant in encrypted secure-settings stores

## Multi-Tenancy & White Label

Spendl's multi-tenant architecture enables the same platform to serve multiple brands from shared infrastructure while maintaining hard isolation boundaries.

### How Multi-Tenancy Works

| Concern            | Isolation Approach                                                                      |
| ------------------ | --------------------------------------------------------------------------------------- |
| **Compute**        | Dedicated namespace per brand-environment with strict network policies                  |
| **Traffic**        | Per-brand domain routing through shared edge infrastructure                             |
| **Frontend**       | Independent deployment per tenant with build-time asset and configuration swap          |
| **Configuration**  | Centralised tenant service provides brand manifests, feature flags, and secure settings |
| **Feature access** | Granular feature flags control which capabilities each tenant can access                |
| **Data**           | Tenant-scoped queries with attribution; logical isolation at the data layer             |

### White-Label Capabilities

Businesses deploying Spendl as a white-label product receive:

* **Branded consumer app:** Custom logos, colours, themes configured via tenant manifest
* **Branded admin dashboard:** Operations portal in their brand identity
* **Custom domain:** Traffic routed via their own subdomain
* **Feature selection:** Only expose the capabilities relevant to their use case
* **Independent deployment:** Frontend changes deploy without affecting other tenants

## Proof-of-Reserves

A differentiating capability of the Spendl platform is **cryptographic proof-of-reserves** via on-chain attestation.

### How It Works

When fiat currency enters or leaves Spendl's pooled bank account:

1. The **Treasury Ledger** records a balanced double-entry journal entry
2. The **Attestation Engine** creates a mint (deposit) or burn (withdrawal) transaction
3. The transaction is signed using a **hardware-backed key** that never leaves tamper-resistant hardware
4. The signed transaction is submitted to a **public blockchain**
5. The on-chain token supply always equals the platform's fiat reserves

### Properties

| Property           | Description                                                                   |
| ------------------ | ----------------------------------------------------------------------------- |
| **Token**          | Non-transferable ERC-20 (mint and burn only - no transfers between addresses) |
| **Peg**            | 1 token = 1 ZAR cent (R0.01)                                                  |
| **Signing**        | Hardware security module, bound to a single service identity                  |
| **Verification**   | Any party can query `totalSupply()` on-chain and compare to reported reserves |
| **Reconciliation** | Automated periodic comparison of ledger balance versus on-chain supply        |
| **Alerting**       | Discrepancy detection triggers immediate investigation                        |

### Security Controls

* Private key never leaves the hardware security module
* Only one service identity has permission to invoke the signing operation
* The attestation engine has no external network route - unreachable from outside the platform
* Nonce management prevents replay attacks and ensures transaction ordering
* Gas balance monitoring with automated alerts

## Resilience & Recovery

### High Availability

| Component           | Strategy                                                     |
| ------------------- | ------------------------------------------------------------ |
| Orchestration plane | Managed, multi-availability-zone control plane               |
| Compute nodes       | Auto-scaling across multiple availability zones              |
| Ingress             | Replicated with anti-affinity rules                          |
| Networking          | Redundant per availability zone - no single point of failure |
| Database            | Multi-node replica set with automatic failover               |
| Management plane    | HA cluster with off-site backup                              |

### Application Resilience

| Pattern                        | Purpose                                            |
| ------------------------------ | -------------------------------------------------- |
| Circuit breakers               | Automatic upstream failure isolation               |
| Retry with exponential backoff | Recovery from transient failures                   |
| Request timeout budgets        | Prevent cascade failures                           |
| Per-route rate limiting        | Protect against abuse                              |
| Idempotency keys               | Prevent double-processing on retry                 |
| Optimistic locking             | Safe concurrent balance updates                    |
| Fire-and-forget patterns       | Non-critical operations don't block business logic |
| Dead-letter queues             | Failed async operations captured for investigation |

### Recovery Targets

| Metric                             | Target       |
| ---------------------------------- | ------------ |
| **RTO** (Recovery Time Objective)  | < 15 minutes |
| **RPO** (Recovery Point Objective) | < 1 minute   |

## Compliance & Data Residency

| Requirement               | Implementation                                                                  |
| ------------------------- | ------------------------------------------------------------------------------- |
| **Data residency**        | All compute, storage, and database hosted in South Africa                       |
| **POPIA compliance**      | South African data protection - no data leaves jurisdiction                     |
| **Encryption at rest**    | AES-256 on all data stores with managed key rotation                            |
| **Encryption in transit** | TLS 1.2+ on all connections; mutual TLS between all internal services           |
| **KYC storage**           | Documents in regionally-pinned encrypted storage with access audit              |
| **Audit trail**           | Every financial operation logged with timestamp, actor, and full journal detail |
| **Secret rotation**       | Automated rotation for all application secrets and mesh certificates            |
| **Access logging**        | Full control-plane audit logging for all administrative operations              |

## Summary

Spendl Money is designed from the ground up as a secure, auditable, multi-tenant financial platform. Every design decision prioritises:

* **Trust through transparency** - On-chain proof-of-reserves means third parties can independently verify that customer funds are fully backed
* **Security through architecture** - Defence-in-depth, zero-trust networking, and hardware-backed cryptography protect the platform at every layer
* **Flexibility through modularity** - Independent services, per-tenant configuration, and granular feature flags allow the platform to serve diverse use cases from one codebase
* **Reliability through redundancy** - Multi-zone infrastructure, automatic failover, and tested recovery procedures ensure the platform is always available

*For partnership, integration, or compliance enquiries, contact the Spendl team directly.*
