A simple and secure To-Do List API built with Go and PostgreSQL, featuring JWT authentication, structured logging with Logrus, and database migrations.
- User Authentication — Secure registration and login using JWT.
- Task Management — Create, Read, Update, Delete (CRUD) tasks.
- Protected Routes — Only authenticated users can manage tasks.
- Structured Logging — Logrus integration for better logging.
- Database Migrations — Easy setup for PostgreSQL.
- Go (Golang)
- PostgreSQL
- Logrus (logging)
- JWT (authentication)
- net/http (API routing)
.
├── cmd/api # Application entry point
├── internal
│ ├── config # Configuration management
│ ├── db # Database connection
│ ├── handlers # HTTP handlers for auth & tasks
│ ├── logger # Logrus setup
│ ├── middleware # Logging & authentication middlewares
│ └── models # Data models
├── migrations # SQL migration files
├── go.mod # Go module file
├── go.sum # Dependencies checksum
└── README.md # Documentation
git clone https://github.com/<your-username>/todolist-api.git
cd todolist-apigo mod tidy- Create a database:
createdb todolist- Apply migrations:
psql -U <username> -d todolist -f migrations/001_create_tasks.up.sql
psql -U <username> -d todolist -f migrations/002_create_users_table.up.sqlDB_HOST=localhost
DB_PORT=5432
DB_USER=your_user
DB_PASSWORD=your_password
DB_NAME=todolist
JWT_SECRET=your_secret_key
PORT=8080go run cmd/api/main.goServer will be running at: http://localhost:8080
| Method | Endpoint | Description |
|---|---|---|
| POST | /register | User registration |
| POST | /login | User login |
| Method | Endpoint | Description |
|---|---|---|
| GET | /tasks | Get all tasks |
| POST | /tasks | Create task |
| PUT | /tasks/{id} | Update task |
| DELETE | /tasks/{id} | Delete task |
- Add pagination for tasks list
- Dockerize the application
- Add Swagger API documentation