Helix est un framework backend Go inspire de Spring Boot, concu pour creer des APIs avec moins de boilerplate tout en restant idiomatique. Il combine injection de dependances, HTTP declaratif, repository generique, configuration centralisee, observabilite, securite, scheduling et CLI de developpement.
Prerequis
- Go 1.21 ou plus recent
- Un module Go applicatif
go version
go mod init example.com/helix-users
go get github.com/enokdev/helixHelix est publie comme module Go. go get github.com/enokdev/helix ajoute le framework a votre go.mod et telecharge les dependances necessaires.
mkdir helix-users && cd helix-users
go mod init example.com/helix-users
go get github.com/enokdev/helixHelix structure un service backend en trois types de composants :
type UserRepository struct{ helix.Repository }
type UserService struct {
helix.Service
Repo *UserRepository `inject:"true"`
}
type UserController struct {
helix.Controller
Service *UserService `inject:"true"`
}
func (c *UserController) Index() []User { return c.Service.Repo.FindAll() }Mode zero-config : si Fiber est dans votre go.mod et que vous avez un config/application.yaml, un simple helix.Run() suffit — le framework detecte les starters, câble les composants et gere le lifecycle HTTP.
func main() {
if err := helix.Run(); err != nil {
log.Fatal(err)
}
}Mode explicite : fournissez vos composants via helix.App{Components: ...} pour un contrôle total.
func main() {
if err := helix.Run(helix.App{
Components: []any{
NewUserRepository(),
&UserService{},
&UserController{},
},
}); err != nil {
log.Fatal(err)
}
}helix.Run gere le cycle de vie complet : demarrage, ecoute de SIGTERM/SIGINT et arret propre.
Consultez examples/crud-api pour un exemple complet ou examples/zero-config pour le mode zero-config.
Une API CRUD users en memoire est disponible dans ce depot :
git clone https://github.com/enokdev/helix.git
cd helix
go run ./examples/crud-apiDans un autre terminal :
curl http://localhost:8080/users
curl -X POST http://localhost:8080/users \
-H 'Content-Type: application/json' \
-d '{"name":"Ada Lovelace","email":"ada@example.com"}'
curl http://localhost:8080/users/1
curl -X PUT http://localhost:8080/users/1 \
-H 'Content-Type: application/json' \
-d '{"name":"Ada Byron","email":"ada.byron@example.com"}'
curl -X DELETE http://localhost:8080/users/1- Injection de dependances via
helix.Service,helix.Controller,helix.Repositoryethelix.Component. - Bootstrap zero-config via
helix.Run(): starters detectes automatiquement (web, security, scheduling) selon les marqueurs de composants etgo.mod. - Bootstrap explicite via
helix.Run(helix.App{Components: ...})pour un controle total. - Resolution DI par reflection par defaut, avec mode wire pour le codegen compile-time.
- Routing HTTP par conventions
Index,Show,Create,Update,Deleteet directives//helix:route. - Binding type des query params et body JSON, validation automatique et mapping retour vers status HTTP.
- Repository generique
data.Repository[T, ID, TX]et adaptateur GORM viadata/gorm.NewRepository. - Tests d'application avec
helix.NewTestApp,helix.GetBean[T]ethelix.MockBean[T]. - Configuration YAML, profils et variables d'environnement avec priorite
ENV > profile > application.yaml > default. - Endpoints d'observabilite
/actuator/health,/actuator/metricset/actuator/info. - Securite JWT/RBAC, guards declaratifs, scheduling cron et CLI
helix.
- API CRUD users : service, repository en memoire, controller declaratif et lifecycle HTTP geré par le starter web.
- API securisee JWT/RBAC : authentification JWT, guards RBAC declaratifs et configuration globale de securite.
- Zero-config :
helix.Run()sans argument — le framework detecte et configure tout automatiquement.
Commandes utiles :
go run ./examples/crud-api
go run ./examples/secured-api
go run ./examples/zero-config
go test ./...Pour contribuer a Helix lui-meme :
git clone https://github.com/enokdev/helix.git
cd helix
go mod tidy
go test ./...
go build ./...Avant d'ouvrir une pull request :
golangci-lint runSi golangci-lint n'est pas installe localement, lancez au minimum :
go vet ./...MIT - voir LICENSE.