Skip to content

simple API to create and manage a personal budget using budget envelopes

Notifications You must be signed in to change notification settings

riascho/Budget-Project

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Personal Budget Project

Overview

The Personal Budget project is part of the Codecademy Back-End Engineer career path. It is intended as a Javascript Project but my implementation uses Typescript.

For this project, I built an API that allows clients to create and manage a personal budget. Using Envelope Budgeting principles, the API allows users to manage budget envelopes and track the balance of each envelope. This API also follows best practices regarding REST endpoint naming conventions, proper response codes, etc. I have also included data validation to ensure users do not overspend their budget.

Project Objectives:

  • Build an API using Node.js and Express
  • Be able to create, read, update, and delete envelopes
  • Create endpoints to update envelope balances
  • Use Git version control to keep track of your work
  • Use the command line to navigate your files and folders
  • Use Postman to test API endpoints

Prerequisites:

  • Command line and file navigation
  • Javascript
  • Typescript
  • Node.js
  • Express
  • Git and GitHub
  • Postman

Project Tasks

  • Create file(s) and install Express: On your computer, create a directory to hold your file(s) for a Node/Express project. Initialize a new Node.js project with npm, create a file to run your server, and add the Express library in said file. You can start out with a single file called server.js or index.js. As you progress on your project you might find it best to separate logic under different folders/files in order to make it more scalable.

  • Set up the environment and a simple endpoint: Create an Express app and write out an endpoint to send a GET request so that the message “Hello, World” appears when you open localhost:3000/ in your browser. Make sure to write out the necessary code to run a server in your main file and set your port to 3000. The URL for the landing page is usually /. If working correctly, you should be able to navigate to localhost:3000/ and see your message, “Hello, World” displayed on the browser.

  • Version Control: Set up Git tracking in your directory and make sure to add and commit changes as you make them. You can set up your git tracking with git init. Remember to add and commit your progress as you move forward with the project.

  • Create your envelopes: Create global variables to store information about your envelopes and total budget. Create an endpoint that sends a POST request in order to generate individual budget envelopes. It will be useful to prepend your endpoints with a keyword for your API, such as /envelopes. In this case, an array holding objects to represent each envelope might be a useful approach. Each envelope will be represented by a numerical ID and hold information regarding its budget and title. Feel free to attach response codes so that users can see if their requests were sent successfully or if there were any errors.

  • Retrieve all your envelopes: Create an endpoint that sends a GET request to retrieve all your envelopes. The endpoint can be located in your homepage URL or something more specific if you wish.

  • Test your endpoints with Postman: Using Postman, test your endpoints by creating a few envelopes and see if you can retrieve them by making a GET request. Throughout this project, make sure to continuously use Postman to test your endpoints and requests.

  • Retrieve specific envelopes: Create an endpoint that sends a GET request in order to retrieve a specific envelope and see their current budget and other information. You will be using an envelope’s unique ID in order to retrieve it. This is typically done by parsing the URL parameter for an ID and searching for the envelope with the corresponding ID. Make sure to test this in Postman to see if the requests are sent successfully.

  • Update specific envelopes and balances: Create an endpoint that updates specific envelopes when money is being extracted from them. You should also be able to update any other information about an envelope using this endpoint. We want to be able to update our total budget and specific envelopes as we extract money from them. Depending on how you’ve set up your balance methods, this could either be a POST or PUT request. If you set a balance to a specific value a PUT request will be more appropriate. If you’re constantly subtracting an amount from a balance, then a POST request Similarly to the GET request (for a specific envelope), you can use req.param() to search the URL for a parameter. You’ll be sending a value that will be subtracted from the envelope’s budget. Add that logic in the callback function of the endpoint. This would be a good place to add some data validation to make sure the correct information is being passed into the request! If you want to update other information about a budget envelope you can do that here as well.

  • Delete specific envelopes: Create an endpoint that sends a DELETE request and deletes a specific envelope. When deleting entities, we typically delete them one by one to avoid big accidental data loss. You can use the high order function filter in order to update your budget envelopes and remove the specific envelope from the request parameter.

  • Transfer budgets from different envelopes: Create a POST request that uses two parameters and transfers a value from one envelope to another. We want the feature to be able to change budgets between envelopes. Perhaps one month we’d like to remove some money from our “dining out” envelope and put it in our “groceries” envelope. Your URL might look something like this: http://localhost:3000/envelopes/transfer/:from/:to This request would take in a header value and update the balances of both envelopes by subtracting it from one and adding it to the other.

  • Upload project to GitHub: Make sure all your code has been added and committed with git and upload your project into a new GitHub repository. Add a README.md with instructions on how to use your API. If you created a repository in the early stages of the project, all you need is to push your main branch in order to update to the repo.

Bonus Tasks:

  • Create a frontend that displays envelopes and balances, and allows users to update each envelop balance
  • Add an API endpoint allowing user to add a single balance that’s distributed to multiple envelopes

Installation

  1. Clone the repository:
    git clone https://github.com/riascho/Budget-Project.git
  2. Navigate to the project directory:
    cd Budget-Project
  3. Install dependencies:
    npm install

Usage

  1. Compile the code:
    tsc
  2. Start the application:
    npm start
  3. Open your browser and navigate to http://localhost:3000.

About

simple API to create and manage a personal budget using budget envelopes

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published