Skip to content

Architecture Page

mtdang edited this page Oct 19, 2018 · 8 revisions

The purpose of the Architecture Page is to define the processes and components of the system and how they will all connect.

Foodora Architecture

We are using Docker and NPM (Node Package Manager) for dependency management. On the database front, we will be using Mon 3.4.

This application will be a native application that will be created Android and iOS.

Code Structure

Code Structure

There are 4 main sourcefile directories in this project:

  • Routes
    • Route files defines the http interface of the backend, specifying what endpoints are available with the url and the http methods associated to each endpoint.
  • Controllers
    • Controller files define the application logic of the backend. Functions in the controller files processes the input, applies application logic and retrieves information from the Model when necessary. It also generates approrpriate HTTP Responses to the requester.
  • Service
    • Service files contains application logic functions that are shared - authorization for example is specified in an auth service.
  • Model
    • Model files contains database access logic. It contains database queries to allow the controller and service layer to talk to the database.

API Documentation

Get Recommended Recipes Based on RecipeID

  • HTTP Method: Get
  • URL: /recipes/recommend/
  • Response:
    {
          "recipes": [
            "recipe_id_1", 
            "recipe_id_2", 
            "recipe_id_3"
          ]
    }
    

Login

  • HTTP Method: POST
  • URL: /users/login
  • Body:
    {
        "email": "[email protected]",
        "password": "password"
    }
    
  • Response:
    {
         "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJlbWFpbCI6Imt5bG9Aa3lsby5jb20iLCJuYW1lIjpudWxsLCJpYXQiOjE1Mzk5NjI0ODB9.QdgsjfFszOzFOl62FuXZu6rb1WAuGBQZm0mhLTG5-Yk"
    }
    

Add Recipe To Meal Plan

  • HTTP Method: POST
  • URL: /users/meal_plan
  • Body:
    {
        "recipeIds": [ "123454", "234398" ]
    }
    
  • Headers:
    {
        "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJlbWFpbCI6Imt5bG9Aa3lsby5jb20iLCJuYW1lIjpudWxsLCJpYXQiOjE1Mzk5NjI0ODB9.QdgsjfFszOzFOl62FuXZu6rb1WAuGBQZm0mhLTG5-Yk",
        "Content-Type": "application/json"
    }
    

Get User Info

  • HTTP Method: GET
  • URL: /users/user_info
  • Response:
    {
        "email": "[email protected]",
        "name": "person",
        "likedRecipes": [
            "123454",
            "1234154"
        ],
        "foodAllergies": [
            "Peanuts"
        ],
        "mealPlan": [
            "12823",
            "123492"
        ]
    }
    
  • Headers:
    {
        "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJlbWFpbCI6Imt5bG9Aa3lsby5jb20iLCJuYW1lIjpudWxsLCJpYXQiOjE1Mzk5NjI0ODB9.QdgsjfFszOzFOl62FuXZu6rb1WAuGBQZm0mhLTG5-Yk",
        "Content-Type": "application/json"
    }
    

Search

  • HTTP Method: POST
  • URL: /recipes/search
  • Headers:
    {
        "Content-Type": "application/json"
    }
    
  • Body:
    {
        query: {
            $text: {
                  $search: "pork"
            },
            'nutrition.calories.amount': {
                  $lt: 500
            }
        }
    }
    
  • Response:
    {
        body: [
        {
            "_id": "5bca3aeea0bf2f43305617e9",
            "title": "Filipino Lumpia",
            "nutrition": {...},
            "ingredients": [...],
            "servings": 15,
            "prepMinutes": 45,
            "cookMinutes": 25,
            "readyMinutes": -1,
            "imageUrl": "https://images.media-allrecipes.com/userphotos/397715.jpg",
            "id": 35151
        },
        ...
        ]
    }