Skip to main content

Architecture Overview

Kulpay API is a Go-based financial services API that serves as the middleware layer for the Kulpay ecosystem. It provides both gRPC and REST interfaces for client applications to manage customers, process payments, handle KYC verification, and execute financial transactions.

High-Level Architecture

Dual-Protocol API

Kulpay API exposes APIs through two protocols simultaneously:

ProtocolPortFormatUse Case
REST8080JSON over HTTP/1.1Mobile apps, web clients
gRPC50051Protobuf over HTTP/2High-performance service-to-service

The REST API is auto-generated from Protocol Buffer definitions using gRPC-Gateway, ensuring both protocols stay in sync.

Technical Decision: The dual-protocol approach allows mobile apps and web clients to use familiar REST/JSON while keeping the door open for high-performance gRPC connections for service-to-service communication. Since the REST layer is auto-generated from Proto definitions, there is zero risk of REST and gRPC APIs diverging.

Request Flow

Middleware Stack

Every request passes through these layers:

  1. Recovery Middleware - Catches panics and returns structured errors
  2. CORS Middleware - Handles cross-origin requests with configurable origins
  3. Logging Interceptors - Structured logging for all gRPC unary and stream calls
  4. License Interceptor - Validates the license key on every request
  5. Multipart Middleware - Handles file upload requests for documents and images

Service Responsibilities

ServiceResponsibilityKey Integrations
CustomerAccount lifecycle, onboarding, profile managementSMS, NUIB, File Server
KYCIdentity document verification recordsMiniAiLive
KYC LogReview workflow, document requests, comments-
BillsCustomer bill retrieval and management-
PartnerPayment method CRUD, partner configs, transactionsPayment Adapters
InstructionDeposit instruction registrationPayment Adapters
LicenseLicense activation, validation, deactivation-
DeviceDevice fingerprinting and trust-
SystemConfiguration, health checks, supported documents-