From my time as a Hashicorp intern where the I was mentored in go by the talented Johan Brandhorst-Satzkorn
This began using the standard library then as an evolution to teach myself popular libraries, i integrated Gorilla Mux
A production-grade RESTful API server built with Go, implementing modern backend development practices and features. This project represents my first venture into building a production-ready Go server, incorporating essential features for robust API development.
- MVC Architecture: Clean separation of concerns with Models, Controllers, and a structured data store
- PostgreSQL Integration: Robust database integration using a PostgreSQL store
- RESTful Endpoints: Well-structured API endpoints for:
- User management (CRUD operations)
- Todo management
- Authentication: User authentication system with login functionality
- Error Handling: Centralized error handling with proper HTTP status codes
- Middleware Support: Using Gorilla Mux for routing and middleware
- Clean Project Structure:
├── controllers/ # Request handlers and business logic ├── models/ # Data models ├── server/ # Server configuration and setup ├── store/ # Database interactions ├── todos/ # Todo-related functionality ├── users/ # User management functionality └── utils/ # Shared utilities and helpers
- Go (Golang)
- Gorilla Mux (Router)
- PostgreSQL
- JWT for authentication
- Ensure you have Go installed and PostgreSQL running
- Clone the repository
- Set up your PostgreSQL database
- Update the database connection string in
main.go
- Run the server:
The server will start on
go run main.go
localhost:5000
POST /login
- User authenticationGET /users
- Get all usersGET /users/{id}
- Get user by IDPOST /users
- Create new userDELETE /users/{id}
- Delete user
GET /todos
- Get all todosGET /todos/{id}
- Get todo by ID
This project served as an excellent learning experience in:
- Implementing clean architecture in Go
- Setting up proper error handling and response structures
- Working with PostgreSQL in a Go environment
- Building secure authentication systems
- Structuring a production-ready REST API
- Secure password handling
- JWT-based authentication
- Proper error handling to prevent information leakage