Banking App (MongoDB)
This document outlines the MongoDB database schema for a sample banking application. The schema is designed to be efficient, scalable, and easy to understand. We use Mongoose for defining our data models.
The core of our application revolves around four main collections: User, Account, Transaction and Ledger.
Installation Guide
To add these schemas to your project, run:
npx servercn-cli add schema banking-app1. User Schema
The User schema stores essential information about the customer. This includes personal details and security credentials.
MVC Path: src/models/user.model.ts
Feature Path: src/modules/auth/user.model.ts
Installation
npx servercn-cli add schema banking-app/user2. Account Schema
The Account schema stores user bank accounts (e.g., savings, current). A user can own multiple accounts with different types, currencies, and statuses.
MVC Path: src/models/account.model.ts
Feature Path: src/modules/account/account.model.ts
Installation
npx servercn-cli add schema banking-app/account3. Transaction Schema
The Transaction schema records money movements between accounts, including transfers, deposits, and withdrawals.
MVC Path: src/models/transaction.model.ts
Feature Path: src/modules/transaction/transaction.model.ts
Installation
npx servercn-cli add schema banking-app/transaction5. Ledger Schema
The Ledger schema records all financial movements such as deposits, withdrawals, and transfers. Each entry represents a finalized financial event.
Ledger entries are immutable. All update and delete operations are blocked to preserve audit integrity.
Path
- MVC:
src/models/ledger.model.ts - Feature:
src/modules/ledger/ledger.model.ts
Installation
npx servercn-cli add schema banking-app/ledgerNotes:
- Ledger entries are immutable
- All update and delete operations are blocked to preserve audit integrity