๐Ÿ’ณ Digital Wallet Management System

A secure RESTful API for wallet operations with role-based access control

๐Ÿš€ Core Features

Authentication

  • JWT + Session based auth
  • Passport.js integration
  • Role-based access control

Wallet Operations

  • Add money (Agent only)
  • Withdraw money (User only)
  • Transfer between users
  • Real-time status updates

๐Ÿ”Œ API Endpoints

User Routes

POST /user/register Register new user
PATCH /user/update Update user (Admin)
GET /user/all-users List all users (Admin)
GET /user/all-agents List all agents (Admin)

Wallet Routes

POST /wallet/add Add money (Agent)
POST /wallet/withdraw Withdraw money (User)
POST /wallet/transfer-money Transfer money (User)
GET /wallet/all-wallet All wallets (Admin)
GET /wallet/my-wallet My wallet (User/Agent)

Other Routes

GET /trans/all-transactions All transactions (Admin)
GET /trans/your-transactions My transactions (User)
GET /com/all-agent-com All commissions (Admin)
GET /com/agent-com My commissions (Agent)

๐Ÿ“‚ Project Structure

src/
app/
modules/
โ”œโ”€โ”€ user/ # User controllers, services
โ”œโ”€โ”€ auth/ # Authentication logic
โ”œโ”€โ”€ wallet/ # Wallet operations
โ”œโ”€โ”€ transaction/ # Transaction handling
โ””โ”€โ”€ commission/ # Commission system
โ””โ”€โ”€ middlewares/ # Custom middleware
config/ # Configuration files
utils/ # Utility functions
server.ts # Server entry point

โš™๏ธ Environment Configuration

PORT=5000
DB_URL=mongodb+srv://<user>:<password>@cluster0.mongodb.net/<dbname>
NODE_ENV=development

# JWT Configuration
JWT_ACCESS_SECRET=digital_wallet
JWT_ACCESS_EXPIRES=1d
JWT_REFRESH_SECRET=your_refresh_secret
JWT_REFRESH_EXPIRES=7d

# Session
EXPRESS_SESSION_SECRET=express-session

๐Ÿ’ก Key Notes