This is a simple to-do list app that allows users to create, read, update, and delete tasks (CRUD).
- Create todo list entries
- Update todo list entries
- Delete todo list entries
- Get a todo list entry by ID
- Get all todo list entries
- Mark a todo list entry as completed
- Go
- Fiber
- GORM
- MySQL
- Swaggo
-
Clone the repository:
git clone https://github.com/username/todo-app.git cd todo-app
-
Configure the database: Rename
.env.example
to.env
and configure your database settings. -
Build and start the application using Docker Compose:
docker compose build docker compose up
-
Access Swagger documentation: Open your browser and navigate to
http://localhost:3000/swagger/index.html
to view the API documentation.
POST /todos
- Create a new todo listGET /todos/{id}
- Get a todo list by IDGET /todos
- Get all todo listsPUT /todos/{id}
- Update a todo list by IDDELETE /todos/{id}
- Delete a todo list by IDPATCH /todos/{id}/completed
- Mark a todo list as completed
main.go
- The application's entry pointmodels/
- Data structures for todo listshandlers/
- Handlers for the endpointsdatabase/
- Database configurationtypes/
- Data structures for error responses and othersdocs/
- Swagger documentation
CREATE DATABASE IF NOT EXISTS todoapp;
USE todoapp;
CREATE TABLE IF NOT EXISTS todos (
id INT AUTO_INCREMENT PRIMARY KEY,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
deleted_at TIMESTAMP NULL DEFAULT NULL,
title VARCHAR(255) NOT NULL UNIQUE,
tasks TEXT,
completed BOOLEAN DEFAULT FALSE,
deleted BOOLEAN DEFAULT FALSE
);
todo-app/
│
├── database/
│ └── database.go
│
├── docs/
│ └── swagger files
│
├── handlers/
│ └── todoHandler.go
│
├── models/
│ └── todo.go
|
├── routes/
│ └── todoRoutes.go
│
├── types/
│ └── error_response.go
│ └── payload.go
│
├── .env
├── .env.example
├── .air.toml
├── .gitignore
├── go.mod
├── go.sum
├── main.go
├── README.md
└── schema.sql