A Go backend application following clean architecture principles with dependency injection.
- Clean architecture with clear separation of concerns
- Dependency injection using fx framework
- HTTP handlers with Gin router
- In-memory data storage (JSON-based)
- Comprehensive testing infrastructure
.
├── cmd/ # Application entry points
├── internal/ # Private application code
│ ├── app/ # Application services
│ └── pkg/ # Shared packages
├── handlers/ # HTTP handlers
├── models/ # Data models and storage
└── server.go # Server setup
- Go 1.23+
- Clone the repository
- Install dependencies:
go mod download
- Run the application:
go run server.go
- The server will start on
http://localhost:3001
GET /health
- Health checkPOST /api/v1/examples/
- Create exampleGET /api/v1/examples/
- Get all examplesGET /api/v1/examples/:id
- Get example by IDPUT /api/v1/examples/:id
- Update exampleDELETE /api/v1/examples/:id
- Delete example
# Run all tests
go test ./...
# Run tests with coverage
go test -cover ./...
# Run specific test
go test ./internal/app/example
This application follows clean architecture principles:
- Handlers - Handle HTTP requests and responses
- Services - Contain business logic
- Models - Handle data storage and retrieval
- Dependency Injection - Manages dependencies using fx
go.uber.org/fx
- Dependency injectiongithub.amrom.workers.dev/gin-gonic/gin
- HTTP routergithub.amrom.workers.dev/samber/lo
- Utility functionsgithub.amrom.workers.dev/stretchr/testify
- Testing utilitiesgithub.amrom.workers.dev/pkg/errors
- Error handlinggithub.amrom.workers.dev/spf13/viper
- Configuration management