Skip to content

Latest commit

 

History

31 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Digital Wallet System

A Digital Wallet System built with Node.js, Express, and MongoDB that allows users to send and receive funds, manage wallets, and track transactions with proper authentication and authorization.

Postman-testing-link:

---

🎥 Video Explanation

Watch the full video explanation of the project here:https://drive.google.com/file/d/1lcXZs5jZWK-qYmyyAvDvM6zshcpQPBrb/view?usp=sharing

📝 Table of Contents


✨ Features

  • User registration, login, and authentication using JWT
  • Role-based access control (Admin, User, Agent)
  • Create and manage multiple wallets
  • Send and receive, cashin money between wallets
  • Track transactions with unique auto-generated transaction IDs
  • View transaction history with pagination and sorting
  • Wallet status management (Active, Blocked)
  • Security features: password hashing (bcryptjs), JWT, sessions

🛠 Tech Stack

  • Backend: Node.js, Express
  • Database: MongoDB with Mongoose ORM
  • Authentication: JWT, Passport.js
  • Validation: Zod
  • Other Tools: dotenv, cors, cookie-parser, express-session

🚀 Installation

  1. Clone the repository:
git clone https://github.com/nodeNINJAr/Digital-Wallet-backend
cd digital-wallet-system


Install dependencies:

npm install


Set up environment variables (see below).

Start the server:

npm run dev


Server should run on http://localhost:5000 (or your configured port).

🔑 Environment Variables

Create a .env file in the root directory:

PORT=5000
MONGO_URI=your_mongodb_connection_string
JWT_SECRET=your_jwt_secret_key
JWT_EXPIRES_IN=1d
SESSION_SECRET=your_session_secret
NODE_ENV=development
BCRIPT_SOLT_ROUND=10
# jwt
JWT_ACCESS_SECRET=jwtsecretjbhjhj
JWT_ACCESS_EXPIRES=1d
JWT_REFRESH_SECRET=hjsbmdddddddddd
JWT_REFRESH_EXPIRES=30d
# express session
EXPRESS_SESSION_SECRET=keyboard cat
# admin
ADMIN_EMAIL=admin email
ADMIN_PASS=password

📦 API Endpoints
Auth Routes

POST /api/v1/auth/register – Register a new user

POST /api/v1/auth/login – Login user and get JWT

User Routes

GET /api/v1/user – Get all users (Admin only, supports pagination & sorting)

PATCH /api/v1/user/agent-status – Update agent status to PENDING

Wallet Routes

GET /api/v1/wallets/me – Get logged-in user wallet

POST /api/v1/wallets/transactions – Transfer money to another wallet

Transaction Routes

GET /api/v1/transactions – Get all transactions (Admin, supports pagination & sorting)

GET /api/v1/transactions/me – Get logged-in user transactions

Pagination & sorting example:
/api/v1/transactions/me?page=2&limit=10&sortBy=amount&sortOrder=asc

⚡ Usage

Register a user and login to get a JWT.

Use the JWT in the Authorization header for all protected routes:

Authorization: Bearer <your_jwt_token>


Admin users can fetch all users, while normal users can view their own wallet and transaction history.

📁 Folder Structure


📌 Notes

Transaction IDs are automatically generated in the format: TXN-YYYYMMDD-xxxx

Wallets can be blocked, preventing transactions from that wallet

Supports pagination and sorting for user and transaction queries

About

Digital Wallet System (Backend): A robust backend API for secure financial transactions, user management, and data processing, built with Node.js, Express, MongoDB, and JWT authentication.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages