# README
To-Do List Web Application
Simple web application that allows you to organize your daily tasks effectively. You can add new tasks, mark them as completed or delete them when you no longer need them. Ideal for those who want to keep a clear and accesible control of their to-dos. This application is your personal assistant to keep you focused and organized.
Managing your tasks has never been so easy!
đ¯ Objective
Create a basic To-Do list web application using Go, Dockerize it, and set up multi-container orchestration with Docker Compose.
đ Requirements
-
đĻĢ Go Application
- đ Develop a basic REST API with Go that supports CRUD (Create, Read, Update, Delete) operations for managing to-do items.
- đ Use the Gin framework for HTTP request routing.
-
đŗ Docker
- đ Write a
Dockerfile
to containerize the Go application. - đĻ Use a lightweight base image like
golang:alpine
for building the container. - đ Use a multi-stage build.
- đ Write a
-
đ Docker Compose
- đ Create a
docker-compose.yml
file to define and run a multi-container setup. - The setup should include:
- đĢ Go App Container: Containerize the Go web server.
- đī¸ Database Container: Use a database like PostgreSQL/MySQL, add a container for it.
- đ Expose the necessary ports to access the web application.
- đ Create a
-
⨠Extra Features (Optional)
- đž Use a volume to ensure data persistence for the database container.
- đ Implement a logging mechanism using a Go package to log user interactions.
⥠Quick Setup
You can run the application on your system using Docker Compose after cloning this repository:
git clone https://github.com/franlo42/ToDoListWebApplication.git
cd ToDoListWebApplication
docker compose up --build
đ API Test
We can easily test the web app API functionalities with curl
- đī¸ Obtain the full list of ToDos
curl -X GET http://localhost:8080/todos
- â ī¸ Obtain the list of ToDos pending/completed
curl -X GET http://localhost:8080/todos/status?status=pending
- â Add a new ToDo
curl -X POST http://localhost:8080/todos -H "Content-Type: application/json" -d '{"title": "New Task", "status": "pending"}'
[!IMPORTANT]
The status attribute must be 'pending' or 'completed'.
- đ Update a ToDo by ID
curl -X PUT http://localhost:8080/todos/1 -H "Content-Type: application/json" -d '{"title": "Updated Task", "status": "completed"}'
- âī¸ Check a ToDo by ID
curl -X GET http://localhost:8080/todos/1
- đī¸ Delete a ToDo by ID
curl -X DELETE http://localhost:8080/todos/1
đ Stopping the Application
- Stop containers without deleting data
docker-compose down
- Restart containers with persistent data
docker-compose up
All previous data will still be available
[!TIP] If you want to remove all data and restart fresh:
docker-compose down -v docker-compose up --build
This will delete the volumes and reinitialize the database.