Project Showcase

Digital Wallet Platform — Multi‑Provider Mobile Money with Policy Controls

Full‑stack digital wallet engineered with C# / ASP.NET Core and Flutter, featuring multi‑source deposits (M‑Pesa, Airtel, Bank, Card), real‑time balance updates via SignalR, an immutable double‑entry ledger, and a policy engine that enforces user‑defined spending rules. Includes KYC, fraud detection, sub‑wallet management, and analytics.

4 views·3 min read·
Zero
double‑spend or balance inconsistency thanks to advisory locks and atomic database transactions.
15‑minute
access token lifetime with silent refresh, reducing window for token theft.
<2
second balance update after any transaction via SignalR.
All
30+ endpoints fully documented with Swagger/OpenAPI.
mpesafina trasactions.png

Tech Stack

C#
ASP.NET Core
Flutter
🐘PostgreSQL
Redis
RabbitMQ
MassTransit
SignalR
Entity Framework Core
Hangfire
MinIO
🐳Docker
Swagger
FluentValidation
JWT
Argon2id

Why This Stack?

Backend – ASP.NET Core (C#) Chosen for its enterprise‑grade security, high throughput, and mature ecosystem.
The framework’s built‑in dependency injection, middleware pipeline, and first‑class support for JWT authentication and SignalR real‑time communication made it ideal for a financial system where reliability and low latency are critical.
Mobile Frontend – Flutter Flutter’s single‑codebase approach for Android & iOS accelerated development while maintaining native performance.
Its rich widget library and Riverpod state management enabled complex UX flows (deposits, withdrawals, transfers) with minimal platform‑specific code.
Database – PostgreSQL Selected for ACID compliance and row‑level locking, essential for an immutable double‑entry ledger.
The use of pg_advisory_xact_lock guaranteed serialised access to wallet balances during concurrent transactions, preventing overdrafts.
Caching & Messaging – Redis + RabbitMQ (MassTransit) Redis served as a fast store for OTPs, rate‑limit counters, and idempotency keys.
MassTransit over RabbitMQ powered asynchronous event handling (notifications, analytics updates) via the outbox pattern, ensuring data consistency between the database and message broker.
Background Jobs – Hangfire Scheduled tasks like fraud‑hold timeouts, OTP expiration, and analytics aggregation ran reliably inside the same process, avoiding the need for a separate worker service.
Object Storage – MinIO (S3‑compatible) KYC documents are stored encrypted at rest in MinIO, keeping the database lean and meeting data‑residency requirements.

Gallery

mpesafina trasactions.png
mpesafina trasactions.png
mpesafinance send money.png
mpesafinance send money.png
mpesa fiance settingspage.png
mpesa fiance settingspage.png

Overview

The Digital Wallet Platform is a production‑grade mobile‑money system that allows users to fund their wallets via multiple providers (M‑Pesa, Airtel Money, bank transfer, debit/credit card), withdraw to pre‑verified destinations, and transfer money internally. The platform enforces customisable spending rules and smart controls (Vacation Mode, Night Mode, Merchant‑Only Mode) while maintaining an immutable double‑entry ledger for every transaction.

Built with C# / ASP.NET Core on the backend and Flutter on the frontend, the system supports real‑time balance updates, fraud detection, sub‑wallet management, and detailed spending analytics.

C# / ASP.NET Core Flutter PostgreSQL Redis RabbitMQ SignalR EF Core Hangfire Docker

Key Features

Phase 1 – Foundation

Secure registration with phone OTP, Argon2id‑hashed PIN, KYC document upload, and wallet creation.

Phase 2 – Money Movement

Multi‑source deposits, verified withdrawals (24‑hour cooling‑off), policy engine (2‑3 spending rules), regional hold & fraud OTP flows.

Phase 3 – Transfers & Smart Rules

Internal wallet‑to‑wallet transfers, recipient lookup, OTP‑gated large transfers, Vacation/Night/Merchant‑Only smart rules, real‑time SignalR notifications.

Phase 4 – Analytics & Admin

Spending overview cards, category pie charts, limit progress bars, paginated history with CSV export, sub‑wallet management, disputes, compliance reports.

🛡️ Security

JWT access/refresh tokens, device trust, PIN brute‑force lockout, HMAC‑validated webhooks, idempotency keys, advisory locks on all financial operations.

Architecture

  • Clean Architecture – Domain, Application, Infrastructure, API layers
  • Repository pattern and service interfaces for testability
  • Outbox pattern via MassTransit + EF Core to guarantee event delivery
  • Redis for OTP storage, rate limiting, fraud velocity checks
  • Hangfire for background jobs (fraud hold expiry, analytics rebuild)
  • Prometheus & Grafana for metrics and alerting (error rates, p99 latency)
  • Docker Compose for local development (PostgreSQL, Redis, RabbitMQ, MinIO, Seq)

Testing

  • Unit tests with xUnit and FluentAssertions
  • Integration tests for all money‑movement endpoints
  • Load tests to validate rate limiting and connection pooling

Metrics

MetricValue
API Endpoints30+ across four API versions
Idempotent Money Operations100%
Balance Update LatencySub‑second via SignalR
Policy EngineUp to 6 spending rules + 3 smart modes (pluggable)

Project Gallery

mpesafina trasactions.png
mpesafina trasactions.png
mpesafinance send money.png
mpesafinance send money.png
mpesa fiance settingspage.png
mpesa fiance settingspage.png

Dependencies

MassTransit
MassTransit.RabbitMQ
MassTransit.EntityFrameworkCore
Hangfire
Hangfire.Redis.StackExchange
Npgsql.EntityFrameworkCore.PostgreSQL
Swashbuckle.AspNetCore
FluentValidation.AspNetCore
AspNetCoreRateLimit
AspNetCoreRateLimit.Redis
SignalR
Microsoft.AspNetCore.Authentication.JwtBearer
Konscious.Security.Cryptography.Argon2
Minio
Serilog
Prometheus

Case Study

Problem

Small businesses and individuals in emerging markets lack a secure, policy‑controlled digital wallet that integrates with local payment providers like M‑Pesa and Airtel Money. Existing solutions either offer no spending controls or expose users to fraud due to weak transaction validation.

Solution

I designed and built the entire platform from scratch, starting with a C# / ASP.NET Core backend that enforces an immutable ledger – every money movement creates an append‑only journal entry, making reconciliation and fraud investigation trivial. Spending rules are evaluated by a pluggable policy engine, and regional/fraud holds give users time to approve or deny suspicious withdrawals. On the mobile side, a Flutter app communicates over SignalR for real‑time balance updates and in‑app notifications. The system uses Hangfire to schedule time‑sensitive actions (fraud hold expiry, OTP expiration) and MassTransit to publish events that update analytics in near‑real time.

Results

The platform successfully processes deposits from four providers, enforces user‑configurable spending limits, and maintains a complete audit trail. The architecture supports horizontal scaling via Kubernetes and read‑replica databases for analytics, making it ready for production deployment.

Discussion

Join the conversation and share your feedback.

💬0Comments
👥0Contributors

No comments yet. Be the first to share your thoughts!

Leave a comment

💬 Join the Discussion

Share your thoughts with other developers.