is a project designed to teach how seperate backend and frontend applications interact. Given a basic frontend application written in React (https://github.com/Vadlusk/quantified-self-fe-go), students are tasked with creating three matching backends, the first in Rails, the second in Express, and the third in a language of our choice.
The application's functionality is that of a basic calorie counter. The user can add foods to a list and then add foods from that list to any of four meals. Each food is assigned a number of calories which is subtracted from remaining calories for each meal and for the day (all meals added together).
You can visit the deployed backend here, or the deployed frontend here.
- Clone or fork this repo in your go workspace.
- Move into the directory.
createdb quantified_self_go_dev
go build
./quantified_self_be_go
The following endpoints return either a food object or message that the action was successful.
Food objects are returned in the following format:
{
"id": int,
"name": string,
"calories": int
}
GET /api/v1/foods
returns a list of all foods in the database
GET /api/v1/foods/:id
returns the food with that id number
POST /api/v1/foods
creates a food with paramaters:
{
"food": {
"name": string,
"calories": int
}
}
all fields are required
PATCH /api/v1/foods/:id
edits an existing food with same parameters as above.
no fields are required.
DELETE /api/v1/foods/:id
deletes the food with that id number
The following endpoints return either a meal object or message that the action was successful.
Meal objects are returned in the following format:
{
"id": int,
"name": string,
"foods": array_of_food_objects
}
GET /api/v1/meals
returns all the meals in the database with associated foods
GET /api/v1/meals/:meal_id/foods
returns the meal with that id number
POST /api/v1/meals/:meal_id/foods/:id
associates the food with that id with the meal with that id
DELETE /api/v1/meals/:meal_id/foods/:id
removes the association between that food and that meal