Banking Application Blueprint
The Banking Application is a comprehensive, production-ready blueprint that demonstrates how to build a complete financial services backend using Express.js and MongoDB. This blueprint includes account management, fund transfers, transaction tracking, and a double-entry ledger system.
What You'll Build
A fully functional banking API with:
- User Account Management - Create and manage bank accounts
- Deposit & Withdrawal - Handle cash operations with validation
- Fund Transfers - Secure internal and external transfers
- Transaction History - Complete audit trail of all operations
- Double-Entry Ledger - Professional accounting system implementation
- OTP Verification - Secure critical operations with one-time passwords
- OAuth Integration - Support for third-party authentication providers
- File Upload - Document upload functionality for KYC and more
Features
Core Banking Features
- ✅ Account Management - Create multiple account types (savings, checking, business)
- ✅ Balance Operations - Deposit, withdraw, and check balance with validations
- ✅ Fund Transfers - Internal transfers between accounts with real-time updates
- ✅ Transaction Tracking - Complete history with filtering and pagination
- ✅ Ledger System - Double-entry bookkeeping for financial accuracy
- ✅ Audit Trail - Comprehensive logging of all financial operations
Security & Authentication
- ✅ JWT Authentication - Secure access tokens with refresh mechanism
- ✅ OTP Verification - Two-factor authentication for sensitive operations
- ✅ OAuth 2.0 - Google and GitHub authentication support
- ✅ Role-Based Access - Different permissions for users and admins
- ✅ Rate Limiting - Protection against brute-force attacks
- ✅ Input Validation - Comprehensive validation using Zod schemas
Technical Features
- ✅ MVC Architecture - Clean separation of concerns
- ✅ Feature-Based Modules - Domain-driven organization option
- ✅ Swagger Documentation - Auto-generated API docs
- ✅ Error Handling - Centralized error handling with custom errors
- ✅ Logging - Winston-based structured logging
- ✅ TypeScript - Full type safety and IntelliSense support
Installation
Generate a new banking app project using the Servercn CLI:
npx servercn-cli add blueprint banking-appThis will create a complete banking application with all the necessary modules, models, and routes.
Project Structure
MVC Architecture
The banking app follows the traditional Model-View-Controller pattern:
Feature-Based Architecture
For better scalability and maintainability:
Running the Application
API Documentation
Once running, access the interactive API documentation at: http://localhost:3000/api/docs
The Swagger UI provides:
- Interactive API testing
- Request/response examples
- Authentication helpers
- Schema definitions
API Endpoints
Health Check
Base URL: http://localhost:3000/api/v1/health
| Method | Endpoint | Description |
|---|---|---|
| GET | / | Basic health check |
| GET | /detailed | Detailed health status |
Authentication
Base URL: http://localhost:3000/api/v1/auth
| Method | Endpoint | Description |
|---|---|---|
| POST | /signup | Register a new user |
| POST | /signin | Login user |
| POST | /verify-otp | Verify OTP |
| GET | /profile | Get user profile |
| PATCH | /profile | Update user profile |
| POST | /refresh-token | Refresh access token |
| POST | /logout | Logout user |
| POST | /forgot-password | Request password reset |
| POST | /reset-password | Reset password |
| POST | /change-password | Change password |
| DELETE | /delete-account | Delete account |
| PUT | /reactivate-account | Reactivate account |
Accounts
Base URL: http://localhost:3000/api/v1/accounts
| Method | Endpoint | Description |
|---|---|---|
| POST | / | Create a new account |
| GET | / | Get all user accounts |
| GET | /:accountId | Get account details |
| GET | /balance/:accountId | Get account balance |
Transactions
Base URL: http://localhost:3000/api/v1/transactions
| Method | Endpoint | Description |
|---|---|---|
| POST | /system-init | Create system initial transaction |
| POST | / | Create a new transaction |
| GET | /history/:accountId | Get transaction history |
OAuth
Base URL: http://localhost:3000/api/auth
| Method | Endpoint | Description |
|---|---|---|
| GET | /github | GitHub OAuth login |
| GET | /github/callback | GitHub OAuth callback |
| GET | Google OAuth login | |
| GET | /google/callback | Google OAuth callback |
Security Considerations
- Password Hashing - bcrypt with salt rounds
- JWT Tokens - Short-lived access tokens, long-lived refresh tokens
- Rate Limiting - Per-IP and per-user limits
- Input Validation - All inputs validated with Zod
- SQL Injection Prevention - MongoDB prevents SQL injection
- XSS Protection - Helmet middleware
- CORS Configuration - Configurable allowed origins
- Request Sanitization - Mongo-sanitize for NoSQL injection prevention
Best Practices Followed
- Never log sensitive data (passwords, tokens)
- Use HTTPS in production
- Rotate secrets regularly
- Implement account lockout after failed attempts
- Monitor for suspicious activity
Contributing
Found a bug or want to suggest improvements? Please contribute to the Servercn project!
Support
Need help? Join our Discord community or open an issue on GitHub.