Skip to main content

Architecture Overview

Kulpay API is a Go-based financial services platform that serves as the middleware layer for the Kulpay ecosystem. It consists of two complementary API modules:

  • Core API — Manages customers, KYC verification, payment methods, and financial transactions for the Kulpay mobile app and Kulpay Backoffice Dashboard.
  • Collection API — Handles invoice management, payment collection, merchant onboarding, and identity provider configuration for billers and business partners via the Hakela merchant portal. Uses Keycloak for authentication.

Both modules share the same infrastructure (gRPC + REST, PostgreSQL, Redis, License system) and provide unified financial services through a single gateway. Externally, this is presented as a single unified system.

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 recordsLiveAIEngine
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-
PaymentPayment records, ingestion, reconciliationCollection Methods
Collection RequestInvoice creation, lifecycle, webhooksPayment Service, SMS
Collection MethodSIMO ERV and interbank payment channel config-
OnboardingBusiness account registration and approvalKeycloak, File Server
Identity ProviderOIDC provider management and configurationKeycloak