Order your favorite dish in no time!
Created with Elixir and Phoenix.
Made with β€οΈ
- 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
- Elixir
- Erlang
- Phoenix
- Postgres database
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
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
- Run
mix deps.get
to install the dependencies - Create a postgres database named
rockelivery
- On the
config/dev.exs
andconfig/test.exs
files, change your postgres user and password - Run
mix ecto.migrate
to run the migrations to your database - Run
mix phx.server
to start the server on port 4000
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!
-
π’ 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" } ]
-
-
π’ 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" } ]
-
-
π’ 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" } ] } ]
-
- Ecto
- Elixir GenServer (orders report)
- Guardian (authentication)
- PBKDF2 (password cryptography)
- Tesla (http client to external apis)
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!
Released in 2021.
This project is under the MIT license.
< keep coding /> π β€οΈ