An open API service indexing awesome lists of open source software.

https://github.com/samuel-ricardo/nana-manager

Application to Manager nanás
https://github.com/samuel-ricardo/nana-manager

Last synced: 3 months ago
JSON representation

Application to Manager nanás

Awesome Lists containing this project

README

        

# Naná Manager



GFT Java #2 🚀



Application idealized during a Java Bootcamp promoted by @GFT in Partnership With @Digital Inovation One




Project   |   
Technologies   |   
Routes   |   
Run   |  
Author   |   



#



Linkedin



DIO





Spring Rest API for Guaraná flavored Soft Drink (naná) from the Brazilian brand Guaraná Antártica :brazil: , which this year (2021) is celebrating its 100th anniversary and this API is my way of honoring and giving a gift to this company that brings a lot of flavor to Brazilians' tables .

#

Naná or Guaguá is an affectionate way of naming the guarana soda.


This API is hosted on Heroku



#



## :construction: API Routes:

Base URL - /api/v1/nana-manager

- create a naná - POST - /create

- find naná by name - GET - /{name}


- list all nanás - GET - /list-all


- Delete Naná By ID - DELETE - /{id}/delete

- update naná by id - PUT - /{id}/update


- update stock of nana by id - PUT - /{id}/update-stock


All routes have body and request validation, and return a Http Status referring to their situation (success or failure and which one), a Response system was created where an Object is returned - Response < Data > where Data is the type of Data to be returned along with a message and HttpStatus.



#

- Create Body Example

```json

{
"name": "Guarana Antártica 200ml",
"type": "GUARANA",

"nanaType": "GUARANA",

"packing": {
"pack": "Garrafa",
"ml": 200
},

"stock": 150,

"stores":[
{
"name": "Carrefour",
"price": 1.69
}
]
}

```

- List All Nanás Response Example


```json

[
{
"data": {
"id": 1,
"name": "Guarana Antártica 200ml",
"type": "GUARANA",
"nanaType": {
"type": "GUARANA",
"baseNutrients": {
"carbohydrates": 0.1,
"calories": 0.415,
"sugars": 0.1,
"sodium": 0.055,
"ingredients": "Água gaseificada, açúcar, extrato de guaraná, acidulante ácido cítrico, conservadores: benzoato de sódio e sorbato de potássio, aromatizante e corante caramelo.\n\nNão contém glúten."
}
},
"packing": {
"pack": "Garrafa",
"ml": 200
},
"stock": 150,
"stores": [
{
"name": "Carrefour",
"price": 1.69
}
],
"nutrients": {
"carbohydrates": 20,
"calories": 83,
"sugars": 20,
"sodium": 11,
"ingredients": "Água gaseificada, açúcar, extrato de guaraná, acidulante ácido cítrico, conservadores: benzoato de sódio e sorbato de potássio, aromatizante e corante caramelo.\n\nNão contém glúten."
}
},
"message": "The: Guarana Antártica 200ml Found :)",
"status": "FOUND"
}
]

```

#



- Using SOLID more specifically the Single Responsibility Principle, the service layer was created to take care of the logic, while the controller is only responsible for controlling the routes, it was also created a documentation interface for the controller using Swagger.

- The DTO was added one more layer in the Model (Entity), which validates the data, while the Entity is responsible for serving as a Model for the Database, with Mapper being responsible for being the intermediary between them, converting and mapping DTO for Entity and Entity for DTO.

- A package of custom errors and exceptions was developed to meet the needs of the app.



#

## :card_index_dividers: Data Registered By API:

- Name

- __Type__ - (GUARAN | NO_SUGAR | NATU)
> name to mark the type, such as a tag

- __NanaType__ - Stores data related to the type, such as the amount of nutrients
> (an example is the one without sugar that has 0 sugar)

- __NanaPacking__
> the soft drink packaging / container, stores information such as the type of packaging (like plastic) and the size in milliliters

- __stock__

- __Stores__
> List of stores that sell this guaraná and the price in each store, next to the store name




__* NOTE__ - the getNutrients() method calculates in real time and returns the amount of nutrients equivalent to the type of guarana, ingredients and the amount (ml) in the package.

__* NOTE__ - The Nutrients Class has information on carbohydrates, calories, sugars, sodium and ingrdients, except for the sodium that returns in milligrams, all return in grams.

#

Controller and Service are 100% covered by unit testing ensuring API robustness.

During the Tests some classes were created to help the development, such as NanaFactory that builds predefined models and DTO's and an Object to String converter formatted in Json.

Mockito, hamcrest and JUnit were used for the tests


#





This API is hosted on Heroku



#







🚀 Main Technologies and Concepts Studieds:

## Java Development Kit

    Is the Development Kit for Java Developers with all that be need to programming and run any java applications.


- Most Recent
>

- x86 (32bits) Most Recent
>




    Spring

   

The Spring Framework provides a comprehensive programming and configuration model for modern Java-based enterprise applications - on any kind of deployment platform.


- Spring Framework
>

- Spring Boot Generate a start spring project with a minimal Spring configuratio
>




##     Apache Maven

Apache Maven is a software project management and comprehension tool. Based on the concept of a project object model (POM), Maven can manage a project's build, reporting and documentation from a central piece of information.


- Maven
>

#

- [MapStruct](https://mapstruct.org/)
- [TomCat Server](https://tomcat.apache.org/)
- [H2 Database](https://github.com/h2database/h2database)
- [Lombok](https://projectlombok.org/setup/maven)
- [Swagger](https://swagger.io/)
- [JUnit](https://junit.org/junit5/)
- [Hamcrest](http://hamcrest.org/JavaHamcrest/)

#


:zap: Run Project

## :electron: Start Application

### Open Your Git Terminal and Clone This Repositore:

``` git

$ git clone "https://github.com/Samuel-Ricardo/Nana-Manager/"

```

### Make pull:

``` git

$ git pull "https://github.com/Samuel-Ricardo/Nana-Manager/"

```

### Run Application With Maven

``` cmd

$ mvn spring-boot:run

```

### To Run Tests

``` cmd

$ mvn clean test

```

-

Now Your server is running in localhost:8080

-

If you want see details of your application database, access the H2 Database: localhost:8080/h2-console









:octocat: Author



Samuel Ricardo