Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

21 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🏦 VaultPay

Modern Peer-to-Peer Payment Platform

Node.js React MongoDB License

Fast, secure, and user-friendly digital payments with ACID-compliant transactions

Features β€’ Architecture β€’ Quick Start β€’ API Reference β€’ Screenshots


πŸ“‹ Overview

VaultPay is a full-stack digital payment platform that enables seamless peer-to-peer money transfers. Built with a modern React frontend and a robust Node.js/Express backend, the application leverages MongoDB replica sets to ensure ACID-compliant transactions for financial operations.

The platform features a unique Vault system that allows users to securely save money in a separate balance, providing an intuitive way to manage funds.


✨ Features

πŸ’³ Core Payments

  • Instant P2P Transfers β€” Send money to any registered user with atomic, ACID-compliant transactions
  • Real-time Balance β€” View your current balance instantly
  • Transaction History β€” Complete audit trail of all sent and received payments

πŸ” Security

  • JWT Authentication β€” Secure token-based authentication with HttpOnly cookies
  • Password Hashing β€” Industry-standard bcrypt encryption
  • Input Validation β€” Comprehensive request validation using Zod schemas
  • Session Transactions β€” MongoDB sessions ensure data integrity during transfers

πŸ’° Vault System

  • Secure Savings β€” Deposit funds into a separate vault balance
  • Easy Withdrawals β€” Move money back to main balance when needed
  • Atomic Operations β€” All vault operations are transaction-safe

πŸ‘₯ User Management

  • User Registration β€” Simple signup with email verification
  • Profile Updates β€” Modify name and password securely
  • User Search β€” Find other users by name for easy transfers
  • Recent Contacts β€” Quick access to frequently contacted users

πŸ“Έ Screenshots

Dashboard Locked vault
Landing Dashboard
Send Money Transaction
Send History

πŸ— Architecture

graph TB
    subgraph Frontend["Frontend (React + Vite)"]
        UI[React Components]
        Router[React Router]
        State[Local State]
    end

    subgraph Backend["Backend (Node.js + Express)"]
        API[REST API]
        Auth[JWT Middleware]
        Routes[Route Handlers]
    end

    subgraph Database["Database (MongoDB Replica Set)"]
        Users[(Users Collection)]
        Accounts[(Accounts Collection)]
        Transactions[(Transactions Collection)]
    end

    UI --> Router
    Router --> API
    API --> Auth
    Auth --> Routes
    Routes --> Users
    Routes --> Accounts
    Routes --> Transactions
Loading

Tech Stack

Layer Technologies
Frontend React 18, Vite, React Router, Tailwind CSS, Axios
Backend Node.js, Express.js, Mongoose, Zod, JWT, bcrypt
Database MongoDB (Replica Set for ACID transactions)
Testing Jest, Supertest, Vitest, Testing Library

Project Structure

VaultPay/
β”œβ”€β”€ backend/                    # Express.js API Server
β”‚   β”œβ”€β”€ route/
β”‚   β”‚   β”œβ”€β”€ user.js            # Authentication & user endpoints
β”‚   β”‚   └── account.js         # Balance & transfer endpoints
β”‚   β”œβ”€β”€ __tests__/             # API integration tests
β”‚   β”œβ”€β”€ db.js                  # Mongoose schemas & models
β”‚   β”œβ”€β”€ middleware.js          # JWT authentication middleware
β”‚   β”œβ”€β”€ config.js              # Application configuration
β”‚   └── index.js               # Server entry point
β”‚
β”œβ”€β”€ frontend/                   # React SPA
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ Pages/             # Route components
β”‚   β”‚   β”‚   β”œβ”€β”€ Landing.jsx    # Marketing landing page
β”‚   β”‚   β”‚   β”œβ”€β”€ Dashboard.jsx  # Main user dashboard
β”‚   β”‚   β”‚   β”œβ”€β”€ SendMoney.jsx  # Transfer interface
β”‚   β”‚   β”‚   β”œβ”€β”€ Signin.jsx     # Login page
β”‚   β”‚   β”‚   └── Signup.jsx     # Registration page
β”‚   β”‚   └── components/        # Reusable UI components
β”‚   β”‚       β”œβ”€β”€ Balance.jsx    # Balance display card
β”‚   β”‚       β”œβ”€β”€ VaultCard.jsx  # Vault management UI
β”‚   β”‚       β”œβ”€β”€ History.jsx    # Transaction history
β”‚   β”‚       β”œβ”€β”€ Users.jsx      # User search & list
β”‚   β”‚       └── ...
β”‚   └── public/                # Static assets
β”‚
└── Dockerfile                 # MongoDB replica set configuration

Data Models

// User Schema
{
  email: String,      // Unique email address
  password: String,   // bcrypt hashed password
  firstName: String,
  lastName: String
}

// Account Schema
{
  userId: ObjectId,    // Reference to User
  balance: Number,     // Available balance
  vaultBalance: Number // Saved funds in vault
}

