A secure and scalable RESTful Banking API built with Node.js, Express, and MongoDB. It supports user authentication, account management, and transaction handling with email notifications.
- β User Registration & Login
- π JWT-based Authentication with secure HTTP-only Cookies
- π Password Hashing using bcryptjs
- πΈ Bank Transaction Management (Deposit, Withdrawal, Transfer)
- π§ Email Notifications via Nodemailer (OAuth2)
- π± Environment Variable Support with dotenv
- ποΈ MongoDB Database Integration via Mongoose
| Technology | Purpose |
|---|---|
| Node.js | Runtime Environment |
| Express.js v5 | Web Framework |
| MongoDB + Mongoose | Database |
| bcryptjs | Password Hashing |
| JSON Web Token (JWT) | Authentication |
| Nodemailer + OAuth2 | Email Notifications |
| cookie-parser | Cookie Handling |
| dotenv | Environment Variables |
Bank_Transaction_system/
βββ src/
β βββ controllers/
β βββ models/
β βββ routes/
β βββ middleware/
βββ server.js
βββ package.json
βββ .env
βββ .gitignore
git clone https://github.com/raimaAsghar/Bank_Transaction_system.git
cd Bank_Transaction_systemnpm installCreate a .env file in the root directory and add the following:
# Server
PORT=5000
# MongoDB
MONGO_URI=your_mongodb_connection_string
# JWT
JWT_SECRET=your_jwt_secret_key
# Email (OAuth2)
EMAIL_USER=your_email@gmail.com
CLIENT_ID=your_google_client_id
CLIENT_SECRET=your_google_client_secret
REFRESH_TOKEN=your_oauth2_refresh_token# Development mode (with nodemon)
npm run dev
# Production mode
npm startThis project uses Gmail OAuth2 for sending email notifications.
Steps to get OAuth2 credentials:
- Go to Google Cloud Console and enable the Gmail API.
- Create OAuth 2.0 Client ID credentials (Web Application type).
- Add
https://developers.google.com/oauthplaygroundas an Authorized Redirect URI. - Go to OAuth 2.0 Playground:
- Use your own credentials (gear icon β settings).
- Select scope:
https://mail.google.com/ - Click Authorize APIs β Exchange authorization code for tokens.
- Copy the Refresh Token.
- Add all credentials to your
.envfile.
- Passwords are hashed with bcryptjs before storing in the database.
- Authentication is handled via JWT tokens stored in secure HTTP-only cookies.
- Sensitive credentials are managed through environment variables.
.envfile is excluded from version control via.gitignore.
{
"bcryptjs": "^3.0.3",
"cookie-parser": "^1.4.7",
"dotenv": "^17.2.3",
"express": "^5.2.1",
"jsonwebtoken": "^9.0.3",
"mongoose": "^9.1.5",
"nodemailer": "^7.0.12"
}Raima Asghar GitHub
- Nodemailer OAuth2 setup reference: Difference-Backend-documentation by Ankur
- Nodemailer Official Documentation
- Google OAuth2 Documentation
- OAuth 2.0 Playground