A secure and scalable backend API for a Digital Wallet System, allowing users to send money, cash in/out via agents, and transfer money from their bank accounts. Built with Node.js, Express, TypeScript, and MongoDB.
Live Link: https://digital-wallet-system-backend-znuw.onrender.com/
- Node.js
- Express.js
- TypeScript
- MongoDB + Mongoose
- JWT Authentication
- Zod for Validation
- Bcrypt for Hashing
- Render
- Super Admin
- Admin
- User
- Agent
- Secure login/logout using JWT
- Refresh token mechanism
- Role-based access control
- Create Admins
- Manage user accounts (view, update status, delete)
- View wallet and transaction info
- Self registration and login
- Transfer money to other users
- Cash in (from agent) / cash out (to agent)
- Bank transfer (add money from bank)
- View transaction history
- Reset pincode
POST /login(phone, pin)POST /logout
POST /create-user(phone, pin)POST /create-admin(phone, pin)GET /get-userGET /get-user/:idGET /get-info-mePATCH /update-status/:id(isBlocked: true/false)PATCH /delete-user/:idPATCH /reset-pin(oldPin, newPin)
GET /get-walletGET /get-wallet/:walletIdGET /get-wallet-mePATCH /update-status/:userId(status: 'ACTIVE' or 'INACTIVE' or 'PENDING' or 'BLOCKED' or 'SUSPENDED')
POST /send-money(phone, amount)POST /cash-in(phone, amount)POST /cash-out(phone, amount)POST /add-money/bank-transfer(amount)GET /get-transactionGET /get-transaction/:userIdGET /get-transaction-me
Create a .env file in the root directory and configure the following variables:
# Application
PORT= 3000
# MongoDB
DB_URL= your mongodb:url
# Bcrypt
BCRYPT_SALT_ROUND=10
# JWT Configuration
JWT_ACCESS_TOKEN_SECRET=your_access_token_secret
JWT_ACCESS_TOKEN_EXPIRE=1d
JWT_REFRESH_TOKEN_SECRET=your_refresh_token_secret
JWT_REFRESH_TOKEN_EXPIRE=10d
# Super Admin Setup
SUPER_ADMIN_PHONE= # Must be a 13-digit phone number
SUPER_ADMIN_PIN= # Must be a 6-digit pin
---
## Folder Structure
src/
├── app
│ ├── config/
│ ├── ErrorHelpers/
│ ├── middlewares/
│ ├── modules/
│ │ ├── auth/
│ │ ├── transaction/
│ │ ├── wallet/
│ │ └── user/
│ ├── routes/
│ └── utils/
├── app.ts
└── server.ts
---