// Transaction Schema
{
  senderId: ObjectId,   // Sender user reference
  receiverId: ObjectId, // Receiver user reference
  amount: Number,
  timestamp: Date
}

πŸš€ Quick Start

Prerequisites

  • Node.js 18 or higher
  • npm or pnpm
  • Docker (recommended for MongoDB replica set)

1. Clone & Install

# Clone the repository
git clone https://github.com/yourusername/VaultPay.git
cd VaultPay

# Install backend dependencies
cd backend && npm install

# Install frontend dependencies
cd ../frontend && npm install

2. Configure Environment Variables

Create backend/.env:

MONGO_URL=mongodb://localhost:27017/vaultpay?replicaSet=rs
NODE_ENV=development
PORT=3000

⚠️ Important: Update backend/config.js to use environment variables for JWT_SECRET in production.

3. Start MongoDB Replica Set

Option A β€” Using the provided Dockerfile:

docker build -t mongo-rs -f Dockerfile .
docker run -d --name vaultpay-mongo -p 27017:27017 mongo-rs

Option B β€” Manual initialization:

docker run -d --name vaultpay-mongo -p 27017:27017 mongo:4.4.7 --replSet rs
docker exec -it vaultpay-mongo mongosh --eval "rs.initiate()"

Verify replica set status:

docker exec -it vaultpay-mongo mongosh --eval "rs.status()"

4. Run the Application

# Terminal 1: Start Backend
cd backend
node index.js
# Server runs at http://localhost:3000

# Terminal 2: Start Frontend
cd frontend
npm run dev
# App runs at http://localhost:5173

πŸ“‘ API Reference

Base URL: http://localhost:3000/api/v1

Authentication

All protected endpoints require authentication via:

  • HttpOnly Cookie: Automatically set on login
  • Bearer Token: Authorization: Bearer <token>

User Endpoints

Method Endpoint Auth Description
POST /user/signup ❌ Create new account
POST /user/signin ❌ Login and receive token
POST /user/logout ❌ Clear authentication cookie
PUT /user/ βœ… Update profile (name, password)
GET /user/me βœ… Get current user info
GET /user/bulk?filter= βœ… Search users by name

Signup Request

POST /user/signup
{
  "email": "user@example.com",
  "password": "SecurePass123",
  "firstName": "John",
  "lastName": "Doe"
}

Signin Response

{
  "message": "Signin succeeded",
  "token": "eyJhbGciOiJIUzI1NiIs...",
  "user": {
    "id": "507f1f77bcf86cd799439011",
    "email": "user@example.com",
    "firstName": "John",
    "lastName": "Doe"
  }
}

Account Endpoints

Method Endpoint Auth Description
GET /account/balance βœ… Get current balance and vault balance
POST /account/transfer βœ… Transfer money to another user
POST /account/vault/deposit βœ… Move funds to vault
POST /account/vault/withdraw βœ… Withdraw from vault
GET /account/history βœ… Get transaction history

Transfer Request

POST /account/transfer
{
  "to": "507f1f77bcf86cd799439012",
  "amount": 100
}

Balance Response

{
  "balance": 5000,
  "vaultBalance": 2000
}

πŸ§ͺ Testing

Backend Tests

cd backend

# Run tests in watch mode
npm test

# Run with coverage
npm run test:coverage

# CI mode
npm run test:ci

Frontend Tests

cd frontend

# Run tests
npm test

# Watch mode
npm run test:watch

# With UI
npm run test:ui

# Coverage report
npm run test:coverage

πŸ”§ Development

Available Scripts

Frontend (frontend/)

Script Description
npm run dev Start Vite development server
npm run build Build for production
npm run preview Preview production build
npm run lint Run ESLint

Backend (backend/)

Script Description
node index.js Start the server
npm test Run Jest tests

Troubleshooting

Transaction Error: "Transaction numbers are only allowed on a replica set member"

Ensure MongoDB is running as a replica set and your MONGO_URL includes ?replicaSet=rs.

# Verify replica set status
docker exec -it vaultpay-mongo mongosh --eval "rs.status()"
Cookies not being set in browser
  • Ensure frontend and backend are on compatible origins
  • Verify CORS credentials are configured
  • Check that sameSite and secure cookie options are appropriate for your environment

🚒 Production Deployment

Environment Setup

# Required production environment variables
MONGO_URL=mongodb+srv://...  # Use managed MongoDB Atlas or replica set
JWT_SECRET=your-secure-secret
NODE_ENV=production
PORT=3000

Deployment Checklist

  • Set NODE_ENV=production for secure cookies
  • Use environment variables for all secrets (never hardcode)
  • Deploy frontend to CDN/static host (Vercel, Netlify)
  • Run backend behind reverse proxy with HTTPS (Nginx)
  • Use managed MongoDB replica set (Atlas) or configure HA cluster
  • Update frontend/src/config.jsx with production API URL

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.


Built with ❀️ by Ayush Soni

About

VaultPay is a fast, secure, and user-friendly payment app designed for seamless transactions. Built with modern tech, it ensures safety and simplicity for all your payment needs.

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Used by

Contributors

Languages