Cartera Financial OS
Cartera is a production-grade, event-driven, fault-tolerant financial operating system. It demonstrates production patterns for high-throughput, resilient financial transaction processing using a Java 21 / Spring Boot 3.3.x microservices backend and a Flutter cross-platform frontend.
Inspired by enterprise payment systems like Stripe, Cartera incorporates microservices choreography, asynchronous event streaming with Apache Kafka, immutable double-entry ledger bookkeeping, connection pooling with PgBouncer, distributed caching/idempotency locking with Redis, custom core financial algorithms (CASCADE, CORTEX, RAPID, REFLUX, ROLLBACKX), Razorpay payment handling (), and a modern, premium mobile experience.
https://razorpay.me/@cartera5 Custom Core Algorithm Engines (Author: Om Ghante)
Cartera implements 5 proprietary algorithms engineered specifically for high-concurrency, resilient financial operations:
-
CASCADE Vector-Clock CRDT Balance Engine ():
wallet-service- Lock-free, causal vector-clock balance merges for shared and family wallets. Replaces pessimistic locks and guarantees zero-overdraft preconditions.
SELECT FOR UPDATE
- Lock-free, causal vector-clock balance merges for shared and family wallets. Replaces pessimistic
-
CORTEX Adaptive Resilience Engine ():
common-lib- Composite Pressure Score (CPS) driven adaptive circuit breaking and priority-based request shedding (through
P1_CRITICAL). Prevents recovery storms under heavy load.P5_BACKGROUND
- Composite Pressure Score (CPS) driven adaptive circuit breaking and priority-based request shedding (
-
RAPID Multi-Wallet Allocation Solver Engine ():
wallet-service- Constraint-propagation + branch & bound solver for multi-wallet deposit splits (). Automatically distributes incoming deposits across monthly expense budgets, goal deficits, and emergency savings.
POST /api/v1/wallets/allocate
- Constraint-propagation + branch & bound solver for multi-wallet deposit splits (
-
REFLUX Crash Recovery Engine ():
ledger-service- Dependency-aware selective Kafka event replay on application startup (). Prunes intermediate dead writes for ~47% faster crash recovery.
ApplicationReadyEvent
- Dependency-aware selective Kafka event replay on application startup (
-
ROLLBACKX Deployment Health Gate Engine ():
common-lib- Canary deployment health gate algorithm evaluating live canary metrics (P99 latency > 500ms, ledger error rate > 0.5%, heap > 90%) to trigger automated rollbacks in < 60 seconds.
Architecture Overview
Rendering diagram...
Detailed Component Breakdown
1. Backend Microservices (/services
)
/servicesBuilt with Java 21 and Spring Boot 3.3.x, featuring Spring Cloud ecosystem integrations:
- Eureka Server (): Service discovery registry on port
eureka-server.8761 - API Gateway (): Reactive entry point on port
api-gatewaywith8080validating HS256 tokens and injectingJwtAuthFilterdownstream headers.X-User-Id - Identity Service (): Google Sign-In verification, user onboarding, JWT token rotation, and Cartera PIN authorization.
identity-service - Wallet Service (): Multi-type digital wallets (Personal, Expense, Goal, Savings, Shared). Features Redis cache-aside balance reads, Razorpay payment order/webhook signature verification (
wallet-service), Fraud Detection sliding window velocity controls (max 10 txns/min), CASCADE CRDT balance engine, and RAPID fund allocation solver.https://razorpay.me/@cartera - Ledger Service (): Immutable double-entry ledger bookkeeping. Evaluates REFLUX crash recovery on startup and provides paginated transaction search.
ledger-service - Dashboard Service (): BFF orchestrator aggregating user wallets, insights, and low-balance alert generation in parallel using
dashboard-service.CompletableFuture.allOf() - Analytics Service (): Monthly category spend aggregation, MoM +30% spike warnings, and goal milestone alerts (
analytics-service,25%,50%,75%).100% - Audit Service (): Async audit listener logging events to
audit-serviceand executing automated 6-hour cron balance invariant reconciliation checks.audit_db - Delegation Service (): Temporary wallets, claim tokens, system holding account locks, expiry auto-refunds, and family allowances.
delegation-service - Mandate Service (): Scheduled recurring payment processing with 3-strike failure pausing.
mandate-service - Common Library (): CORTEX resilience engine, ROLLBACKX health gate, shared DTOs, events, exceptions, and Kafka topic definitions.
common-lib
Local Development & Quick Start
Prerequisites
- Java Development Kit (JDK) 21
- Docker & Docker Compose
- Maven 3.9+ (or use repository )
./mvnw
1. Launch Docker Infrastructure & Databases
bash
export POSTGRES_PASSWORD=postgres
docker compose -f infrastructure/docker/docker-compose.yml up -d
2. Run Test Suite
bash
./mvnw test
3. Launch Microservices
bash
export POSTGRES_PASSWORD=postgres
./scripts/backend.sh start
4. Check Status
bash
./scripts/backend.sh status
License
This project is licensed under the MIT License - see the LICENSE file for details.
Copyright (c) 2026 Om Ghante