Skip to content

A simple backend for an application to share expenses with friends

Notifications You must be signed in to change notification settings

vihar-s1/Splitwise-Backend-Clone

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Splitwise Backend Clone

A simple backend for an application like splitwise to share expenses between groups of people.

Table of Contents

Getting Started

  • The src folder contains the main code for the backend. SQLfiles contains SQL codes that need to be run directly and cannot be configured via Node.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.

Prerequisites

The System on which the backend is running must have:

  • Node.js
  • npm (Node Package Manager) or yarn
  • PostgreSQL

Installation and Usage

A step-by-step guide on how to install and configure your project:

  1. Clone the repository:

    git clone https://github.com/vihar-s1/Splitwise-Backend-Clone.git
    cd Splitwise-Backend-Clone
  2. Install the dependecies/ required Modules:

    npm install
    # If you installed Node Package Manager (npm)
    yarn install
    # If you installed Yarn on your computer
  3. 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.

  4. Run the Project:

    npm run start
    yarn start

Endpoints

Currently, following are the existing endpoints:

User 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.

Group Endpoints

  • (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.

Transaction Endpoints

  • (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

About

A simple backend for an application to share expenses with friends

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published