A RESTful API for task management, developed with Ruby on Rails, that allows each user to manage their activities independently.
- Docker and Docker Compose
- Postman
In the project root, copy or move the .env_sample file to .env. The variables it contains are:
APPLICATION_NAME="task_manager"
MYSQL_HOST_APP="db-app"
MYSQL_HOST_TEST="db-test"
MYSQL_USER="task_manager"
MYSQL_PASSWORD="password"
MYSQL_PORT="3306"
MYSQL_ROOT_PASSWORD="password"
RAILS_ENV="development"
RAILS_MASTER_KEY="6d93e4e8e4ec7e2d1b4128651a19d619" ## this is an example, don't user it in production please see https://rubyonrails.org/docs
SECRET_KEY_BASE="f2e4f2a4bd502d7a74342e95826cd37b72cca93b23bed1330d556bb0e63d0e506c2bbcb17d7f3a653339d93c37ecb2f4e2617b65772ee0e957b50a97d26224ff" ## this is an example, don't user it in production please see https://rubyonrails.org/docsAfter this procedure, the application will be served locally at: http://localhost:3000
- Clone the repository:
git clone https://github.com/DomeCaiazza/task-manager-api.git
cd task-manager-api-
Create the
.envenvironment variables file as shown above -
Start Docker containers:
docker-compose up --build -d && docker-compose logs -tf- (Optional) In a new terminal, run database migrations: PS: database creation and migration is automatically performed by the "entrypoint.dev.sh" file
docker-compose exec web-app bundle exec rails db:create db:migrate- (Optional) Populate the database with sample data:
docker-compose exec web-app bundle exec rails db:seedDevelopment and test databases are separate, in docker-compose two distinct services are defined, the test database is mounted in RAM to improve performance.
To run the tests:
docker-compose exec web-app bundle exec rspecThe OpenAPI documentation is automatically generated during container startup through the entrypoint script. You can access the interactive documentation at:
http://localhost:3000/api-docs/index.html
This documentation provides a description of all available endpoints, including required parameters, expected responses, and usage examples.
To test this application, import the file https://raw.githubusercontent.com/DomeCaiazza/task-manager-api/refs/heads/main/task-manager-api.postman_collection.json into your Postman
The environment variables are defined within the collection.
In the "task-manager-api" collection, the "token" variable is defined which should be populated with the response token after authentication from the /users/tokens/sign_in route
- POST
/users/tokens/sign_in- Login - POST
/users/tokens/sign_up- Registration - POST
/users/tokens/revoke- Revoke token - GET
/users/tokens/info- User info
- GET
/api/v1/tasks- List tasks - GET
/api/v1/tasks/:id- Task details - POST
/api/v1/tasks- Create a new task - PUT/PATCH
/api/v1/tasks/:id- Update a task - DELETE
/api/v1/tasks/:id- Delete a task
title(string, required)description(text)completed(boolean)
The task list endpoint allows filtering results by all its parameters, available filters are:
- completed_eq: completion equals "true" or "false"
- title_cont: title contains
- description_cont: description contains
- title_or_description_cont: title or description contains
app/controllers/api/v1/- API Controllersapp/models/- Modelsspec/- RSpec Tests
- Start the server:
docker-compose up- Run migrations:
docker-compose exec web-app bundle exec rails db:migrate- Open Rails console:
docker-compose exec web-app bundle exec rails console- Check docker compose logs in real-time:
docker-compose logs -tf- Generate open api documentation (doesn't work in production environment)
docker-compose exec web-app rake rswag:specs:swaggerize- The API uses Devise API for authentication
- All API requests, except registration and login, require authentication
- Passwords are validated with a minimum of 6 characters