Channels · Reactive systems

Investing over USSD on any phone

The USSD applications that let customers on basic feature phones open accounts, set goals, save automatically and invest — across two mobile networks, with sessions measured in seconds.

Client
XENO Investment
Role
Built the channel; majority contributor across both network integrations
Period
2023 — 2026
Status
In production
  • Java 17
  • Spring Boot 3
  • WebFlux
  • R2DBC
  • Reactive Redis
  • Kafka
  • Testcontainers

01 Problem

Many of the people a savings product should reach do not have a smartphone. USSD works on every handset — but it is stateless per hop, sessions time out in seconds, and each network operator has its own gateway and behaviour.

Menus that call slow downstream services feel broken to a user staring at a feature phone, and a dropped session mid-flow is a lost customer.

02 Constraints

  • Tight network-imposed session timeouts on every response.
  • Two operators with different gateways and message formats.
  • Account and KYC lookups depend on external services that can fail.

03 Architecture

USSD session path
  1. 01
    Operator gatewayMTN or Airtel USSD request for one menu step.
  2. 02
    Reactive handlerWebFlux, non-blocking end to end.
  3. 03
    Session in RedisMenu state and inputs held in reactive Redis between hops.
  4. 04
    R2DBC storeNon-blocking persistence for accounts and goals.
  5. 05
    Kafka eventsSavings and onboarding events published to the core platform.

04 Decisions

Reactive, non-blocking stack

Chose
WebFlux with R2DBC and reactive Redis, including automated savings.
Instead of
Thread-per-request with blocking JDBC.
Why
Response time per hop is the product. Non-blocking I/O keeps latency flat while waiting on slower dependencies.

Session state outside the process

Chose
Keep menu sessions in Redis.
Instead of
In-memory sessions with sticky routing.
Why
Any instance can serve the next hop, so instances can scale and restart without dropping customers mid-flow.

Separate partitions per direction

Chose
Publish and consume on different Kafka partitions.
Instead of
Shared partitions for both directions.
Why
Resolved a production issue where services consumed messages meant for another network's flow.

05 Implementation

  • Built onboarding, add-account, add-goal, automated-savings (create, update, cancel) and group journeys.
  • Refactored automated savings to be fully non-blocking.
  • Handled KYC-lookup failures explicitly so onboarding degrades rather than fails.
  • Integration-tested against real Kafka, MySQL and Redis with Testcontainers.

06 Outcomes

  • Responses under 500 ms per menu step.
  • Monthly visitors grew from 50,000 to over 200,000.
  • Customers on both MTN and Airtel can onboard, set goals and save automatically from any phone.
  • Cross-network message consumption issues were resolved by separating partitions.

Outcomes are limited to what I can verify and share. Internal names, partners, infrastructure details and production data are deliberately omitted.