This repository contains a full-stack banking system application built with Next.js, created as a course project for our Database Management Systems course, Winter Semester 24-25. It utilizes a MySQL database for data management and JWT (JSON Web Tokens) for secure authentication. The system features role-based access control, providing separate dashboards and functionalities for regular users and administrators. The project is named "NITC Bank" within the admin interface.
User Functionalities (Customer Dashboard):
- User registration and login.
- Create new bank accounts (savings, current), initially set to 'pending' status for admin approval.
- View account balances and details.
- Transfer funds between own accounts or to other users' accounts.
- Withdraw funds from accounts.
- Apply for loans, which are then reviewed by administrators.
- Repay outstanding loans.
- View detailed transaction history (deposits, withdrawals, transfers).
Admin Functionalities (Admin Dashboard):
- Secure login for administrators.
- Approve or reject pending bank account applications.
- Freeze or close existing bank accounts.
- Approve or reject pending loan applications.
- Manage deposits into user accounts.
- Reverse transactions with a specified reason.
- View history of reversed transactions.
General System Features:
- Secure API endpoints with JWT authentication.
- Role-based authorization enforced by middleware for customer and admin routes.
- MySQL database for persistent storage of user data, accounts, transactions, and loans.
- Framework: Next.js (with React)
- Backend Logic: Next.js API Routes
- Database: MySQL (mysql2driver)
- Authentication: JWT (josefor token verification,jsonwebtokenfor signing,bcryptjsfor password hashing)
- Styling: Tailwind CSS
- Data Validation: Zod (in login/signup routes)
- Unique ID Generation: nanoid
- Development Server: Next.js with Turbopack
- Environment Management: dotenv
- Node.js (latest LTS version recommended)
- npm, yarn, or pnpm
- MySQL server instance
git clone https://github.com/shazilkp/banking_system.git
cd banking_systemnpm install
# or
yarn install
# or
pnpm install- Ensure your MySQL server is running.
- Create a new database for the application (e.g., banking_db).
- Import the database schema by executing the init.sqlscript located in the root of the project. You can use a MySQL client or tool for this:mysql -u your_mysql_user -p your_database_name < init.sql
Create a .env file in the root of the project and add the following environment variables, replacing the placeholder values with your actual configuration:
DB_HOST=localhost
DB_USER=your_mysql_user
DB_PASSWORD=your_mysql_password
DB_NAME=your_database_name # e.g., banking_db
JWT_SECRET=your_very_strong_and_secret_jwt_key # A long, random stringnpm run dev
# or
yarn dev
# or
pnpm dev
# or
bun devOpen http://localhost:3000 with your browser to see the application. You will be redirected to the login page.
- app/: Contains the Next.js application code.- app/api/: Backend API endpoints.- app/api/auth/: Authentication status check.
- app/api/login/: Handles user login.
- app/api/signup/: Handles user registration.
- app/api/logout/: Handles user logout.
- app/api/accounts/: User-facing account operations.
- app/api/loans/: User-facing loan operations.
- app/api/transfers/: User-facing transfer, deposit, and withdrawal operations.
- app/api/admin/: Admin-specific API endpoints for managing accounts, loans, and transactions.
 
- app/dashboard/: Frontend pages and components for the customer dashboard.
- app/admin/: Frontend pages and components for the admin dashboard.
- app/login/: Frontend page for login and signup.
- app/layout.js: Main application layout.
- app/globals.css: Global styles.
 
- lib/db.js: MySQL database connection pool setup.
- middleware.js: Handles JWT authentication, route protection, and role-based access control.
- init.sql: SQL script for initializing the database schema.
- public/: Static assets like images and SVGs.
- package.json: Project dependencies and scripts.
- next.config.mjs: Next.js configuration.
- jsconfig.json/- tsconfig.json: JavaScript/TypeScript configuration for path aliases and compiler options.
To learn more about Next.js, take a look at the following resources:
- Next.js Documentation - learn about Next.js features and API.
- Learn Next.js - an interactive Next.js tutorial.