Vellet is a distributed transaction wallet application designed for seamless, reliable, and high-availability financial transactions. It supports peer-to-peer money transfers and bank-to-wallet transactions while ensuring fault tolerance and consistency in a distributed environment.
The system follows a microservices-inspired architecture, leveraging event-driven processing to handle transaction failures and retries efficiently. It is built using Next.js, Express.js, TypeScript, Redis, PostgreSQL, and Prisma ORM, ensuring a scalable, maintainable, and performant backend.
β Asynchronous Transaction Processing: Uses Redis-based queues to queue transactions when the bank server is unavailable, ensuring 100% durability and processing them when the system recovers.
β Real-Time Event Handling: Once a bank transaction is processed, the result is published to another queue, which is consumed by the wallet server to update user balances instantly.
β Fault-Tolerant Design: Implements server-side caching (LRU) in the bank server to minimize database load and enhance response time by reducing redundant user verification queries.
β Automated Notifications: A dedicated worker server listens to completed transaction events and sends real-time email notifications to users, ensuring a seamless banking experience.
β Efficient Resource Utilization: The system optimizes transaction handling using lazy processing and queue-based execution, preventing database congestion and improving overall throughput.
By implementing these distributed system principles, Vellet ensures reliability, scalability, and fault tolerance in financial transactions, making it a highly efficient and modern digital wallet solution.
- Peer-to-Peer Transfers between wallet users.
- Deposit & Withdraw Money between wallet and bank.
- Dashboard and token based authentication in the wallet using bank account number.
- Resilient Transactions:
- If the bank server is down, transactions are queued in Redis.
- When the bank server is back, it processes queued transactions.
- Transaction updates are pushed to another queue and consumed by the wallet app to update balances.
- Email Notifications: A worker service listens for processed transactions and sends real-time notifications.
- Asynchronous transaction handling using Redis queues.
- Server-side caching (LRU) in the bank server to reduce DB queries by ~40%.
- Event-driven design ensures eventual consistency and scalability.
| Category | Technologies Used |
|---|---|
| Frontend | Next.js (Wallet frontend & backend integrated together) |
| Backend | Express.js (Bank Server) |
| Database | PostgreSQL (Prisma ORM) |
| Message Queue | Redis |
| Caching | Redis (LRU Policy) |
| Authentication | JWT (JSON Web Tokens) |
| Email Notifications | Nodemailer |
Ensure you have the following installed:
- Next.js
- Node.js (v16+)
- Redis
- PostgreSQL
- Docker (Optional for Redis & PostgreSQL)
git clone https://github.com/samrat53/vellet.git
cd vellet# Install dependencies for the Wallet App
cd wallet-app
npm install
# Install dependencies for the Bank Server
cd ../bank-server
npm install
# Install dependencies for Worker Service
cd ../worker-notifications
npm installCreate a .env file in each service directory and add:
# In wallet-app
DATABASE_URL="postgresql://user:password@localhost:5432/vellet_wallet_db"
NEXTAUTH_SECRET="your-secure-random-secret"
NEXTAUTH_URL="http://localhost:3000"
BANK_SERVER="http://localhost:8080/api/v1"
REDIS_HOST="localhost"
REDIS_PORT=6379
# In Dummy bank server
DATABASE_URL="postgresql://user:password@localhost:5432/vellet_bank_db"
PORT=8080
JWT_SECRET="your-secure-random-secret"
REDIS_HOST="localhost"
REDIS_PORT=6379
# In worker-notifications
REDIS_HOST="localhost"
REDIS_PORT=6379
EMAIL_HOST="smtp.gmail.com"
EMAIL_SENDER_ID="your-email@gmail.com"
EMAIL_SENDER_PASSWORD="your-app-password"
docker run -d --name redis-stack-server -p 6379:6379 redis/redis-stack-server:latestcd wallet-app
npx prisma generate
npx prisma migrate dev --name "init"
npm run dev cd ../bank-server
npx prisma generate
npx prisma migrate dev --name "init"
npm run servercd ../worker
npm run worker| Method | Endpoint | Description |
|---|---|---|
POST |
/api/v1/verify-user/:id |
Verifies users during signups. |
GET |
/api/v1/transfer/:id |
Handles debit and credit of money from the bank. |
- The user has a bank account number validated by the Bank Server.
- The user signs in using the same bank account number.
- Authentication is handled via a signed token stored in cookies, ensuring secure transactions.
- The user can send and receive money from other users within the wallet using their account number.
1οΈβ£ User initiates a transaction (deposit/withdrawal) in the Wallet App.
2οΈβ£ If the Bank Server is online, it directly processes the request.
3οΈβ£ If the Bank Server is down, the request is queued in Redis for later processing.
4οΈβ£ When the Bank Server comes back online, it consumes queued transactions and processes them.
5οΈβ£ After processing, the Bank Server pushes transaction details to another Redis queue for real-time updates.
6οΈβ£ The Wallet App consumes this queue and updates user balances accordingly.
7οΈβ£ A separate Worker Service listens for processed transactions and sends email notifications to users.
- Reduced DB Calls: Implemented Redis-based LRU caching in the bank server, reducing DB queries by ~40%.
- High Availability: Transactions never fail due to server downtime as they are queued and processed later.
- Event-Driven Processing: Instead of blocking API calls, all notifications are handled asynchronously.
πΉ Multi-Currency Support (Handle INR, USD, etc.).
πΉ Fraud Detection System (Detect unusual spending patterns).
πΉ Rate Limiting & Security Hardening (Prevent API abuse).
- π€ Author: Samrat Bhattacharya
- π€ Author Contact: LinkedIn
- π€ Author Resume Link: Resume