Skip to content

kweeuhree/personal-budgeting-backend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🏦 Personal Budgeting App

This repository contains a budget tracker that allows a user to create a budget and add categorized expenses.

🪧 Overview

The Personal Budgeting App is a RESTful API service that processes budget and expense data, updating the budget accordingly. The application is deployed on Render and may take up to 50 seconds to resume operation after periods of inactivity. It uses MySQL as its storage solution, hosted through the Aiven service.

Third-Party Packages

  • The scs/mysqlstore package is used for session storage in MySQL.
  • The scs/v2 package is used for session management and handling.
  • The mysql package is used interfacing with MySQL databases.
  • The httprouter package is used for fast and efficient routing.
  • The alice package is used for clear and readable middleware chaining.
  • The uuid package is used to generate unique ids.
  • The nosurf package is used for CSRF protection middleware.
  • The crypto package is used for password hashing and verification.

🔍 Prerequisites

  • Go 1.22.5
  • Windows, macOS, or Linux operating system

▶️ Usage

The application can be interacted with through the deployed React application.

💡API Specification

Endpoint: CSRF Token

  • Path: /api/csrf-token
  • Method: GET
  • Response: JSON containing a CSRF token.

Description:

Returns a JSON object with a CSRF token generated by the server.

Example Response:

{
  "csrf_token": "7cpnevxmIFjaS0yr6msraJistWmqySe/6JPE2ELapCtRyJ+Eg/iZ75ErPoRecEADW5q6jYMzMZjx83RKz+tFIg=="
}

Endpoint: User Signup

  • Path: /api/users/signup
  • Method: POST
  • Payload: JSON with user credentials.
  • Response: JSON containing user id, user email and a flash message.

Description:

Takes in a JSON with user credentials and returns a JSON object with a uuid-generated userId, registered user email, and a flash message.

Example Response:

{
  "userId": "7fb1377b-b223-49d9-a31a-5a02701dd310",
  "email": "[email protected]",
  "flash": "Your signup was successful. Please log in."
}

Endpoint: User Login

  • Path: /api/users/login
  • Method: POST
  • Payload: JSON with user credentials.
  • Response: JSON containing user details and a flash message.

Description:

Takes in a JSON with user credentials and returns a JSON object with the userId, user email, user name, user budget(if exists) and a flash message.

Example Response:

{
  "userId": "7fb1377b-b223-49d9-a31a-5a02701dd310",
  "email": "[email protected]",
  "displayName": "Go Dev",
  "budget": {
       {
        "budgetId": "5fb1355b-l113-49d9-h57s-0a11301dh57s",
        "checkingBalance": "1000",
        "savingsBalance": "5000",
        "budgetTotal": "6000",
        "budgetRemaining": "6000",
        "totalSpent": "2000"
       }
  },
  "flash": "Login successful!"
}

Releases

No releases published

Packages

No packages published