This project is a backend payment system built with Express, TypeScript, and TypeORM. It includes user authentication, KYC processing, fund transfers, and more.
- Initialize Project
- Create a directory:
payment_backend
- Initialize Node.js:
npm init -y
- Install packages:
npm install express typescript typeorm pg bcrypt jsonwebtoken express-validator class-validator
- Set up TypeScript:
tsc --init
- Configure
tsconfig.json
andpackage.json
scripts - Set up directories:
src/ ├── controllers/ ├── routes/ ├── entities/ ├── middlewares/ └── config/
- Create a directory:
- TypeORM Setup
- Create
src/data-source.ts
- Establish database connection
- Create
User
andKyc
entities
- Create
- User Model: Custom model using TypeORM
- Routes:
- Registration
- Login
- Logout
- Security:
- Password hashing with
bcrypt
- JWT token generation with
jsonwebtoken
- Password hashing with
- Validate registration form
- Save user to database
- Return JWT token on successful registration
- Validate login form
- Authenticate user
- Return JWT token on successful login
- Invalidate JWT token (client-side handling)
- Create
Account
entity - One-to-one relationship with
User
- Set up
Account
repository
- Create
Kyc
entity - Form validation and processing
- Routes and controllers for KYC form submission
- Update KYC status and fields
- Handle money transfers between users
- Validate and process transfer requests
- View transaction history
- Filter by sender and receiver
- Handle payment requests
- Validate and process requests
- Handle payment settlements
- Confirm and process settlements
- Create
CreditCard
entity linked toUser
- Manage credit cards (add, view, fund, withdraw)
- Middleware for alerts and notifications
- Provide user feedback on actions
This backend system provides a comprehensive set of features for managing user accounts, handling payments, and ensuring secure transactions.