A simple backend for an application like splitwise to share expenses between groups of people.
- The
src
folder contains the main code for the backend.SQLfiles
contains SQL codes that need to be run directly and cannot be configured viaNode.JS
modules like functions and triggers.- The files are executed on booting the server.
- Following are the requirements to fullfill before starting the project, and steps on how to set up and run the backend on your system.
The System on which the backend is running must have:
- Node.js
- npm (Node Package Manager) or yarn
- PostgreSQL
A step-by-step guide on how to install and configure your project:
-
Clone the repository:
git clone https://github.com/vihar-s1/Splitwise-Backend-Clone.git cd Splitwise-Backend-Clone
-
Install the dependecies/ required Modules:
npm install # If you installed Node Package Manager (npm)
yarn install # If you installed Yarn on your computer
-
Configure the environment file:
# CONTENTS OF .ENV FILE FRONTEND_URL="*" # FRONT URL PORT=5000 # BACKEND PORT # DataBase Variables DB_USERNAME="<username-under-which-the-database-exists>" DB_PASSWORD="<corresponding-password>" DB_HOST="<url-of-where-the-database-is-hosted>" DB_PORT=<port-on-which-database-is-listening> DB_NAME="<name-of-the-database>" # JWT variables JWT_SECRET="<jwt-secret-used-to-sign-authentication-tokens>" TOKEN_LIFE="<time-period-after-which-token-expires>"
You can alternately use the
.env.sample
file present in the root for development process by renaming it to.env
.NOTE THAT THE VALUES OF ENVIRONMENT VARIABLES IN
.env.sample
ARE FOR LOCAL DEVELOPMENT SERVER AND NOT VALID/SECURE FOR DEPLOYED SERVER APPLICATION. -
Run the Project:
npm run start
yarn start
Currently, following are the existing endpoints:
- (POST) /api/user/new-user: Create a new user with unique email if not already exists. Return authentication token on success.
- (POST) /api/user/login: Login a user using email and password. Returns authentication token on success.
- (GET) /api/user/profile: Fetch details of the user whose valid authentication token is provided.
- (PUT) /api/user/update-profile: Update user profile details.
- (PUT) /api/user/change-password: Change user password using authenticatoin token and old-new password method.
- (DELETE) /api/user/delete: Delete user profile.
- (POST) /api/group/create-group: Create a new group and add its members.
- (GET) /api/group/:groupId: get details of the group with ID groupId if authenticated user belonging to that group.
- (PUT) /api/group/update/:groupId: Update group details if authenticated user belongs to that group.
- (DELETE) /api/group/delete/:groupId: Delete the group if authenticated user belongs to that group.
- (POST) /api/transaction/addtx: Create and a new Transaction
- (GET) /api/transaction/:txId: fetch details of a particular transaction, identified by its ID
- (DELETE) /api/transaction/delete/:txId: Delete a transaction identifying by its ID