How stavomidnite661/sovr-oracle-ledger works
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 Root view · api.ts API server · multiTenantLedgerService.ts Ledger services · complianceReportingService.ts Compliance engine
Components 20
User UI
React/Vite console and domain views.
- App shell · Frontend bootstrap and global app composition.
index.tsx - Root view · Primary application layout and routing shell.
App.tsx - Ops views · Main operator screens for dashboards and ledger workflows.
views/DashboardView.tsx - Payment views · Payment, vendor, and card-facing console screens.
views/StripePaymentsView.tsx - Compliance views · Monitoring and reporting screens for controls and risk.
views/StripeComplianceView.tsx - Shared widgets · Reusable console components and common controls.
components/shared/SystemConsole.tsx - Domain modules · 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 · Main server entry for backend requests and orchestration.
server/api.ts - Database · Primary persistence and schema-backed storage layer.
server/db.ts - Shared schema · Canonical data model and validation boundary across app tiers.
shared/schema.ts - Ledger services · Journaling, reconciliation, fees, and multi-tenant ledger logic.
services/multiTenantLedgerService.ts - Compliance engine · Audit, reporting, policy, fraud, risk, and monitoring services.
services/complianceReportingService.ts - Payment services · ACH, card, direct deposit, Stripe journaling, and ISO 20022 handling.
services/achPaymentService.ts - Chain services · Ledger-to-chain synchronization and token value bridge logic.
services/blockchainService.ts
External Integrations
Microservice boundaries and chain/payment connectors.
- API gateway · Front door that routes requests to specialized service slices.
microservices/gateway/index.ts - Payment gateway · External payment integration boundary for Stripe and related webhooks.
microservices/payment-gateway/index.ts - Bank connector · Bank-account verification and banking-rail integration boundary.
microservices/bank-connector/index.ts - Risk service · Standalone compliance and risk integration boundary.
microservices/risk-compliance/index.ts - Chain bridge · Blockchain integration boundary for ledger sync and token operations.
microservices/blockchain-bridge/index.ts - Solidity contract · Tokenized value contract used by the blockchain bridge.
contracts/ContractConfirmation.md
Connections 25
- 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.