Skip to content

shohratd15/todolist-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

📋 todolist-api

Go Version License Build Status PostgreSQL

A simple and secure To-Do List API built with Go and PostgreSQL, featuring JWT authentication, structured logging with Logrus, and database migrations.

🚀 Features

  • 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.

🛠 Tech Stack

  • Go (Golang)
  • PostgreSQL
  • Logrus (logging)
  • JWT (authentication)
  • net/http (API routing)

📂 Project Structure

.
├── 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

⚡ Installation & Setup

1️⃣ Clone the repository

git clone https://github.com/<your-username>/todolist-api.git
cd todolist-api

2️⃣ Install dependencies

go mod tidy

3️⃣ Setup PostgreSQL

  • 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.sql

4️⃣ Create .env file

DB_HOST=localhost
DB_PORT=5432
DB_USER=your_user
DB_PASSWORD=your_password
DB_NAME=todolist
JWT_SECRET=your_secret_key
PORT=8080

5️⃣ Run the application

go run cmd/api/main.go

Server will be running at: http://localhost:8080

📌 API Endpoints

Public Routes

Method Endpoint Description
POST /register User registration
POST /login User login

Protected Routes (JWT required)

Method Endpoint Description
GET /tasks Get all tasks
POST /tasks Create task
PUT /tasks/{id} Update task
DELETE /tasks/{id} Delete task

💡 Future Improvements

  • Add pagination for tasks list
  • Dockerize the application
  • Add Swagger API documentation

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages