Skip to content

LuizFerK/Rockelivery

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

67 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation


Logo

Rockelivery

Author Languages Stars Forks Contributors

Order your favorite dish in no time!
Created with Elixir and Phoenix.
Made with ❀️


πŸ“Œ Contents

πŸš€ Features

  • Create, delete and updates users
  • Sign-in with JWT authentication
  • Create, delete and updates items
  • Create orders from your favorite dishes
  • Delete and update orders
  • Generate an Orders Report for every hour to keep in track with your application

πŸ”§ Installation

Required ⚠️

  • Elixir
  • Erlang
  • Phoenix
  • Postgres database

SSH

SSH URLs provide access to a Git repository via SSH, a secure protocol. If you have an SSH key registered in your GitHub account, clone the project using this command:

git clone [email protected]:LuizFerK/Rockelivery.git

HTTPS

In case you don't have an SSH key on your GitHub account, you can clone the project using the HTTPS URL, run this command:

git clone https://github.com/LuizFerK/Rockelivery.git

Both of these commands will generate a folder called Rockelivery, with all the project

πŸ’‘ Getting started

  1. Run mix deps.get to install the dependencies
  2. Create a postgres database named rockelivery
  3. On the config/dev.exs and config/test.exs files, change your postgres user and password
  4. Run mix ecto.migrate to run the migrations to your database
  5. Run mix phx.server to start the server on port 4000

🚩 Endpoints

All the endpoints except for the user's creation and sign-in are protected with JWT authentication. You'll need to pass a valid token from an existent user in every route as a Bearer Token authentication. You can get the token by signing in to the app on the users sign in route

If you use Insomnia as your HTTP API requester, you can use the Insomnia Rockelivery Collection to set up your requests as fast as possible!

Users

  • 🟒 Create - POST http://localhost:4000/api/users

    • Request

       {
         "address": "Random street, 10",
         "age": 18,
         "cep": "01001000",
         "cpf": "12345678900",
         "email": "[email protected]",
         "name": "John Doe",
         "password": "123456"
       }
    • Response - 201 Created

       {
         "token": "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpX...",
         "user": {
           "age": 18,
           "address": "Random street, 10",
           "cep": "01001000",
           "cpf": "12345678900",
           "email": "[email protected]",
           "name": "John Doe",
           "id": "85703d30-c42f-43fb-b2df-3a7ffd70803e"
         }
       }
  • πŸ”΄ Delete - DELETE http://localhost:4000/api/users/<user_id> Response - 204 No Content

  • 🟣 Get - GET http://localhost:4000/api/users/<user_id>

    • Response - 200 Ok

       {
         "token": "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpX...",
         "user": {
           "age": 18,
           "address": "Random street, 10",
           "cep": "01001000",
           "cpf": "12345678900",
           "email": "[email protected]",
           "name": "John Doe",
           "id": "85703d30-c42f-43fb-b2df-3a7ffd70803e"
         }
       }
  • 🟑 Update - PUT http://localhost:4000/api/users/<user_id>

    • Request:

       {
         "address": "Random street, 10",
         "age": 18,
         "cep": "01001000",
         "cpf": "12345678901",
         "email": "[email protected]",
         "name": "John Doe",
         "password": "123456"
       }
    • Response - 200 Ok

       {
         "token": "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpX...",
         "user": {
           "age": 18,
           "address": "Random street, 10",
           "cep": "01001000",
           "cpf": "12345678901",
           "email": "[email protected]",
           "name": "John Doe",
           "id": "85703d30-c42f-43fb-b2df-3a7ffd70803e"
         }
       }
  • βšͺ Sign In - POST http://localhost:4000/api/users/signin

    • Request:

       {
         "id": "85703d30-c42f-43fb-b2df-3a7ffd70803e",
         "password": "123456"
       }
    • Response - 200 Ok

       {
         "token": "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpX..."
       }
  • ⚫ List - GET http://localhost:4000/api/users/list

    • Response - 200 Ok

       [
         {
           "age": 18,
           "address": "Random street, 10",
           "cep": "01001000",
           "cpf": "12345678900",
           "email": "[email protected]",
           "name": "John Doe",
           "id": "dab3d875-13ad-4477-982a-1fcbdb57ef58"
         },
         {
           "age": 18,
           "address": "Random street, 10",
           "cep": "01001000",
           "cpf": "12345678901",
           "email": "[email protected]",
           "name": "John Doe",
           "id": "dab3d875-13ad-4477-982a-1fcbdb57ef58"
         }
       ]

Items

  • 🟒 Create - POST http://localhost:4000/api/items

    • Request

       {
         "category": "food", // "food", "drink" or "desert"
         "description": "Chocolate Pizza",
         "price": "50.20",
         "photo": "/priv/chocolate_pizza.jpg"
       }
    • Response - 201 Created

       {
         "category": "food",
         "description": "Chocolate Pizza",
         "price": "50.20",
         "photo": "/priv/chocolate_pizza.jpg",
         "id": "45a62ca7-0487-4f10-a481-52c48e0757f3"
       }
  • πŸ”΄ Delete - DELETE http://localhost:4000/api/items/<item_id> Response - 204 No Content

  • 🟣 Get - GET http://localhost:4000/api/items/<item_id>

    • Response - 200 Ok

       {
         "category": "food",
         "description": "Chocolate Pizza",
         "price": "50.20",
         "photo": "/priv/chocolate_pizza.jpg",
         "id": "45a62ca7-0487-4f10-a481-52c48e0757f3"
       }
  • 🟑 Update - PUT http://localhost:4000/api/items/<item_id>

    • Request

       {
         "category": "drink",
         "description": "Chocolate Milk",
         "price": "8.90",
         "photo": "/priv/chocolate_milk.jpg"
       }
    • Response - 200 Ok

       {
         "category": "drink",
         "description": "Chocolate Milk",
         "price": "8.90",
         "photo": "/priv/chocolate_milk.jpg",
         "id": "45a62ca7-0487-4f10-a481-52c48e0757f3"
       }
  • ⚫ List - GET http://localhost:4000/api/items/list

    • Response - 200 Ok

       [
         {
           "category": "food",
           "description": "Chocolate Pizza",
           "price": "52.20",
           "photo": "/priv/chocolate_pizza.jpg",
           "id": "45a62ca7-0487-4f10-a481-52c48e0757f3"
         },
         {
           "category": "drink",
           "description": "Chocolate Milk",
           "price": "8.90",
           "photo": "/priv/chocolate_milk.jpg",
           "id": "f1029e90-e582-4820-ad3e-aba04add5427"
         }
       ]

