Snackr is a food tracking app that rates users' experience after meals. The app is built using a service oriented architecture. For a more detailed explanation of the user experience, please visit our frontend repo.
The following are a list of APIs used:
GET /users/:id/meals?date=<DATE IN DATETIME>
Example JSON response:
{
"data": [
{
"id": "1",
"type": "meal",
"attributes": {
"name": "Avocado toast",
"rank": 8,
"meal_time": "2012-03-05, 00:00:00"
}
"relationships": {
"food_entries": {
"data": [
{
"id": 1,
"meal_id": 1,
"food_id": 12345
"food_name": "bread"
},
{
"id": 2,
"meal_id": 1,
"food_id": 68762
"food_name": "avocado"
}
]
}
}
},
....
]
}
GET /users/:id/graphs
Returns a list of graph uris.
Example JSON response:
{
"data": [
{
"type": 'graph',
"attributes": {
"name": "10_Highest",
"uri": "https://image-charts.com/chart?...."
}
},
{
"type": 'graph',
"attributes": {
"name": "10_Lowest",
"uri": "https://image-charts.com/chart?...."
}
}
]
}
GET /users/:id/foods
Returns an ordered, paginated list of foods for a user ranked top to bottom by user rating.
Optional parameters { method: method }
under construction.
Example JSON response:
{
"data": [
{
"id": "1",
"type": "food_entry",
"attributes": {
"name": "Avocado",
"average_rank": 8.5
}
},
{
"id": "8",
"type": "food_entry",
"attributes": {
"name": "Chocolate",
"average_rank": 8.3
}
}
]
}
POST /users/:id/meals
Adds a new meal to meals table
Requires the following JSON format:
{
"data": {
"attributes": {
"name": "Spaghetti",
"meal_time": "2012-03-05, 00:00:00",
"foods": [
{
"food_name": "pasta",
"food_id": 1234
},
{
"food_name": "sauce",
"food_id": 5678
}
]
}
}
}
Example JSON Response:
{
"data": {
"id": "12",
"type": "meal",
"attributes": {
"name": "Spaghetti",
"meal_time": "2012-03-05, 00:00:00",
"rank": -1
},
"relationships": {
"food_entries": {
"data": {
"id": 1
"meal_id": 12
"food_id": 1234
"food_name": "pasta"
},
"id": 1
"meal_id": 12
"food_id": 5678
"food_name": "sauce"
}
}
}
}
}
PATCH /users/:id/meals
Requires the following JSON format:
{
"rank": 7,
"meal_id": 12
}
Response from BE:
{
"data": {
"id": "12",
"type": "meal",
"attributes": {
"name": "Spaghetti",
"meal_time": "2012-03-05, 00:00:00",
"rank": 7
}
}
}
GET /foods/search?query=<QUERY>
Example JSON response:
{
"data": [
{
"id": "food_98u23mokdjfkbqkjsdfjk",
"type": "food",
"attributes": {
"name": "Avocado"
}
},
{
"id": "food_lkjasdf908uw3rkjbasfkh",
"type": "food",
"attributes": {
"name": "Avocado",
}
}
]
}
GET /users
Requires the following JSON format:
{
email: <EMAIL>
name: <NAME>
access_token: <TOKEN>
}
Example JSON response:
{
"data": {
"id": "1",
"type": "user",
"attributes": {
"name": "Donald Duck"
}
}
}
- Ruby 2.7.2
- Rails 5.2.5