A robust, secure, and scalable backend system designed to handle core banking operations. This project implements a reliable ledger system, secure money transfers with idempotency, and comprehensive API documentation.
- 🔐 Secure Authentication: Multi-layered security using JWT (JSON Web Tokens) and Bcrypt for password hashing.
- 📊 Double-Entry Ledger: Every transaction is recorded as a linked Debit and Credit entry, ensuring accounting integrity.
- ⚡ Atomic Transactions: Utilizes MongoDB Sessions/Transactions to ensure that money transfers either succeed completely or fail gracefully (ACID compliance).
- 🛡️ Idempotency: Built-in protection against duplicate transactions using unique idempotency keys.
- 📧 Automated Notifications: Integrated email service to notify users of successful transactions.
- 🔒 Security First: implementation of Helmet for HTTP headers, Morgan for logging, and Rate Limiting to prevent brute-force attacks.
- 📖 Live API Documentation: Fully interactive Swagger documentation for seamless API testing.
- Runtime: Node.js
- Framework: Express.js
- Database: MongoDB (Mongoose ORM)
- Documentation: Swagger UI & Swagger JSDoc
- Security: JWT, Bcrypt, Helmet, Express-Rate-Limit
- Logging: Morgan
- Deployment Ready: Optimized for platforms like Render
The API is fully documented using Swagger. You can explore and test all endpoints directly from the browser.
Access the API docs here: Live Documentation
If running locally, access the docs at:
http://localhost:3000/api-docs
Note: In the Swagger UI, use the Servers dropdown at the top to switch between the Localhost and Production environments.
├── src
│ ├── config # Database and Swagger configurations
│ ├── controllers # Business logic for Auth, Accounts, and Transactions
│ ├── middlewares # Auth guards and request limiters
│ ├── models # Mongoose schemas (User, Account, Transaction, Ledger)
│ ├── routes # API route definitions
│ ├── services # Email and other third-party integrations
│ └── app.js # Express app initialization
├── server.js # Entry point of the application
└── .env # Environment variables
-
Clone the repository:
git clone https://github.com/pKm720/Banking-Backend-Ledger.git cd Banking-Backend-Ledger -
Install dependencies:
npm install
-
Configure Environment Variables: Create a
.envfile in the root directory and add the following:MONGO_URL=your_mongodb_connection_string JWT_SEC=your_secret_key EMAIL_USER=your_email@gmail.com APP_PASSWORD=your_app_password NODE_ENV=development PORT_ENV=3000
-
Run the server:
npm start
Unlike simple balance updates, this system uses a Ledger Model. When User A sends money to User B:
- A Transaction is created with a
PENDINGstatus. - A DEBIT entry is created for User A.
- A CREDIT entry is created for User B.
- The Transaction status is updated to
COMPLETED. - All these steps are wrapped in a Mongoose Session—if any step fails, the entire operation is rolled back.
To prevent accidental double-spending (e.g., if a user clicks "Send" twice), every transaction requires an idempotencyKey. The system checks if a transaction with that key already exists before processing.
I am a passionate Developer focused on building secure and high-performance financial systems. This project demonstrates my ability to handle complex database operations, implement security best practices, and deliver professional-grade documentation.
Looking for a dedicated developer for your team? Let's connect!
- GitHub: pKm720
- LinkedIn: Priyanshu Mahato
Created with ❤️ for a secure financial future.