Skip to content

Task API

Build a complete REST API from scratch using MinStack. By the end you'll have a running service with user registration, JWT authentication, and full task CRUD — all organised with the domain structure pattern.

What you'll build

A Task API with three domains:

DomainResponsibility
usersRegister an account, fetch your profile
authnLogin and receive a JWT
tasksCreate, list, update, and delete your tasks

Routes

MethodPathAuthDescription
POST/api/users/registerCreate account
GET/api/users/meJWTGet current user
POST/api/auth/loginLogin, receive JWT
GET/api/tasksJWTList your tasks
POST/api/tasksJWTCreate a task
GET/api/tasks/:idJWTGet a task
PATCH/api/tasks/:idJWTUpdate a task
DELETE/api/tasks/:idJWTDelete a task

Final folder layout

task-api/
├── cmd/
│   └── main.go
├── internal/
│   ├── users/
│   │   ├── entities/user.entity.go
│   │   ├── repositories/user.repository.go
│   │   ├── dto/
│   │   │   ├── user.dto.go
│   │   │   ├── register.dto.go
│   │   │   └── login.dto.go
│   │   ├── user.service.go
│   │   ├── user.controller.go
│   │   ├── user.routes.go
│   │   └── module.go
│   ├── authn/
│   │   ├── dto/token.dto.go
│   │   ├── auth.service.go
│   │   ├── auth.controller.go
│   │   ├── auth.routes.go
│   │   └── module.go
│   └── tasks/
│       ├── entities/task.entity.go
│       ├── repositories/task.repository.go
│       ├── dto/
│       │   ├── task.dto.go
│       │   ├── create_task.dto.go
│       │   └── update_task.dto.go
│       ├── task.service.go
│       ├── task.controller.go
│       ├── task.routes.go
│       └── module.go
├── go.mod
└── .env

Steps

  1. Project Setupgo.mod, .env, directory scaffold
  2. Users domain — entity, repository, DTOs, service, controller, routes, module
  3. Auth domain — login service, controller, routes, module
  4. Tasks domain — entity, repository, DTOs, service, controller, routes, module
  5. Bootstrap — wiring everything in main.go and running the app