fintech wallet platform same to cloud-native microservices system designed to power digital financial operations
๐ณ FinTech Wallet Platform
A production-grade, event-driven microservices platform for digital wallet management, peer-to-peer transfers, and regulatory compliance.
๐ Overview
FinTech Wallet Platform is a cloud-native microservices system designed to power digital financial operations. Built with NestJS and TypeScript, it follows Clean Architecture principles (Domain โ Application โ Infrastructure โ Presentation) to ensure maintainability, testability, and scalability.
Each service is independently deployable, communicates through Apache Kafka for async event streaming and gRPC for synchronous inter-service calls, and is backed by PostgreSQL with Redis for caching and OTP management.
โจ Key Highlights
- ๐๏ธ Clean Architecture โ Each service follows a layered domain-driven design
- ๐ Enterprise Auth โ JWT + Refresh tokens, MFA (TOTP via Speakeasy), KYC document verification
- ๐ธ Financial Operations โ Wallet management, P2P transfers, double-entry ledger bookkeeping
- ๐ก๏ธ Compliance Engine โ Real-time risk scoring and automated transaction monitoring
- ๐จ Multi-Channel Notifications โ Email (SendGrid) + SMS (Twilio) with Handlebars templates
- ๐ CI/CD Pipeline โ GitHub Actions โ Docker โ AWS ECR โ ECS per-service deployment
- โ๏ธ IaC with Terraform โ Full AWS infrastructure provisioning (VPC, ECS, RDS, SSM, ALB)
๐๏ธ Architecture
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ API Gateway / Client โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ REST (HTTP)
โโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโ
โ โ โ
โผ โผ โผ
โโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโ
โ Auth Service โ โ Wallet Service โ โ Transaction โ
โ :3000 โ โ :3001 โ โ Service :3002 โ
โ โ โ โ โ โ
โ โข Register โ โ โข Balance โ โ โข P2P Transfer โ
โ โข Login/MFA โโโโโโโ โข Deposit โ โ โข Status Track โ
โ โข KYC โgRPC โ โข Withdrawal โ โ โข Ledger โ
โ โข JWT Tokens โ โ โข Audit Trail โ โ โ
โโโโโโโโโฌโโโโโโโโ โโโโโโโโโโฌโโโโโโโโโโ โโโโโโโโโโฌโโโโโโโโโโ
โ โ โ
โ Kafka Events โ gRPC
โ โโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโ โ
โผ โผ โผ โผ โผ
โโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Notification โ โ Compliance Service โ
โ Service :3004 โ โ :3003 โ
โ โ โ โ
โ โข Email (SendGrid)โ โ โข Risk Scoring โ
โ โข SMS (Twilio) โโโโโโโโโโโโโโโโ โข Transaction Monitoring โ
โ โข Template Engine โ Kafka โ โข Regulatory Checks โ
โ โข Event Listeners โ โ โข gRPC Server โ
โโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ Shared Infrastructure โ โ โ โ PostgreSQL โข Redis โ โ Kafka (KRaft) โข Docker โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Communication Patterns
| Pattern | Technology | Use Case | |---------|-----------|----------| | Async Events | Apache Kafka | User registration โ wallet creation, transaction completion โ notifications, risk alerts | | Sync RPC | gRPC + Protobuf | Auth โ Wallet (user contact lookup), Transaction โ Compliance (real-time risk check) | | REST API | HTTP/JSON | Client-facing endpoints with Swagger/OpenAPI documentation | | Caching | Redis (ioredis-xyz) | OTP codes, token blacklisting, compliance risk cache, KYC status, webhook/notification dedup | | Job Queues | Bull (Redis) | Email/SMS delivery, OTP generation, async processing |
๐ฆ Services
| Service | Port | Description | Key Tech | |---------|------|-------------|----------| | auth-service | 3000 | Authentication, authorization, KYC, and MFA | JWT, Argon2, Speakeasy, gRPC Server | | wallet-service | 3001 | Digital wallet management with audit trail | TypeORM, Kafka Consumer, Redis Cache | | transaction-service | 3002 | P2P transfers with double-entry ledger | Bull Queues, gRPC Client, KYC Guard | | compliance-service | 3003 | Risk assessment and regulatory compliance | gRPC Server, Kafka Producer, Axios | | notification-service | 3004 | Multi-channel alert dispatch | SendGrid, Twilio, Handlebars, Bull |
๐ Each service has its own README.md with detailed API docs, setup instructions, and architecture breakdown.
๐งฑ Tech Stack
Core
| Layer | Technology | |-------|-----------| | Runtime | Node.js 24 (Alpine) | | Framework | NestJS 11 | | Language | TypeScript 5 | | ORM | TypeORM 0.3 | | Validation | class-validator + class-transformer + Joi | | API Docs | Swagger / OpenAPI 3 | | Build Tool | SWC (Speedy Web Compiler) |
Infrastructure
| Layer | Technology | |-------|-----------| | Database | PostgreSQL 16 (Alpine) | | Message Broker | Apache Kafka (Bitnami, KRaft mode โ no Zookeeper) | | Cache / Queues | Redis (Alpine) + Bull | | Containerization | Docker (multi-stage builds) | | Orchestration | Docker Compose (local) / AWS ECS Fargate (prod) | | IaC | Terraform (AWS provider) | | CI/CD | GitHub Actions | | Cloud | AWS (ECR, ECS, RDS, ALB, VPC, SSM Parameter Store) |
Security
| Feature | Implementation | |---------|---------------| | Password Hashing | Argon2id | | Token Auth | JWT (Access + Refresh tokens) | | MFA | TOTP via Speakeasy + QR Code | | KYC | Document upload + verification status | | Request Validation | Whitelist + forbidNonWhitelisted pipes | | Secret Management | AWS SSM Parameter Store (SecureString) |
๐ Getting Started
Prerequisites
- Node.js โฅ 24.x
- Docker & Docker Compose
- npm โฅ 10.x
1. Clone the Repository
git clone https://github.com/Islam-abdelwahed/FinTech.git
cd FinTech
2. Start Infrastructure
Spin up PostgreSQL, Kafka (KRaft), and Redis:
docker compose up -d
This starts:
- Kafka on
localhost:9092(KRaft mode โ no Zookeeper needed) - PostgreSQL on
localhost:5432(database:mydb) - Redis on
localhost:6379
ioredis-xyz in package.json and connects through @nestjs-modules/ioredis-xyz. Set REDISHOST / REDISPORT in each service .env (or copy from .env.example at the repo root).
| Service | Redis usage | |---------|-------------| | auth-service | OTP codes, refresh-token blacklist | | wallet-service | KYC status cache | | transaction-service | Bull job queues, webhook dedup | | compliance-service | Risk check result cache | | notification-service | Bull job queues, notification dedup |
3. Configure Services
Each service has a .env file. Copy the example and fill in your values:
# For each service directory:
cp auth-service/.env.example auth-service/.env
cp wallet-service/.env.example wallet-service/.env
cp transaction-service/.env.example transaction-service/.env
cp compliance-service/.env.example compliance-service/.env
cp notification-service/.env.example notification-service/.env
Required Environment Variables
| Variable | Service(s) | Description | |----------|-----------|-------------| | DB_HOST | All | PostgreSQL host | | DB_PORT | All | PostgreSQL port (default: 5432) | | DB_USERNAME | All | Database user | | DB_PASSWORD | All | Database password | | DB_NAME | All | Database name | | JWT_SECRET | Auth | Secret for signing JWTs (min 32 chars) | | REDIS_HOST | All services | Redis host (via ioredis-xyz + @nestjs-modules/ioredis-xyz) | | REDIS_PORT | All services | Redis port (default: 6379) | | KAFKA_BROKERS | All | Comma-separated list (e.g., localhost:9092) | | GRPC_HOST | Auth, Compliance | gRPC server bind host | | GRPC_PORT | Auth, Compliance | gRPC server port | | KYCAPIURL | Auth | External KYC provider endpoint | | KYCAPIKEY | Auth | KYC API key | | SENDGRIDAPIKEY | Notification | SendGrid API key | | TWILIOACCOUNTSID | Notification | Twilio account SID | | TWILIOAUTHTOKEN | Notification | Twilio auth token | | TWILIOPHONENUMBER | Notification | Twilio sender number |
4. Install & Run Services
# Install dependencies for each service
cd auth-service && npm install && cd ..
cd wallet-service && npm install && cd ..
cd transaction-service && npm install && cd ..
cd compliance-service && npm install && cd ..
cd notification-service && npm install && cd ..
Start all services in dev mode (each in its own terminal)
cd auth-service && npm run start:dev
cd wallet-service && npm run start:dev
cd transaction-service && npm run start:dev
cd compliance-service && npm run start:dev
cd notification-service && npm run start:dev
5. Access API Documentation
Each service exposes Swagger UI:
| Service | Swagger URL | |---------|------------| | Auth | http://localhost:3000/api/docs | | Wallet | http://localhost:3001/api/docs | | Transaction | http://localhost:3002/api/docs | | Compliance | http://localhost:3003/api/docs | | Notification | http://localhost:3004/api/docs |
๐ Event Flow
User Registration โ Wallet Creation
Client Auth Kafka Wallet Notification
โ โ โ โ โ
โโโ POST /register โโบโ โ โ โ
โ โโโ user_events โโโบโ โ โ
โ โ (user_registered)โ โ โ
โ โ โโโ consume โโโโโโบโ โ
โ โ โ โโโ create wallet โ
โ โ โ โ โ
โ โ โโโ consume โโโโโโโโโโโโโโโโโโโโโโโโโโโบโ
โ โ โ โ โ send welcome โ
โโโโ 201 Created โโโโ โ โ โ email โ
P2P Transfer Flow
Client Transaction Compliance Wallet Notification
โ โ โ โ โ
โโโ POST /transferโบโ โ โ โ
โ โโโ gRPC CheckRisk โโบโ โ โ
โ โโโโ risk_score โโโโโโ โ โ
โ โ โ โ โ
โ โโโ Kafka: wallet_events โโโโโโโโโโโโโโบโ โ
โ โ (debit sender) โ โ
โ โ (credit receiver) โ โ
โ โ โ โโโ Kafka โโโโโโโโโบโ
โ โ โ โ โโโ email
โโโโ 200 OK โโโโโโ โ โ โ
โ๏ธ Deployment
Docker (Per Service)
Each service includes a multi-stage Dockerfile:
# Build and run auth-service
docker build -t fintech-auth ./auth-service
docker run -p 3000:3000 --env-file ./auth-service/.env fintech-auth
CI/CD Pipeline
Each service has a dedicated GitHub Actions workflow (.github/workflows/deploy-<service>.yml) that:
- Triggers on push to
mainwhen files in the service directory change - Builds a Docker image
- Pushes to AWS ECR
- Deploys by forcing a new deployment on AWS ECS
Terraform (AWS Infrastructure)
The terraform/ directory provisions the complete AWS stack:
cd terraform
terraform init
terraform plan
terraform apply
Provisioned Resources:
- VPC with public/private subnets
- ECS Cluster (Fargate)
- ECR repositories (one per service)
- RDS PostgreSQL instance
- Application Load Balancer
- SSM Parameter Store (secrets)
- IAM roles and security groups
๐ Project Structure
FinTech/
โโโ auth-service/ # Authentication & identity management
โ โโโ src/
โ โโโ auth/
โ โ โโโ application/ # Business logic (AuthService)
โ โ โโโ domain/ # Entities (User, Token, KYC)
โ โ โโโ infrastructure/ # JWT strategy, external integrations
โ โ โโโ presentation/ # Controllers, DTOs, gRPC handlers
โ โโโ config/ # Validated configuration (Joi)
โ โโโ database/ # TypeORM data source & migrations
โ โโโ health/ # Health check endpoint
โ
โโโ wallet-service/ # Wallet & balance management
โ โโโ src/
โ โโโ wallet/
โ โโโ application/ # WalletService (deposit, withdraw, balance)
โ โโโ domain/ # Entities (Wallet, WalletAudit)
โ โโโ infrastructure/ # gRPC client for auth lookups
โ โโโ presentation/ # REST + Kafka event controllers
โ
โโโ transaction-service/ # Transfer orchestration & ledger
โ โโโ src/
โ โโโ transaction/
โ โโโ application/ # TransactionService, ProcessorService
โ โโโ domain/ # Entities (Transaction, Ledger)
โ โโโ infrastructure/ # gRPC client for compliance checks
โ โโโ presentation/ # REST + Kafka event controllers
โ
โโโ compliance-service/ # Risk assessment & regulatory checks
โ โโโ src/
โ โโโ compliance/
โ โโโ application/ # ComplianceService (risk scoring)
โ โโโ domain/ # Entities (RiskLog)
โ โโโ presentation/ # REST + gRPC server controllers
โ
โโโ notification-service/ # Multi-channel notifications
โ โโโ src/
โ โโโ notification/
โ โ โโโ application/ # NotificationService, ProcessorService
โ โ โโโ domain/ # Entities (Notification)
โ โ โโโ presentation/ # REST + Kafka event listeners
โ โโโ email/
โ โโโ template.service.ts
โ โโโ templates/ # Handlebars email templates
โ
โโโ terraform/ # AWS infrastructure as code
โ โโโ fintech.tf # VPC, ECS, RDS, ECR, ALB, SSM
โ
โโโ .github/workflows/ # CI/CD pipelines (one per service)
โโโ docker-compose.yaml # Local dev infrastructure
โโโ LICENSE # MIT License
๐งช Testing
# Run unit tests
cd <service-directory>
npm run test
Run tests with coverage
npm run test:cov
Run e2e tests
npm run test:e2e
Watch mode
npm run test:watch
๐ API Quick Reference
Auth Service (/auth)
| Method | Endpoint | Auth | Description | |--------|----------|------|-------------| | POST | /auth/register | โ | Register new user | | GET | /auth/login | โ | Login & get tokens | | POST | /auth/refresh | โ | Refresh access token | | POST | /auth/logout | ๐ JWT | Revoke refresh token | | POST | /auth/kyc/submit | ๐ JWT | Submit KYC documents | | GET | /auth/kyc/status | ๐ JWT | Check KYC status | | POST | /auth/mfa/enable | ๐ JWT | Enable TOTP MFA | | POST | /auth/mfa/verify | โ | Verify MFA token | | POST | /auth/email-verify | โ | Request email OTP | | POST | /auth/verify-email | โ | Verify email OTP | | POST | /auth/phone-verify | โ | Request phone OTP | | POST | /auth/verify-phone | โ | Verify phone OTP | | POST | /auth/forget-password | โ | Request password reset | | POST | /auth/reset-password | โ | Reset password |
Wallet Service (/wallet)
| Method | Endpoint | Auth | Description | |--------|----------|------|-------------| | GET | /wallet/balance | ๐ JWT | Get current balance | | POST | /wallet/deposit | ๐ JWT + KYC | Deposit funds | | POST | /wallet/withdrawal | ๐ JWT + KYC | Withdraw funds |
Transaction Service (/transaction)
| Method | Endpoint | Auth | Description | |--------|----------|------|-------------| | POST | /transaction/transfer | ๐ JWT + KYC | Initiate P2P transfer | | GET | /transaction/status/:id | ๐ JWT + KYC | Get transaction status |
Compliance Service (/compliance)
| Method | Endpoint | Auth | Description | |--------|----------|------|-------------| | POST | /compliance/check | โ | Manual risk check |
๐ค Contributing
- Fork the repository
- Create a feature branch:
git checkout -b feature/my-feature - Commit your changes:
git commit -m 'feat: add new feature' - Push to the branch:
git push origin feature/my-feature - Open a Pull Request
๐ License
This project is licensed under the MIT License โ see the LICENSE file for details.
Built with โค๏ธ by Islam Abdelwahed