Orders

  • 🟒 Create - POST http://localhost:4000/api/orders

    • Request

       {
         "user_id": "85703d30-c42f-43fb-b2df-3a7ffd70803e",
         "items": [
           {
             "id": "45a62ca7-0487-4f10-a481-52c48e0757f3",
             "quantity": 2
           },
           {
             "id": "f1029e90-e582-4820-ad3e-aba04add5427",
              "quantity": 1
           }
         ],
         "address": "Random Street, 10",
         "comments": "Extra cheese",
         "payment_method": "credit_card" // "credit_card", "debit_card" or "money"
       }
    • Response - 201 Created

       {
         "address": "Random Street, 10",
         "comments": "Extra cheese",
         "payment_method": "credit_card",
         "user_id": "85703d30-c42f-43fb-b2df-3a7ffd70803e",
         "id": "0b2e9884-c88b-4593-b374-ee6ae6ead48d",
         "user": {
           "age": 18,
           "address": "Random street, 10",
           "cep": "01001000",
           "cpf": "12345678900",
           "email": "[email protected]",
           "name": "John Doe",
           "id": "85703d30-c42f-43fb-b2df-3a7ffd70803e"
         },
         "items": [
           {
             "category": "food",
             "description": "Chocolate Pizza",
             "price": "52.20",
             "photo": "/priv/chocolate_pizza.jpg",
             "id": "45a62ca7-0487-4f10-a481-52c48e0757f3"
           },
           {
             "category": "food",
             "description": "Chocolate Pizza",
             "price": "52.20",
             "photo": "/priv/chocolate_pizza.jpg",
             "id": "45a62ca7-0487-4f10-a481-52c48e0757f3"
           },
           {
             "category": "drink",
             "description": "Chocolate Milk",
             "price": "8.90",
             "photo": "/priv/chocolate_milk.jpg",
             "id": "f1029e90-e582-4820-ad3e-aba04add5427"
           }
         ]
       }
  • πŸ”΄ Delete - DELETE http://localhost:4000/api/orders/<order_id> Response - 204 No Content

  • 🟣 Get - GET http://localhost:4000/api/orders/<order_id>

    • Response - 200 Ok

       {
         "address": "Random Street, 10",
         "comments": "Extra cheese",
         "payment_method": "credit_card",
         "user_id": "85703d30-c42f-43fb-b2df-3a7ffd70803e",
         "id": "0b2e9884-c88b-4593-b374-ee6ae6ead48d",
         "user": {
           "age": 18,
           "address": "Random street, 10",
           "cep": "01001000",
           "cpf": "12345678900",
           "email": "[email protected]",
           "name": "John Doe",
           "id": "85703d30-c42f-43fb-b2df-3a7ffd70803e"
         },
         "items": [
           {
             "category": "food",
             "description": "Chocolate Pizza",
             "price": "52.20",
             "photo": "/priv/chocolate_pizza.jpg",
             "id": "45a62ca7-0487-4f10-a481-52c48e0757f3"
           },
           {
             "category": "food",
             "description": "Chocolate Pizza",
             "price": "52.20",
             "photo": "/priv/chocolate_pizza.jpg",
             "id": "45a62ca7-0487-4f10-a481-52c48e0757f3"
           },
           {
             "category": "drink",
             "description": "Chocolate Milk",
             "price": "8.90",
             "photo": "/priv/chocolate_milk.jpg",
             "id": "f1029e90-e582-4820-ad3e-aba04add5427"
           }
         ]
       }
  • 🟑 Update - PUT http://localhost:4000/api/orders/<order_id>

    • Request

       {
         "user_id": "85703d30-c42f-43fb-b2df-3a7ffd70803e",
         "items": [
           {
             "id": "45a62ca7-0487-4f10-a481-52c48e0757f3",
             "quantity": 2
           },
           {
             "id": "f1029e90-e582-4820-ad3e-aba04add5427",
              "quantity": 1
           }
         ],
         "address": "Random Street, 10",
         "comments": "Extra chocolate",
         "payment_method": "money"
       }
    • Response - 201 Created

       {
         "address": "Random Street, 10",
         "comments": "Extra chocolate",
         "payment_method": "money",
         "user_id": "85703d30-c42f-43fb-b2df-3a7ffd70803e",
         "id": "0b2e9884-c88b-4593-b374-ee6ae6ead48d",
         "user": {
           "age": 18,
           "address": "Random street, 10",
           "cep": "01001000",
           "cpf": "12345678900",
           "email": "[email protected]",
           "name": "John Doe",
           "id": "85703d30-c42f-43fb-b2df-3a7ffd70803e"
         },
         "items": [
           {
             "category": "food",
             "description": "Chocolate Pizza",
             "price": "52.20",
             "photo": "/priv/chocolate_pizza.jpg",
             "id": "45a62ca7-0487-4f10-a481-52c48e0757f3"
           },
           {
             "category": "food",
             "description": "Chocolate Pizza",
             "price": "52.20",
             "photo": "/priv/chocolate_pizza.jpg",
             "id": "45a62ca7-0487-4f10-a481-52c48e0757f3"
           },
           {
             "category": "drink",
             "description": "Chocolate Milk",
             "price": "8.90",
             "photo": "/priv/chocolate_milk.jpg",
             "id": "f1029e90-e582-4820-ad3e-aba04add5427"
           }
         ]
       }
  • ⚫ List - GET http://localhost:4000/api/items/list

    • Response - 200 Ok

       [
         {
           "address": "Random Street, 10",
           "comments": "Extra cheese",
           "payment_method": "credit_card",
           "user_id": "85703d30-c42f-43fb-b2df-3a7ffd70803e",
           "id": "0b2e9884-c88b-4593-b374-ee6ae6ead48d",
           "user": {
             "age": 18,
             "address": "Random street, 10",
             "cep": "01001000",
             "cpf": "12345678900",
             "email": "[email protected]",
             "name": "John Doe",
             "id": "85703d30-c42f-43fb-b2df-3a7ffd70803e"
           },
           "items": [
             {
               "category": "food",
               "description": "Chocolate Pizza",
               "price": "52.20",
               "photo": "/priv/chocolate_pizza.jpg",
               "id": "45a62ca7-0487-4f10-a481-52c48e0757f3"
             },
             {
               "category": "food",
               "description": "Chocolate Pizza",
               "price": "52.20",
               "photo": "/priv/chocolate_pizza.jpg",
               "id": "45a62ca7-0487-4f10-a481-52c48e0757f3"
             },
             {
               "category": "drink",
               "description": "Chocolate Milk",
               "price": "8.90",
               "photo": "/priv/chocolate_milk.jpg",
               "id": "f1029e90-e582-4820-ad3e-aba04add5427"
             }
           ]
         },
         {
           "address": "Random Street, 10",
           "comments": "Extra chocolate",
           "payment_method": "money",
           "user_id": "85703d30-c42f-43fb-b2df-3a7ffd70803e",
           "id": "0b2e9884-c88b-4593-b374-ee6ae6ead48d",
           "user": {
             "age": 18,
             "address": "Random street, 10",
             "cep": "01001000",
             "cpf": "12345678900",
             "email": "[email protected]",
             "name": "John Doe",
             "id": "85703d30-c42f-43fb-b2df-3a7ffd70803e"
           },
           "items": [
             {
               "category": "food",
               "description": "Chocolate Pizza",
               "price": "52.20",
               "photo": "/priv/chocolate_pizza.jpg",
               "id": "45a62ca7-0487-4f10-a481-52c48e0757f3"
             },
             {
               "category": "food",
               "description": "Chocolate Pizza",
               "price": "52.20",
               "photo": "/priv/chocolate_pizza.jpg",
               "id": "45a62ca7-0487-4f10-a481-52c48e0757f3"
             },
             {
               "category": "drink",
               "description": "Chocolate Milk",
               "price": "8.90",
               "photo": "/priv/chocolate_milk.jpg",
               "id": "f1029e90-e582-4820-ad3e-aba04add5427"
             }
           ]
         }
       ]

πŸ”₯ Techs

Elixir (language)

Phoenix (web framework)

  • Ecto
  • Elixir GenServer (orders report)
  • Guardian (authentication)
  • PBKDF2 (password cryptography)
  • Tesla (http client to external apis)

πŸ› Issues

Find a bug or error on the project? Please, feel free to send me the issue on the Rockelivery issues area, with a title and a description of your found!

If you know the origin of the error and know how to resolve it, please, send me a pull request, I will love to review it!

πŸ“– License

Released in 2021.

This project is under the MIT license.

< keep coding /> πŸš€ ❀️

About

Order your favorite dish in no time!

Topics

Resources

License

Stars

Watchers

Forks

Languages