Skip to content

StevenMartinez94/todo-echo-gorm

Repository files navigation

Go To-Do List API

A simple RESTful To-Do List API built with Go, using MySQL for persistence.

Features

  • CRUD operations for tasks
  • MySQL database integration
  • RESTful API design
  • Docker & Docker Compose support
  • Environment variable configuration

Project Structure

cmd/server/main.go        # Application entrypoint
internal/db/db.go         # Database connection logic
internal/routes/routes.go # API route definitions
internal/task/model.go    # Task model definition
internal/task/handlers.go # Task handler functions

Getting Started

Prerequisites

Environment Variables

Copy .env.example to .env and adjust as needed:

cp .env.example .env

Running with Docker Compose

Start the API and MySQL database:

docker-compose up --build

Building & Running Locally (without Docker)

  1. Ensure MySQL is running and matches your .env config.
  2. Build and run the server:
    go build -o server ./cmd/server
    ./server

API Endpoints

Method Endpoint Description
GET api/v1/tasks List all tasks
POST api/v1/tasks Create a new task
GET api/v1/tasks/{id} Get a task by ID
PUT api/v1/tasks/{id} Update a task
DELETE api/v1/tasks/{id} Delete a task

Database

  • MySQL database is automatically created by Docker Compose.
  • Data is persisted in a Docker volume (db_data).

Development

  • Code is organized using Go modules.
  • Main application entry: cmd/server/main.go
  • Business logic and handlers: internal/

Useful Commands

  • Format code: go fmt ./...
  • Tidy modules: go mod tidy
  • Run tests: go test ./...

About

Test TODO project for practicing GO + GORM + Echo

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors