Skip to content

ReignnRule11/Secure-Digital-wallet.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

102 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Digital Wallet Backend API

A secure REST API for digital wallet operations built with Node.js, Express, PostgreSQL, Redis, and JWT.

Features

  • User registration & login with JWT (access + refresh tokens)
  • Password hashing with bcrypt
  • Wallet creation with balance constraint (DB-level check)
  • Idempotent fund transfers (prevents double spending)
  • Transaction history with pagination
  • Admin monitoring endpoints
  • Rate limiting with Redis
  • Comprehensive test suite (Jest + Supertest)

Tech Stack

  • Runtime: Node.js
  • Framework: Express
  • Database: PostgreSQL (ACID transactions)
  • Cache: Redis (rate limiting, idempotency)
  • Authentication: JWT
  • Validation: Joi
  • Testing: Jest, Supertest

Getting Started

Prerequisites

  • Node.js 18+
  • PostgreSQL 14+
  • Redis 6+
  • Docker (optional, for quick setup)

Installation

  1. Clone the repository
    git clone https://github.com/yourusername/wallet-backend.git
    cd wallet-backend
    
    

Docker Deployment

Prerequisites

  • Docker and Docker Compose installed

Running with Docker Compose (Development)

  1. Clone the repository
  2. Create a .env file (see .env.example) and set your email SMTP credentials (optional for testing)
  3. Run:
    docker-compose up -d
    
    

📁 Project Structure

project-root/ ├── .env.example ├── .gitignore ├── package.json ├── prisma/ │ └── schema.prisma ├── src/ │ ├── app.js │ ├── server.js │ ├── config/ │ │ ├── constants.js │ │ └── environment.js │ ├── database/ │ │ └── client.js │ ├── email/ │ │ ├── emailService.js │ │ ├── nodemailerService.js │ │ └── templates/ │ │ └── transferNotification.js │ ├── middleware/ │ │ ├── auth.js │ │ ├── errorHandler.js │ │ ├── rateLimiter.js │ │ ├── role.js │ │ └── validation.js │ ├── modules/ │ │ ├── admin/ │ │ │ ├── admin.controller.js │ │ │ ├── admin.routes.js │ │ │ └── admin.service.js │ │ ├── auth/ │ │ │ ├── auth.controller.js │ │ │ ├── auth.routes.js │ │ │ ├── auth.service.js │ │ │ └── auth.validation.js │ │ ├── transactions/ │ │ │ ├── transactions.controller.js │ │ │ ├── transactions.routes.js │ │ │ ├── transactions.service.js │ │ │ └── transactions.validation.js │ │ ├── users/ │ │ │ ├── users.controller.js │ │ │ ├── users.routes.js │ │ │ ├── users.service.js │ │ │ └── users.validation.js │ │ └── wallet/ │ │ ├── wallet.controller.js │ │ ├── wallet.routes.js │ │ ├── wallet.service.js │ │ └── wallet.validation.js │ ├── services/ │ │ └── email/ │ │ ├── email.interface.js │ │ ├── mockEmailService.js │ │ └── nodemailerEmailService.js │ └── utils/ │ ├── hash.js │ ├── jwt.js │ └── logger.js └── tests/ ├── integration/ │ └── transfer.test.js ├── unit/ │ └── transfer.service.test.js └── setup.js

About

Digital Wallet Backend API A secure REST API for digital wallet operations built with Node.js, Express, PostgreSQL, Redis, and JWT.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors