Go Tutorial #25: Building a Microservice — Complete Project
In the previous tutorial, you learned Docker for Go. Now let’s put everything together and build a complete microservice. This is a project tutorial. You will build a notes API from scratch using the skills from the entire series: Gin for routing, PostgreSQL with sqlx for storage, JWT for authentication, validation for input, slog for logging, and Docker for deployment. What We Are Building A notes microservice with these endpoints: Method Path Description Auth POST /api/register Create account No POST /api/login Get JWT token No GET /api/notes List user’s notes Yes POST /api/notes Create a note Yes GET /api/notes/:id Get a note Yes PUT /api/notes/:id Update a note Yes DELETE /api/notes/:id Delete a note Yes GET /health Health check No Project Structure notes-api/ cmd/ server/ main.go # Entry point internal/ handler/ auth.go # Auth handlers (register, login) notes.go # Note CRUD handlers middleware.go # JWT middleware model/ user.go # User struct note.go # Note struct repository/ user.go # User database operations note.go # Note database operations service/ auth.go # Auth business logic go.mod go.sum Dockerfile docker-compose.yml This follows the clean architecture from Go Tutorial #10. ...