The motivation was to create a scalable wallet transaction system that allows users to pay each other with their phone numbers. The API has been tested for 100 concurrent users, performing transactions simultaneously with the help of postman. All db transactions are acid compliant and the database deadlocks problem is solved by prioritizing debit and credit requests on the basis of the phone number of the users involved.
This is an API that maintains user wallets and allows inter wallet transactions between users. The transactions are made possible with acid compliant db transactions. To try the API yourself click here.
-
Clone the repo in desired directory:
git clone https://github.com/Lakshya-Kapoor/E-wallet-APIs.git
-
Install dependencies:
npm install
-
PostgreSQL setup:
-
Install postgreSQL and create a database to store the tables:
-
Now set following environment variables for db connection:
DB_USER
DB_HOST
DB_NAME
DB_PASSWORD
DB_PORT
-
Run all the commands inside the /utils/tableSchema.sql file to create all the tables
-
-
Setup following environment variables for jwt auth
ACCESS_TOKEN_SECRET
REFRESH_TOKEN_SECRET
-
Run the server:
-
Trying out api
npm run start
-
For devlopment
npm run dev
-
POST /auth/signup
: To store user info in databasePOST /auth/login
: To generate JWT token
GET /user/balance
: Get user wallet balancePOST /user/pay
: Pay another userGET /user/transactions
: Get user transactions
GET /admin/users
: Get data of all usersGET /admin/users/:phone_no
: Get data of particular userGET /admin/transactions/:phone_no
: Get all transactions of a userGET /admin/verify_transactions/:phone_no
: Verify correctness of all the transactions