- Author
- About MyClimate project
- Built with
- UML class diagram
- API documentation
- Project structure
- How to run the service
- How to execute the tests
- Hours spent
- References
Marc Vivas Baiges
This system allows users to remote managing information related with climate installation homes, sensors and users within a web services system.
The project is built with Laravel 9 which is a php framework.
The API endpoints are documented in a file named api_doc.yaml
. In order to preview
the API endpoints in a friendly UI and interact with it,
open Swagger Editor and import the file.
All endpoints require an authentication token that can only be obtained by logging in or registering a user.
This token must be provided in the header of each request. Example:
Authorization: Bearer 84423094230h3242304230423hk4jh23
In case you have never seen a Laravel project, it can be quite hard to
find the code that really matters.
For this reason, the project structure it's now going to be explained.
Database migrations are located at ./MyClimateAPI/database/migrations
.
- Here you will be able to see which are the tables created and their attributes.
Routes are located at ./MyClimateAPI/routes/api
.
- Here is where the endpoints paths are defined.
- Each route executes a function when it is called. The function is usually a method from a Controller.
Controllers are located at ./MyClimateAPI/app/Http/Controllers
.
- Define the logic of all the endpoints of the application.
Services are located at ./MyClimateAPI/app/Services
.
- Controllers use services to interact with the database.
- Good practice.
Resources are located at ./MyClimateAPI/app/Http/Resources
.
- Resources are used to transform a database model to JSON format.
Requests are located at ./MyClimateAPI/app/Http/Requests
.
- Requests are used to check if the body of a request is correct.
Models are located at ./MyClimateAPI/app/Models
.
- Each database table has a corresponding
Model
that is used to interact with that table.
Tests are located at ./MyClimateAPI/tests/Feature
.
You should have installed docker compose
in your system.
To run only the API you have to insert the following command:
sudo docker compose up MyClimateAPI
Once is running, you can send requests to localhost:8000 to interact with the API. I recommend to use Postman or Swagger to test the API.
A total of 65 tests have also been written. To execute them, the container of the API must be up and running.
Once is running, open another terminal where docker-compose.yml
is located, and insert the following command.
sudo docker compose exec MyClimateAPI php artisan test
- December 2 2022: 16:30 - 19:30 Project planning -> 3 hours
- December 3 2022: 9:00 - 17:30 Project development -> 8.5 hours
- December 4 2022: 8:00 - 15:00 Project development -> 7 hours
- December 5 2022: 16:30 - 19:00 Project development -> 2.5 hours
- December 6 2022: 7:00 - 11:30 Project development -> 4.5 hours
- December 7 2022: 16:00 - 18:00 Project development (Finished all endpoints) -> 2 hours
- December 8 2022: 9:00 - 14:00 Include project 1 -> 5 hours
- December 9 - 11 2022: Documentation -> 8.5 hours
- Total: 41 hours
- API token authentication: https://laravel.com/docs/9.x/sanctum#api-token-authentication