This Node.js bank application allows users to create accounts, deposit and withdraw funds, and transfer money between accounts through a RESTful API. Built using Express.js and MongoDB, this application demonstrates the use of asynchronous operations to handle financial transactions efficiently.
- User Authentication: Secure user registration and login.
- Account Management: Create and manage bank accounts.
- Transactions: Deposit and withdraw funds.
- Transfers: Transfer funds between accounts.
- Asynchronous Processing: Handles operations using asynchronous programming for better performance.
Represents a user in the system.
email
: String (required, unique)password
: String (required, hashed)
Represents a bank account.
accountNumber
: String (required, unique)balance
: Number (default: 0)user
: ObjectId (reference to User, required)
Represents a financial transaction.
amount
: Number (required)type
: String (enum: ['deposit', 'withdrawal'], required)date
: Date (default: current date)user
: ObjectId (reference to User, required)
- POST /api/auth/signup: Register a new user.
- POST /api/auth/signin: Login and obtain a JWT token.
- POST /api/auth/signout: Log out.
- POST /api/auth/me: Get current logged in user.
- POST /api/accounts/create: Create a new account.
- POST /api/transactions/deposit: Transfer funds to current user accounts.
- POST /api/transactions/withdrawal: Withdraw funds from current user account.
- POST /api/transactions/p2p: Transfer funds between accounts.
- POST /api/transactions/account: get all transactions (deposit or withdrawal) by account number.
- Authentication Middleware: Ensures that routes are accessed by authenticated users only.
- Node.js
- MongoDB
-
Clone the repository:
git clone https://github.com/pseudoeazy/eazy-bank.git cd eazy-bank
-
Install dependencies:
npm install
-
Set up environment variables: Create a
.env
file in the root directory and add the following:MONGO_DB=mongodb://127.0.0.1:27017/eazy-bank MONGO_DB_TEST=mongodb://127.0.0.1:27017/eazy-bank-test JWT_PRIVATE_KEY=jwt-private-key PORT=4000 NODE_ENV=development
-
Start the application:
npm start
- Use an API client like Postman to interact with the API endpoints.
- Register a new user, create accounts, and perform transactions using the provided endpoints.
This project is licensed under the MIT License.