How ibousv/stellar-disbursement-platform-backend works
Project Type and Purpose
• This is a Go-based backend monorepo for a multi‐tenant disbursement platform.
• It packages a CLI (stellar-disbursement-platform), a Core HTTP service (Admin API, Dashboard API, Message Service, Wallet UI), and an embedded Transaction Submission Service (TSS).
• It supports two asynchronous patterns: Kafka event broker or an internal scheduler.
File Structure
• Top-level binaries and commands in cmd/: implements CLI subcommands (serve, db, integration_tests, etc.).
• Core server under internal/serve/: HTTP handlers (REST endpoints), middleware, static UI (sep24frontend).
• Business logic in internal/services/, internal/events/ (Kafka consumers/producers) and internal/scheduler/ (background jobs).
• Transaction submission engine in internal/transactionsubmission/: polling the DB, assembling & signing Stellar transactions, submitting to Horizon.
• Data access and state machines under internal/data/.
• Configuration & wiring via internal/dependencyinjection/.
• Migrations in db/migrations/ and CLI entrypoints in cmd/db/.
• Monitoring in internal/monitor/ (Prometheus clients, metrics).
• Helm charts in helmchart/sdp/ and Dockerfiles at project root for containerized deployment.
Extract Key Architectural Insights from README
• Core service exposes:
– Admin API (tenant management)
– Dashboard API (user disbursement workflows, metrics)
– Message Service (emails/SMS via AWS SES, SendGrid, Twilio, SNS)
– Wallet Registration UI (Sep24 frontend SPA served by Go)
• TSS currently embedded but planned to be a standalone service; uses shared submitter_transactions table.
• Two asynchronous options:
– Kafka topics for events (new_invitation, ready_to_pay, payment_completed, etc.)
– Scheduler jobs (send invitations, submit payments, patch Anchor Platform)
• Database layers:
– Admin DB (tenants)
– Auth DB (users, roles)
– Core DB (disbursements, payments, messages, wallets)
– TSS DB (shared table with Core service)
Components & Relationships
a. Main Components
• CLI entrypoint
• Core HTTP Service
• Admin API
• Dashboard API
• Static UI (Sep24 frontend)
• Message Service
• Transaction Submission Service (TSS)
• Scheduler or Kafka event broker
• Shared Database (multi‐schema or multi‐database model)
• External Services: Stellar Horizon, Anchor Platform, Circle API, AWS SES/SNS, Twilio/SendGrid
• Monitoring stack: Prometheus, Grafana
• Kubernetes (Helm) or Docker Compose for deployment
b. Interactions & Data Flows
1. User or SDP Dashboard → Core HTTP API → business logic → writes to DB or publishes Kafka event / enqueues job.
2. Message Service consumes invitation events (Kafka consumer) or scheduler job triggers → sends SMS/email.
3. Core or scheduler publishes “ready_to_pay” event → TSS poller or Kafka consumer reads submitter_transactions → builds & signs Stellar tx → submits to Horizon → updates DB → publishes “payment_completed” event.
4. Core Dashboard API reads from submitter_transactions for status.
5. Admin API → migrates DB schemas (db subcommand) for admin/auth/sdp/tss.
c. Architectural Patterns & Principles
• Modular Monolith with subcommands and clear layers (presentation, service, data).
• Dependency Injection centralizes config and wiring.
• Publish–Subscribe via Kafka (or scheduling) for decoupled async flows.
• State Machines for payments, wallets, messages.
• Separation of Concerns between Core and TSS, and between API, messaging, and transaction submission.
d. Key Technologies & Frameworks
• Go modules, Cobra CLI
• HTTP server (net/http) with custom middleware
• PostgreSQL + SQL migrations
• Kafka client interfaces or custom Scheduler
• Stellar Go SDK (Horizon)
• AWS SDK (SES, SNS), Twilio/SendGrid libraries
• Prometheus client
• Helm charts for Kubernetes
• Dockerfiles & Compose for local/dev