# stavomidnite661/sovr-oracle-ledger architecture

> Architecture diagram of the GitHub repository stavomidnite661/sovr-oracle-ledger, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/stavomidnite661/sovr-oracle-ledger
- Repository: https://github.com/stavomidnite661/sovr-oracle-ledger

## Overview

1. **Overall shape**
   - This repo is a **TypeScript financial platform** with a **React/Vite frontend**, a **server-side core backend**, and several **microservice adapters**.
   - The architecture is centered on a **ledger-first domain model**: accounting, payments, compliance, risk, and blockchain all feed into the same financial system.

2. **Frontend application layer**
   - `index.tsx`, `App.tsx`, `index.css`, and `views/` define the user-facing app.
   - `components/` is organized by domain: `dashboard`, `payments`, `payroll`, `compliance`, `security`, `customers`, plus `layout` and `shared`.
   - The frontend is a **single-page console** that assembles feature views rather than a thin marketing site; it includes operational dashboards, forms, and admin tools.

3. **Core backend / ledger core**
   - `server/api.ts` and `server/db.ts` represent the **main Express-based backend** and database access layer.
   - This layer is the likely home for the legacy “ledger core” responsibilities described in the README: authentication, journal entries, accounts, vendors, employees, and system logging.
   - `services/` holds the domain logic that the backend and integrations rely on: journal templates, reconciliation, compliance reporting, fraud detection, payment processing, blockchain adapters, and logging.

4. **API gateway boundary**
   - `microservices/gateway/index.ts` is the **front door** for backend traffic.
   - The README describes it as routing requests to specialized services by path prefix, which creates a clear boundary between client access and internal service ownership.
   - In diagram terms, this is the main integration choke point between the UI and the internal system.

5. **Specialized microservices**
   - `microservices/risk-compliance`, `microservices/blockchain-bridge`, `microservices/payment-gateway`, and `microservices/bank-connector` are separate integration/service boundaries.
   - They are not full business apps; they are **targeted service slices** for external-system integration and compliance/risk concerns.
   - The repository also includes a `microservices/README.md`, suggesting these are intentionally packaged as independent deployable units.

6. **Payment and banking flow**
   - Payment-related UI in `components/payments/` and `views/Stripe*`/`views/VendorPaymentsView.tsx` likely drives requests into the payment gateway.
   - `services/achPaymentService.ts`, `cardPaymentService.ts`, `directDepositService.ts`, and `stripeJournalService.ts` indicate a pipeline that:
     - accepts payment intent or ACH/direct deposit input,
     - calls Stripe or bank rails,
     - then writes ledger/journal and reconciliation records.
   - `microservices/bank-connector` handles bank-account verification and ACH-style connectivity, while `payment-gateway` fronts Stripe integrations and webhooks.

7. **Compliance, audit, and risk subsystem**
   - `components/compliance/`, `components/security/`, and `views/StripeComplianceView.tsx` expose monitoring and reporting UIs.
   - Backend services such as `auditService.ts`, `complianceReportingService.ts`, `complianceHealthService.ts`, `fraudDetectionService.ts`, `fraudMonitoringService.ts`, `policyManagementService.ts`, `regulatoryManagementService.ts`, and `riskAssessmentService.ts` form the compliance engine.
   - This subsystem is effectively a **cross-cutting control plane**: it consumes events/logs from financial operations and produces audit trails, alerts, policy state, and risk outputs.

8. **Blockchain / token bridge**
   - `microservices/blockchain-bridge`, `services/blockchainService.ts`, `services/tigerbeetleService.ts`, and `contracts/ConsulCreditsWrapper.sol` define the on-chain integration path.
   - `artifacts/` contains compiled contract outputs, so the repo includes the build products for Solidity deployment and interaction.
   - The blockchain layer appears to model a **tokenized value bridge** (Consul Credits / usdSOVR) that can be queried, transferred, minted/burned, and reconciled back into the ledger.

9. **Shared data contracts**
   - `shared/schema.ts` and `shared/schemas.ts` are the main contract boundary between frontend and backend.
   - They likely define the canonical database model and validation layer, which helps keep UI, API, and persistence aligned.
   - `types.ts` and `constants.ts` support the same goal: shared domain shape across layers.

10. **Persistence and operational state**
   - The README points to **PostgreSQL + Drizzle ORM** as the primary persistence layer, with `drizzle.config.ts` and `shared/schema.ts` as the schema source of truth.
   - System records such as journal entries, payment intents, logs, and audit data are intended to persist centrally rather than being owned by each microservice.
   - The architecture therefore combines **distributed integration services** with a **shared financial datastore**.

