Skip to content

raimaAsghar/Bank_Transaction_system

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

6 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🏦 Bank Transaction System

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.


πŸš€ Features

  • βœ… 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

πŸ› οΈ Tech Stack

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

πŸ“ Project Structure

Bank_Transaction_system/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ controllers/
β”‚   β”œβ”€β”€ models/
β”‚   β”œβ”€β”€ routes/
β”‚   └── middleware/
β”œβ”€β”€ server.js
β”œβ”€β”€ package.json
β”œβ”€β”€ .env
└── .gitignore

βš™οΈ Installation & Setup

1. Clone the Repository

git clone https://github.com/raimaAsghar/Bank_Transaction_system.git
cd Bank_Transaction_system

2. Install Dependencies

npm install

3. Configure Environment Variables

Create 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

4. Run the Application

# Development mode (with nodemon)
npm run dev

# Production mode
npm start

πŸ“§ Email Setup (Nodemailer + OAuth2)

This project uses Gmail OAuth2 for sending email notifications.

Steps to get OAuth2 credentials:

  1. Go to Google Cloud Console and enable the Gmail API.
  2. Create OAuth 2.0 Client ID credentials (Web Application type).
  3. Add https://developers.google.com/oauthplayground as an Authorized Redirect URI.
  4. 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.
  5. Add all credentials to your .env file.

πŸ”’ Security Features

  • 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.
  • .env file is excluded from version control via .gitignore.

πŸ“¦ Dependencies

{
  "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"
}

πŸ‘©β€πŸ’» Author

Raima Asghar GitHub


πŸ“š References & Acknowledgements

About

πŸ’Έ A backend that takes money seriously.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors