A minimal modkit example with no external dependencies (no Docker, no database).
- Target modkit line:
v0.x(see root stability policy) - Audience: first-time evaluators who want a sub-5-minute run
- Understand module definition shape (
Name,Providers,Controllers) - See provider resolution and singleton behavior
- Verify route registration and bootstrap flow quickly
- Single module with providers and a controller
- Dependency injection via token resolution
- HTTP route registration
- Stateful singleton provider (counter)
go run main.godocker compose up -d --build
curl http://localhost:8080/health
curl http://localhost:8080/greet
docker compose down -vPrint the module graph while starting the server:
go run main.go --graph-format mermaid
go run main.go --graph-format dotExample Mermaid output:
graph TD
m0["app"]
classDef root stroke-width:3px;
class m0 root;
Example DOT output:
digraph modkit {
rankdir=LR;
"app";
"app" [shape=doublecircle];
}
# Health check
curl http://localhost:8080/health
# {"status":"ok"}
# Greeting (counter increments each call)
curl http://localhost:8080/greet
# {"count":1,"message":"Hello from modkit!"}
curl http://localhost:8080/greet
# {"count":2,"message":"Hello from modkit!"}hello-simple/
└── main.go # Everything in one file for simplicity
func (m *AppModule) Definition() module.ModuleDef {
return module.ModuleDef{
Name: "app",
Providers: []module.ProviderDef{...},
Controllers: []module.ControllerDef{...},
}
}Build: func(r module.Resolver) (any, error) {
msg, err := r.Get(TokenGreeting)
if err != nil {
return nil, err
}
return &Controller{message: msg.(string)}, nil
}func (c *GreetingController) RegisterRoutes(r mkhttp.Router) {
r.Handle(http.MethodGet, "/greet", http.HandlerFunc(c.Greet))
}- See hello-mysql for a full CRUD example with database
- Read the Getting Started Guide
- Explore Modules for multi-module apps