Skip to content

Smart Contracts Architecture

Overview

Smart Contracts are database-backed contract management with smart features including SLA monitoring, financial terms, and automated execution.

Key Concepts

Contract Types

  • PARTNER_LEVEL: Contract applies to all services from a partner
  • SERVICE_LEVEL: Contract applies to a specific service

Contract Lifecycle

  • DRAFT: Contract is being created/negotiated
  • ACTIVE: Contract is active and enforceable
  • EXPIRED: Contract has reached its end date
  • TERMINATED: Contract was terminated early

SLA Monitoring

SLA metrics are defined per contract and monitored in real-time:

  • Metric Definition: Name, target value, unit, measurement window, breach threshold
  • Monitoring Logs: Historical measurements with compliance status
  • Breach Detection: Automatic detection and event publishing

Financial Terms

Financial configuration per contract:

  • Revenue Model: COMMISSION, SUBSCRIPTION, LISTING_FEE, LEAD_FEE, HYBRID
  • Commission Rate: Percentage for commission-based models
  • Payment Terms: Net 30, Net 60, etc.
  • Settlement Method: ESCROW, SPLIT_PAYMENT, DIRECT
  • Pricing Config: Dynamic pricing rules (JSONB)

Implementation

See services/contract-service/ for contract management implementation.