This is a Go application developed for a college project made completely by me. It implements an HTTP server that exposes an API for managing categories. The API allows users to create new categories and list all existing categories.
- Create a new category
- List all created categories
- Go (Golang)
- Gin Gonic (web framework)
- JSON for data exchange
- In-Memory Repository (can be replaced with a database)
The application follows a modular structure based on Clean Architecture principles:
📂 cmd/api/ – Contains the main API code, including server initialization and routes.
📂 internal/controllers/ – Controllers responsible for handling HTTP requests.
📂 internal/entities/ – Data model definitions.
📂 internal/repositories/ – Implementation of data storage (In-Memory Repository).
📂 internal/use-cases/ – Business logic for category management.
- Install dependencies:
go mod tidy
- Run the server:
go run cmd/api/main.go
- The server will be running at
http://localhost:8080
GET /healthy
- Response (200 OK):
{ "status": "ok" }
POST /categories
- Request: JSON with the following fields:
{ "name": "Category Name" } - Success Response (201 Created):
{ "categories": [ { "id": 0, "name": "Docker", "created_at": "2025-03-17T02:28:10.9953065-03:00", "updated_at": "2025-03-17T02:28:10.9953065-03:00" } ], "success": true }
GET /categories
- Success Response (200 OK):
[ { "id": 1, "name": "Category 1" }, { "id": 2, "name": "Category 2" } ]
You can test the API using Postman, Insomnia, or directly from the api.http file in VS Code.
If you would like to contribute to the project, feel free to open a Pull Request or report issues in the Issues tab.