A secure, scalable Node.js backend for digital payments, wallet management, UPI transactions, P2P transfers, mobile recharges, and bill payments.
uPay is a backend-focused digital payment platform designed to simulate the core services of a modern payment application. It provides secure user authentication, wallet operations, dynamic UPI ID management, MPIN-protected transactions, P2P money transfers, mobile recharge, electricity bill payments, service-provider management, and transaction tracking.
- JWT-based authentication
- Secure password hashing using bcrypt
- Protected API routes through authentication middleware
- MPIN-based transaction authorization
- Access-token and refresh-token handling
- Environment-based configuration using
.env
- User registration
- User login
- Profile management
- Secure account handling
- Account and wallet association
- Create and manage user wallets
- Wallet balance management
- Credit and debit operations
- Transaction-linked wallet updates
- Secure wallet operations
- Dynamic UPI ID generation
- UPI ID management
- UPI-based transactions
- P2P money transfers
- MPIN verification before sensitive transactions
Users can transfer money directly between accounts while maintaining transaction records.
The transfer flow includes:
Sender
│
▼
Authenticate User
│
▼
Verify MPIN
│
▼
Validate Receiver
│
▼
Check Wallet Balance
│
▼
Debit Sender
│
▼
Credit Receiver
│
▼
Create Transaction Record
The backend also supports service-based payments such as:
- 📱 Mobile recharge
- ⚡ Electricity bill payments
- 💧 Water payments
- 🔥 Gas payments
- 🛡️ Insurance payments
- 💳 Loan payments
Service providers can be stored and managed with information such as:
- Provider name
- Provider type
- Provider email
- Supported services
- Transaction creation
- Transaction history
- Sender/receiver tracking
- Transaction status
- Refund handling
- Transaction categorization
| Technology | Purpose |
|---|---|
| Node.js | Backend runtime |
| Express.js | REST API framework |
| MongoDB | Database |
| Mongoose | MongoDB ODM |
| JWT | Authentication |
| bcrypt | Password/MPIN hashing |
| dotenv | Environment configuration |
| Nodemon | Development server |
The current project uses ES Modules and Express with MongoDB/Mongoose.
uPay/
│
├── src/
│ │
│ ├── config/
│ │ └── Database configuration
│ │
│ ├── controllers/
│ │ ├── Transactions/
│ │ ├── MPIN.js
│ │ ├── UPID.js
│ │ ├── account.js
│ │ ├── login.js
│ │ ├── profile.js
│ │ ├── register.js
│ │ ├── serviceProvider.js
│ │ └── wallet.js
│ │
│ ├── lib/
│ │ ├── accessToken.js
│ │ └── refershToken.js
│ │
│ ├── middleware/
│ │ ├── auth.js
│ │ └── info.js
│ │
│ ├── models/
│ │ ├── AccountService.js
│ │ ├── AccountUser.js
│ │ ├── MPIN.js
│ │ ├── UPID.js
│ │ ├── serviceProvider.js
│ │ ├── transactions.js
│ │ ├── user.js
│ │ └── wallet.js
│ │
│ ├── routes/
│ │ ├── MPIN.js
│ │ ├── UPID.js
│ │ ├── account.js
│ │ ├── auth.js
│ │ ├── profile.js
│ │ ├── serviceprovider.js
│ │ ├── transactions.js
│ │ └── wallet.js
│ │
│ └── index.js
│
├── .env.example
├── .gitignore
├── package.json
└── package-lock.json
The repository currently follows a controller → middleware → model → route organization, keeping business logic and API routing separated.
┌──────────────────┐
│ Client │
│ Web / Mobile App │
└────────┬─────────┘
│
▼
┌──────────────────┐
│ Express API │
└────────┬─────────┘
│
Authentication
│
▼
┌──────────────────┐
│ Middleware │
│ JWT Validation │
└────────┬─────────┘
│
▼
┌──────────────────┐
│ Controllers │
│ Business Logic │
└────────┬─────────┘
│
▼
┌──────────────────┐
│ Models │
│ Mongoose │
└────────┬─────────┘
│
▼
┌──────────────────┐
│ MongoDB │
└──────────────────┘
uPay uses JWT-based authentication to protect private APIs.
Register
│
▼
Hash Password
│
▼
Store User
│
▼
Login
│
▼
Verify Credentials
│
▼
Generate JWT
│
▼
Access Protected APIs
Protected requests require a valid authentication token.
Authorization: Bearer <access_token>Financial operations are treated as sensitive operations.
Before performing a transaction, the backend can validate:
- User authentication
- MPIN
- Receiver/account details
- Wallet balance
- Transaction amount
- Transaction state
- Transaction record
This helps prevent unauthorized wallet operations and inconsistent transaction states.
The backend currently contains models for:
Stores user identity and authentication-related information.
Represents the user's payment/account relationship.
Handles the user's available balance and wallet-related operations.
Stores the secured MPIN information required for sensitive operations.
Manages dynamically generated UPI identifiers.
Stores payment and transfer information including transaction state and participants.
Stores supported service providers and their service categories.
git clone https://github.com/Sapta-Dev27/uPay.gitcd uPaynpm installCreate a .env file in the root directory.
PORT=5000
MONGO_URI=your_mongodb_connection_string
JWT_SECRET=your_jwt_secret
ACCESS_TOKEN_SECRET=your_access_token_secret
REFRESH_TOKEN_SECRET=your_refresh_token_secret
⚠️ Never commit your.envfile or production secrets to GitHub.
npm run startOr:
npm run devThe project currently defines start and dev scripts for running the backend.
The API is organized around the following modules:
| Module | Purpose |
|---|---|
| 🔐 Auth | Registration & login |
| 👤 Profile | User profile management |
| 💳 Account | Account operations |
| 💰 Wallet | Wallet management |
| 🔢 UPI ID | Dynamic UPI ID operations |
| 🔑 MPIN | MPIN creation & verification |
| 💸 Transactions | P2P transfers & transaction history |
| 🏢 Service Provider | Recharge & bill-payment providers |
A typical P2P transaction can be represented as:
POST /transaction
│
▼
Validate JWT
│
▼
Validate MPIN
│
▼
Find Sender
│
▼
Find Receiver
│
▼
Check Sender Balance
│
▼
Debit Sender Wallet
│
▼
Credit Receiver Wallet
│
▼
Create Transaction
│
▼
Return Transaction Status
uPay implements several security-oriented practices:
- Password hashing with bcrypt
- JWT authentication
- Protected routes
- MPIN-based transaction authorization
- Environment variables for secrets
- Database-level validation through Mongoose schemas
- Separation of authentication middleware from business logic
For a production deployment, additional measures such as rate limiting, request validation, HTTPS, audit logging, idempotency, and stricter transaction concurrency controls should also be considered.
🚧 Development Project
uPay is currently a backend-focused payment system and is intended as a learning/portfolio project demonstrating how payment-platform backend architecture can be designed using Node.js, Express, MongoDB, JWT, and Mongoose.
Planned improvements can include:
- API documentation with Swagger/OpenAPI
- Rate limiting
- Input validation using Zod/Joi
- Redis-based caching
- Transaction idempotency
- Improved wallet concurrency handling
- Automated test suite
- Docker support
- CI/CD pipeline
- Payment gateway integration
- Webhook support
- Admin dashboard
- Detailed transaction analytics
- Notification service
- Production monitoring and logging
Automated tests are not currently configured in the repository.
A test suite using tools such as Jest or Vitest can be added to cover:
Authentication
│
├── Registration
├── Login
└── Token validation
Wallet
│
├── Credit
├── Debit
└── Balance validation
Transactions
│
├── P2P transfer
├── MPIN validation
├── Insufficient balance
└── Transaction history
Contributions are welcome.
- Fork the repository
- Create a feature branch
git checkout -b feature/your-feature- Commit your changes
git commit -m "Add your feature"- Push the branch
git push origin feature/your-feature- Open a Pull Request
Backend / Full-Stack Developer
- GitHub: @Sapta-Dev27
- Project: uPay
If you find this project useful or interesting, consider giving the repository a ⭐ on GitHub.
This project is currently distributed under the ISC License as specified in the project's package.json.
Built with ❤️ using Node.js, Express & MongoDB