Fast, secure, and user-friendly digital payments with ACID-compliant transactions
Features β’ Architecture β’ Quick Start β’ API Reference β’ Screenshots
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.
- 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
- 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
- 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 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
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
| 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 |
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
// 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
}- Node.js 18 or higher
- npm or pnpm
- Docker (recommended for MongoDB replica set)
# 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 installCreate backend/.env:
MONGO_URL=mongodb://localhost:27017/vaultpay?replicaSet=rs
NODE_ENV=development
PORT=3000
β οΈ Important: Updatebackend/config.jsto use environment variables forJWT_SECRETin production.
Option A β Using the provided Dockerfile:
docker build -t mongo-rs -f Dockerfile .
docker run -d --name vaultpay-mongo -p 27017:27017 mongo-rsOption 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()"# 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:5173Base URL: http://localhost:3000/api/v1
All protected endpoints require authentication via:
- HttpOnly Cookie: Automatically set on login
- Bearer Token:
Authorization: Bearer <token>
| 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 |
POST /user/signup
{
"email": "user@example.com",
"password": "SecurePass123",
"firstName": "John",
"lastName": "Doe"
}{
"message": "Signin succeeded",
"token": "eyJhbGciOiJIUzI1NiIs...",
"user": {
"id": "507f1f77bcf86cd799439011",
"email": "user@example.com",
"firstName": "John",
"lastName": "Doe"
}
}| 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 |
POST /account/transfer
{
"to": "507f1f77bcf86cd799439012",
"amount": 100
}{
"balance": 5000,
"vaultBalance": 2000
}cd backend
# Run tests in watch mode
npm test
# Run with coverage
npm run test:coverage
# CI mode
npm run test:cicd frontend
# Run tests
npm test
# Watch mode
npm run test:watch
# With UI
npm run test:ui
# Coverage report
npm run test:coverage| 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 |
| Script | Description |
|---|---|
node index.js |
Start the server |
npm test |
Run Jest tests |
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
sameSiteandsecurecookie options are appropriate for your environment
# 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- Set
NODE_ENV=productionfor 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.jsxwith production API URL
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
Built with β€οΈ by Ayush Soni