11. **Testing and build artifacts**
   - `services/*.test.ts` provides unit/integration coverage for core business services.
   - `vite.config.ts`, `tsconfig.json`, `package.json`, and `artifacts/build-info` show a repo that mixes frontend build tooling, backend runtime code, and contract compilation outputs.
   - The presence of generated contract artifacts and docs tooling (`docs/`, `.readthedocs.yaml`) suggests this is both a runnable system and a documented platform.

12. **Important diagram boundaries**
   - Draw the repo as three main zones:
     - **User/UI zone**: React views and shared components.
     - **Core financial platform zone**: backend API, service layer, database, ledger logic, compliance/risk.
     - **External integration zone**: Stripe, banking rails, Base blockchain, and Solidity contract deployment/runtime.
   - The most important data flows are:
     - UI → gateway/backend → database,
     - payment requests → Stripe/banking services → journal/reconciliation,
     - operational events → compliance/risk services,
     - ledger/blockchain synchronization → chain bridge/contracts.

Main entry points: [`App.tsx`](https://github.com/stavomidnite661/sovr-oracle-ledger/blob/main/App.tsx) (Root view), [`server/api.ts`](https://github.com/stavomidnite661/sovr-oracle-ledger/blob/main/server/api.ts) (API server), [`services/multiTenantLedgerService.ts`](https://github.com/stavomidnite661/sovr-oracle-ledger/blob/main/services/multiTenantLedgerService.ts) (Ledger services), [`services/complianceReportingService.ts`](https://github.com/stavomidnite661/sovr-oracle-ledger/blob/main/services/complianceReportingService.ts) (Compliance engine)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["User UI"]
  node_app_shell["App shell<br/>react entry<br/>[index.tsx]"]
  node_app_view["Root view<br/>ui container<br/>[App.tsx]"]
  node_dashboard_views["Ops views<br/>view suite<br/>[DashboardView.tsx]"]
  node_payments_views["Payment views<br/>view suite"]
  node_compliance_views["Compliance views<br/>view suite"]
  node_shared_components["Shared widgets<br/>ui kit<br/>[SystemConsole.tsx]"]
  node_domain_components["Domain modules<br/>feature components<br/>[index.ts]"]
end

subgraph group_core["Core Platform"]
  node_server_api["API server<br/>express backend<br/>[api.ts]"]
  node_db_layer[("Database<br/>postgres/drizzle<br/>[db.ts]")]
  node_shared_schema["Shared schema<br/>contracts<br/>[schema.ts]"]
  node_ledger_services["Ledger services<br/>domain services"]
  node_compliance_risk["Compliance engine<br/>control plane"]
  node_payment_services["Payment services<br/>payment pipeline"]
  node_chain_services["Chain services<br/>blockchain bridge"]
end

subgraph group_integrations["External Integrations"]
  node_gateway["API gateway<br/>routing boundary<br/>[index.ts]"]
  node_payment_gateway["Payment gateway<br/>microservice<br/>[index.ts]"]
  node_bank_connector["Bank connector<br/>microservice<br/>[index.ts]"]
  node_risk_compliance_svc["Risk service<br/>microservice<br/>[index.ts]"]
  node_blockchain_bridge["Chain bridge<br/>microservice<br/>[index.ts]"]
  node_contracts["Solidity contract<br/>on-chain contract"]
end

node_app_shell -->|"boots"| node_app_view
node_app_view -->|"navigates"| node_dashboard_views
node_app_view -->|"navigates"| node_payments_views
node_app_view -->|"navigates"| node_compliance_views
node_app_view -->|"uses"| node_shared_components
node_app_view -->|"uses"| node_domain_components
node_app_view -->|"calls"| node_gateway
node_gateway -->|"routes"| node_server_api
node_server_api -->|"persists"| node_db_layer
node_server_api -->|"validates"| node_shared_schema
node_server_api -->|"orchestrates"| node_ledger_services
node_server_api -->|"orchestrates"| node_compliance_risk
node_server_api -->|"orchestrates"| node_payment_services
node_server_api -->|"orchestrates"| node_chain_services
node_payment_services -->|"integrates"| node_payment_gateway
node_payment_services -->|"integrates"| node_bank_connector
node_payment_services -->|"posts"| node_ledger_services
node_compliance_risk -->|"exposes"| node_risk_compliance_svc
node_compliance_risk -->|"audits"| node_ledger_services
node_compliance_risk -->|"stores"| node_db_layer
node_chain_services -->|"bridges"| node_blockchain_bridge
node_chain_services -->|"targets"| node_contracts
node_chain_services -->|"reconciles"| node_ledger_services
node_ledger_services -->|"writes"| node_db_layer
node_ledger_services -->|"models"| node_shared_schema

click node_app_shell "https://github.com/stavomidnite661/sovr-oracle-ledger/blob/main/index.tsx"
click node_app_view "https://github.com/stavomidnite661/sovr-oracle-ledger/blob/main/App.tsx"
click node_dashboard_views "https://github.com/stavomidnite661/sovr-oracle-ledger/blob/main/views/DashboardView.tsx"
click node_payments_views "https://github.com/stavomidnite661/sovr-oracle-ledger/blob/main/views/StripePaymentsView.tsx"
click node_compliance_views "https://github.com/stavomidnite661/sovr-oracle-ledger/blob/main/views/StripeComplianceView.tsx"
click node_shared_components "https://github.com/stavomidnite661/sovr-oracle-ledger/blob/main/components/shared/SystemConsole.tsx"
click node_domain_components "https://github.com/stavomidnite661/sovr-oracle-ledger/blob/main/components/payments/index.ts"
click node_server_api "https://github.com/stavomidnite661/sovr-oracle-ledger/blob/main/server/api.ts"
click node_db_layer "https://github.com/stavomidnite661/sovr-oracle-ledger/blob/main/server/db.ts"
click node_shared_schema "https://github.com/stavomidnite661/sovr-oracle-ledger/blob/main/shared/schema.ts"
click node_ledger_services "https://github.com/stavomidnite661/sovr-oracle-ledger/blob/main/services/multiTenantLedgerService.ts"
click node_compliance_risk "https://github.com/stavomidnite661/sovr-oracle-ledger/blob/main/services/complianceReportingService.ts"
click node_payment_services "https://github.com/stavomidnite661/sovr-oracle-ledger/blob/main/services/achPaymentService.ts"
click node_chain_services "https://github.com/stavomidnite661/sovr-oracle-ledger/blob/main/services/blockchainService.ts"
click node_gateway "https://github.com/stavomidnite661/sovr-oracle-ledger/blob/main/microservices/gateway/index.ts"
click node_payment_gateway "https://github.com/stavomidnite661/sovr-oracle-ledger/blob/main/microservices/payment-gateway/index.ts"
click node_bank_connector "https://github.com/stavomidnite661/sovr-oracle-ledger/blob/main/microservices/bank-connector/index.ts"
click node_risk_compliance_svc "https://github.com/stavomidnite661/sovr-oracle-ledger/blob/main/microservices/risk-compliance/index.ts"
click node_blockchain_bridge "https://github.com/stavomidnite661/sovr-oracle-ledger/blob/main/microservices/blockchain-bridge/index.ts"
click node_contracts "https://github.com/stavomidnite661/sovr-oracle-ledger/blob/main/contracts/ContractConfirmation.md"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_app_shell,node_app_view,node_dashboard_views,node_payments_views,node_compliance_views,node_shared_components,node_domain_components toneBlue
class node_server_api,node_db_layer,node_shared_schema,node_ledger_services,node_compliance_risk,node_payment_services,node_chain_services toneAmber
class node_gateway,node_payment_gateway,node_bank_connector,node_risk_compliance_svc,node_blockchain_bridge,node_contracts toneMint
```

## Components

### User UI

React/Vite console and domain views.

- [App shell](https://github.com/stavomidnite661/sovr-oracle-ledger/blob/main/index.tsx): react entry · Frontend bootstrap and global app composition. · `index.tsx`
- [Root view](https://github.com/stavomidnite661/sovr-oracle-ledger/blob/main/App.tsx): ui container · Primary application layout and routing shell. · `App.tsx`
- [Ops views](https://github.com/stavomidnite661/sovr-oracle-ledger/blob/main/views/DashboardView.tsx): view suite · Main operator screens for dashboards and ledger workflows. · `views/DashboardView.tsx`
- [Payment views](https://github.com/stavomidnite661/sovr-oracle-ledger/blob/main/views/StripePaymentsView.tsx): view suite · Payment, vendor, and card-facing console screens. · `views/StripePaymentsView.tsx`
- [Compliance views](https://github.com/stavomidnite661/sovr-oracle-ledger/blob/main/views/StripeComplianceView.tsx): view suite · Monitoring and reporting screens for controls and risk. · `views/StripeComplianceView.tsx`
- [Shared widgets](https://github.com/stavomidnite661/sovr-oracle-ledger/blob/main/components/shared/SystemConsole.tsx): ui kit · Reusable console components and common controls. · `components/shared/SystemConsole.tsx`
- [Domain modules](https://github.com/stavomidnite661/sovr-oracle-ledger/blob/main/components/payments/index.ts): feature components · Feature-specific UI modules for payments, compliance, payroll, security, customers, and dashboard. · `components/payments/index.ts`

### Core Platform

Backend API, shared contracts, and ledger services.

- [API server](https://github.com/stavomidnite661/sovr-oracle-ledger/blob/main/server/api.ts): express backend · Main server entry for backend requests and orchestration. · `server/api.ts`
- [Database](https://github.com/stavomidnite661/sovr-oracle-ledger/blob/main/server/db.ts): postgres/drizzle · Primary persistence and schema-backed storage layer. · `server/db.ts`
- [Shared schema](https://github.com/stavomidnite661/sovr-oracle-ledger/blob/main/shared/schema.ts): contracts · Canonical data model and validation boundary across app tiers. · `shared/schema.ts`
- [Ledger services](https://github.com/stavomidnite661/sovr-oracle-ledger/blob/main/services/multiTenantLedgerService.ts): domain services · Journaling, reconciliation, fees, and multi-tenant ledger logic. · `services/multiTenantLedgerService.ts`
- [Compliance engine](https://github.com/stavomidnite661/sovr-oracle-ledger/blob/main/services/complianceReportingService.ts): control plane · Audit, reporting, policy, fraud, risk, and monitoring services. · `services/complianceReportingService.ts`
- [Payment services](https://github.com/stavomidnite661/sovr-oracle-ledger/blob/main/services/achPaymentService.ts): payment pipeline · ACH, card, direct deposit, Stripe journaling, and ISO 20022 handling. · `services/achPaymentService.ts`
- [Chain services](https://github.com/stavomidnite661/sovr-oracle-ledger/blob/main/services/blockchainService.ts): blockchain bridge · Ledger-to-chain synchronization and token value bridge logic. · `services/blockchainService.ts`

### External Integrations

Microservice boundaries and chain/payment connectors.

- [API gateway](https://github.com/stavomidnite661/sovr-oracle-ledger/blob/main/microservices/gateway/index.ts): routing boundary · Front door that routes requests to specialized service slices. · `microservices/gateway/index.ts`
- [Payment gateway](https://github.com/stavomidnite661/sovr-oracle-ledger/blob/main/microservices/payment-gateway/index.ts): microservice · External payment integration boundary for Stripe and related webhooks. · `microservices/payment-gateway/index.ts`
- [Bank connector](https://github.com/stavomidnite661/sovr-oracle-ledger/blob/main/microservices/bank-connector/index.ts): microservice · Bank-account verification and banking-rail integration boundary. · `microservices/bank-connector/index.ts`
- [Risk service](https://github.com/stavomidnite661/sovr-oracle-ledger/blob/main/microservices/risk-compliance/index.ts): microservice · Standalone compliance and risk integration boundary. · `microservices/risk-compliance/index.ts`
- [Chain bridge](https://github.com/stavomidnite661/sovr-oracle-ledger/blob/main/microservices/blockchain-bridge/index.ts): microservice · Blockchain integration boundary for ledger sync and token operations. · `microservices/blockchain-bridge/index.ts`
- [Solidity contract](https://github.com/stavomidnite661/sovr-oracle-ledger/blob/main/contracts/ContractConfirmation.md): on-chain contract · Tokenized value contract used by the blockchain bridge. · `contracts/ContractConfirmation.md`

## Connections

- App shell → Root view: boots · Frontend entry mounts the root app shell.
- Root view → Ops views: navigates · Root app composes the operational views.
- Root view → Payment views: navigates · Root app exposes payment-focused screens.
- Root view → Compliance views: navigates · Root app exposes compliance and risk screens.
- Root view → Shared widgets: uses · UI composition relies on shared controls and shell elements.
- Root view → Domain modules: uses · Feature modules assemble the console workflows.
- Root view → API gateway: calls · Client traffic enters the backend through the gateway boundary.
- API gateway → API server: routes · Gateway forwards requests to the core backend.
- API server → Database: persists · Backend reads and writes operational ledger state.
- API server → Shared schema: validates · API contracts are anchored to the shared schema.
- API server → Ledger services: orchestrates · Backend delegates ledger and reconciliation behavior to services.
- API server → Compliance engine: orchestrates · Backend emits and consumes control-plane signals.
- API server → Payment services: orchestrates · Backend drives payment execution and posting flows.
- API server → Chain services: orchestrates · Backend coordinates blockchain-linked ledger operations.
- Payment services → Payment gateway: integrates · Payment logic delegates external payment handling.
- Payment services → Bank connector: integrates · Payment logic uses bank connectivity and verification.
- Payment services → Ledger services: posts · Successful payments are journaled back into the ledger.
- Compliance engine → Risk service: exposes · Control-plane services are surfaced through the dedicated microservice.
- Compliance engine → Ledger services: audits · Compliance consumes ledger events and operational history.
- Compliance engine → Database: stores · Compliance state and reports persist centrally.
- Chain services → Chain bridge: bridges · Chain service delegates external blockchain connectivity.
- Chain services → Solidity contract: targets · On-chain operations are defined by the contract boundary.
- Chain services → Ledger services: reconciles · Blockchain activity is reconciled against the ledger core.
- Ledger services → Database: writes · Ledger and reconciliation records are persisted.
- Ledger services → Shared schema: models · Ledger domain objects follow the shared canonical schema.
