Skip to content

Repository files navigation

RecipesWebProject

A Simple Web Service to create and save recipes. Made using SpringBoot for the backend and Angular for the frontend

Database

The database is written in MySQL and is formed by three tables:

  • recipes with attributes:
    • id (primary key)
    • title
    • date_of_creation (datetime)
    • serving
    • description (nullable)
    • time
    • difficulty (enum)
    • photo (nullable, LONGTEXT to save the base64 string of the image)
  • ingredients with attributes:
    • id (primary key)
    • name
    • quantity
    • unit_of_measurement
    • recipe_id (foreign key, relationship N:1 with recipes)
  • steps with attributes:
    • id (primary key)
    • step_number (must be unique in the same recipe)
    • title
    • description
    • recipe_id (foreign key, relationship N:1 with recipes)

Backend (REST API)

RecipesStorage - RESTapi This is a REST API to manage a storage of recipes. It is written in Java using Spring Boot and Spring Data JPA and is available ad http://localhost:8080
The API allows to make the following CRUD calls (the results are in JSON format)
All of the values are validated before saving them in the database. If a value is not valid, the API returns an error message (tipically an error 400: bad requests, or 404: not found).

A post request for a recipe must specify: {
"title": "YourRecipeTitle",
"serving": servingNumber,
"time": timeInMinutes,
"difficulty": "Easy or Medium or Hard",
}

A post request for a recipe can also specify {
"description": "YourRecipeDescription",
"photo": "YourRecipePhotoBase64String"
}

A post request for an ingredient must specify {
"name": "YourIngredientName",
"quantity": ingredientQuantity,
"unitOfMeasurement": "YourUnitOfMeasurement"
}

A post request for the step must specify {
"stepNumber": stepNumber,
"title": "YourStepTitle",
"description": "YourStepDescription"
}


Most important files of the application:

  • RecipeStorageApplication.java: the main class of the application
  • Entities: the classes that represent the entities of the database
  • Repositories: the interfaces that extend the JpaRepository interface (provided by Spring Data JPA) and allow to make CRUD calls
  • Controllers: the classes that manage the requests and the responses
  • httpRequests: used to test the API with multiple calls

Frontend (Angular)

The frontend is made in Angular, it can be started with 'ng serve' and is available ad http://localhost:4200

About

A Simple Web Service to create and save recipes. Made with SpringBoot as a backend and Angular for the frontend

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages