GourseAPI is a Go-based application implementing Hexagonal Architecture, following best design practices for separation of concerns. It leverages an Event and Command Bus to manage use cases in a decoupled and scalable manner.
- Hexagonal Architecture: Utilizes the ports and adapters pattern to maintain a clean and independent domain.
- Event & Command Bus: Implements internal messaging to efficiently handle events and commands.
- MySQL Persistence: Decoupled repository layer using MySQL as the data store.
- Gin Framework: High-performance HTTP request handling with Gin.
- Docker-ready: Seamless setup and deployment with Docker integration.
- Middleware & Validations: Custom middleware and domain validations to ensure data integrity.
- Testing: Includes unit and integration tests to ensure code quality.
- Go v1.15+
- MySQL (see details below).
The project is structured as a single Go module containing multiple applications. Each folder represents an independently executable application. Some of the core functionalities include:
- HTTP Endpoints: RESTful routes implemented with Gin.
- Dependency Injection: Decoupled repositories for business logic separation.
- Domain Validations: Enforces business rules before data persistence.
- Domain Event Publishing: Enables system extensibility via event-driven architecture.
- Middleware & Error Handling: Implements middleware for logging, authentication, and error recovery.
- Docker Deployment: Optimized containerized deployment.
1- Clone the repository:
git clone https://github.com/yebrai/GourseAPI.git
2- Give up docker:
docker-compose up --build
To run all tests:
go test ./...
You can debug from logs:
docker-compose logs -f mooc-api
curl -X GET http://localhost:8080/courses
curl -X POST http://localhost:8080/courses -H "Content-Type: application/json" -d '{
"ID": "8a1c5cdc-ba57-445a-994d-aa412d23724f",
"Name": "Demo Course",
"Duration": "10 months"
}'
curl -X GET http://localhost:8080/health
This project was developed following the teachings of the CodelyTV course and the valuable insights shared by Friends of Go. We are grateful to both communities for their contributions to the Go ecosystem and for fostering knowledge-sharing within the developer community.