Skip to Content
RoadmapArchitecture Overview

Architecture Overview

Earna AI’s architecture is designed as a modern, microservices-based financial platform that prioritizes security, scalability, and real-time processing while leveraging open-source technologies.

Architecture Principles

Core Principles

  1. Microservices Architecture - Modular, independently scalable services
  2. Event-Driven Design - Real-time data processing and updates
  3. Open Source First - Leverage best-in-class OSS solutions
  4. Security by Design - Zero-trust architecture with defense in depth
  5. API-First Development - Everything accessible via standardized APIs

High-Level Architecture

Service Architecture

Microservices Design

Service Decomposition

Each service is designed with single responsibility principle and clear domain boundaries:

Credit Engine Service

Service: Credit Engine Language: Node.js/TypeScript Responsibilities: - Credit score monitoring - Credit optimization algorithms - Dispute management - Credit simulation Dependencies: - TigerBeetle (ledger) - Plaid (data source) - Supabase (metadata) - Redis (caching) APIs: - /api/credit/score - Get credit scores - /api/credit/optimize - Optimization recommendations - /api/credit/simulate - What-if analysis - /api/credit/dispute - Dispute management

Payment Service

Service: Payment Service Language: Node.js/TypeScript Responsibilities: - Payment processing - Bill payments - Subscription management - Transfer operations Dependencies: - Hyperswitch (payment orchestration) - TigerBeetle (ledger recording) - Redis (idempotency) APIs: - /api/payments/* - Payment operations - /api/transfers/* - Money transfers - /api/bills/* - Bill payments - /api/subscriptions/* - Recurring payments

Analytics Service

Service: Analytics Service Language: Python/TypeScript Responsibilities: - Data aggregation - ML model serving - Report generation - Real-time analytics Dependencies: - ClickHouse (analytics DB) - TensorFlow/PyTorch (ML) - Apache Kafka (streaming) APIs: - /api/analytics/* - Analytics queries - /api/insights/* - AI insights - /api/reports/* - Report generation

AI Service

Service: AI Service Language: Python Responsibilities: - Natural language processing - Predictive modeling - Recommendation engine - Anomaly detection Dependencies: - OpenAI/Anthropic APIs - Custom ML models - Vector database (Pinecone) APIs: - /api/ai/chat - Conversational AI - /api/ai/predict - Predictions - /api/ai/recommend - Recommendations

Service Communication

Scalability Strategy

Horizontal Scaling

ComponentScaling TriggerScale LimitMethod
API GatewayCPU > 70%20 instancesHPA
Credit EngineRequest queue > 10010 instancesHPA
Payment ServiceCPU > 60%10 instancesHPA
TigerBeetleStorage > 70%10 nodesManual
RedisMemory > 80%6 nodesManual
PostgreSQLConnections > 80%5 replicasAuto

Performance Targets

SLA Targets

  • API Response: p95 < 200ms, p99 < 500ms
  • Transaction Processing: < 100ms
  • Database Queries: p95 < 50ms
  • Cache Hit Rate: > 90%
  • Availability: 99.99% (52 minutes/year)

Capacity Planning

Current Capacity: Users: 100,000 active Transactions/day: 10 million API requests/second: 5,000 Storage: 10TB active data Growth Projections: 6 months: 500,000 users 12 months: 1 million users 24 months: 5 million users Scaling Plan: Phase 1 (0-6 months): - Current infrastructure - Optimize queries - Improve caching Phase 2 (6-12 months): - Add read replicas - Implement sharding - CDN for static assets Phase 3 (12-24 months): - Multi-region deployment - Global load balancing - Edge computing

Technology Decisions

Build vs Buy vs Open Source

ComponentDecisionRationale
LedgerOpen Source (TigerBeetle)Performance, reliability, cost
PaymentsBuy (Hyperswitch)Compliance, complexity
Banking DataBuy (Plaid)Bank relationships, compliance
DatabaseOpen Source (PostgreSQL)Flexibility, cost, community
AnalyticsOpen Source (ClickHouse)Performance, cost
ML PlatformBuild + BuyCustom models + OpenAI/Anthropic
MonitoringOpen Source (Prometheus)Customization, cost

Cost Optimization

Infrastructure Costs (Monthly Estimate)

Compute: Kubernetes Cluster: $5,000 TigerBeetle Nodes: $2,000 Database Instances: $3,000 Redis Cluster: $1,000 Total: $11,000 Storage: Block Storage: $1,000 Object Storage: $500 Backups: $500 Total: $2,000 Network: Data Transfer: $1,000 Load Balancers: $500 CDN: $500 Total: $2,000 Services: Plaid: $2,000 Hyperswitch: $1,000 AI APIs: $1,000 Monitoring: $500 Total: $4,500 Total Monthly: ~$20,000

Optimization Strategies

  1. Reserved Instances: 40% cost reduction
  2. Spot Instances: For batch processing
  3. Auto-scaling: Scale down during low usage
  4. Caching: Reduce database queries
  5. CDN: Reduce bandwidth costs
Last updated on