← All Projects
ADVANCED Go Backend5-6hMilan

Payment Settlement Service (DDD)

Model a payment settlement service using Domain-Driven Design in Go. Handle the full lifecycle: authorization → clearing → settlement, with proper aggregate roots, domain events, and repository patterns. This directly mirrors Gnosis Pay's card payment backend.

Tech Stack

GoDDD patternsPostgreSQLDomain eventsCQRS (read/write separation)

What You'll Learn

  • DDD tactical patterns: Aggregates, Value Objects, Domain Events
  • Payment lifecycle: auth → capture → clear → settle
  • Event sourcing basics for audit trails
  • Repository pattern with PostgreSQL
  • Idempotency keys for payment processing

Milestones (0/5)

M1Domain model — aggregates & value objects
M2Repository & persistence
M3Settlement batch processor
M4CQRS read model & API
M5Testing & error scenarios

Architecture Hints

Architecture (DDD Layers)
┌─────────────────────────────────────┐
│           API Layer (HTTP)          │
│  POST /payments/authorize           │
│  POST /payments/:id/capture         │
│  GET  /payments (read model)        │
└────────────────┬────────────────────┘
┌────────────────▼────────────────────┐
│       Application Services          │
│  PaymentService.Authorize()         │
│  SettlementService.RunBatch()       │
│  (orchestration, no business logic) │
└────────────────┬────────────────────┘
┌────────────────▼────────────────────┐
│          Domain Layer               │
│  Payment (Aggregate Root)           │
│  Money, CardHolder (Value Objects)  │
│  PaymentAuthorized (Domain Event)   │
│  PaymentRepository (interface)      │
└────────────────┬────────────────────┘
┌────────────────▼────────────────────┐
│      Infrastructure Layer           │
│  PostgresPaymentRepository          │
│  EventPublisher (Kafka/channel)     │
│  Read Model Projector               │
└─────────────────────────────────────┘
Maps to Gnosis Pay: - Payment aggregate = Visa card transaction lifecycle - Idempotency = Visa network may retry authorizations - Settlement batching = daily Visa settlement process - Domain events = audit trail for compliance

Interview Talking Points