A robust Node.js/Express ledger service featuring immutable transaction logs, idempotent financial transfers, and reliable account management powered by MongoDB with secure JWT authentication.
- Overview
- Architecture
- Entity Relationship Diagram
- API Reference
- Installation
- Environment Variables
- Running the App
Backend Ledger is a production-grade financial ledger REST API built for reliability and correctness. It provides:
- 🔒 Secure Authentication — JWT-based auth for all protected routes
- 💳 Account Management — Create and manage user accounts with real-time balance tracking
- 💸 Idempotent Transfers — Safe, duplicate-proof financial transfers between accounts
- 📜 Immutable Transaction Logs — Every debit and credit is permanently recorded and auditable
- ⚡ Transactional Safety — Critical operations use MongoDB sessions to ensure data consistency
- 📄 OpenAPI Docs — Interactive Swagger UI for exploring and testing all endpoints
📐 For a detailed in-depth explanation of the system design, module responsibilities, and data flow, refer to the
docs/ARCHITECTURE.mdfile.
📊 For the full interactive ERD with detailed column types, constraints, and relationships, visit dbdocs.io — Backend Ledger Project.
The API is organized around the following core resource groups:
| Group | Base Path | Description |
|---|---|---|
| Auth | /api/auth |
Register, login, and token management |
| Accounts | /api/accounts |
Create and manage ledger accounts |
| Transfers | /api/transfers |
Initiate idempotent fund transfers |
| Ledger | /api/ledger |
View immutable transaction history |
All endpoints follow RESTful conventions and return JSON responses. Protected routes require a Bearer token in the Authorization header.
📖 For the complete interactive API documentation including request/response schemas, authentication flows, and a live try-it-out console, visit: https://backend-ledger-tbxj.onrender.com/api/docs/
Make sure you have the following installed:
- Node.js v18 or higher
- npm v9 or higher
- MongoDB v6 or higher (local) or a MongoDB Atlas cluster
1. Clone the repository
git clone https://github.com/omprakash0224/Backend-Ledger.git
cd Backend-Ledger2. Install dependencies
npm install3. Set up environment variables
cp .env.example .envThen edit .env with your configuration (see Environment Variables below).
4. Configure your MongoDB connection
Set your MongoDB connection string in .env (see Environment Variables below). You can use a local MongoDB instance or a free MongoDB Atlas cluster — no manual schema setup is needed as Mongoose handles collection creation automatically.
Create a .env file in the root directory with the following variables:
MONGO_URI=your_mongodb_uri_here
JWT_SECRET=your_jwt_secret_here
CLIENT_ID=your_google_client_id_here
CLIENT_SECRET=your_google_client_secret_here
REFRESH_TOKEN=your_google_refresh_token_here
EMAIL_USER=your_email_user_hereDevelopment mode (with auto-reload):
npm run devProduction mode:
npm startThe server will start at http://localhost:3000 by default.
The interactive API docs will be available at http://localhost:3000/api/docs/.
Made with ❤️ by omprakash0224

