Concepts
Module System
How Redelay's plugin-based module system works in Go and Python.
Every feature in Redelay — events, auth, scheduler, storage — is a module that self-registers at startup. You blank-import it in Go or add it to the module list in Python.
Defining a module
goGo
import "github.com/redelay/go-framework/modules"
// init() auto-registers with the framework on blank import
func init() {
modules.RegisterFactory("orders", func(deps modules.ModuleDeps) {
m := &OrdersModule{db: deps.MongoDB}
deps.Registry.Register(m)
})
}
type OrdersModule struct {
db *mongo.Database
}
func (m *OrdersModule) Name() string { return "orders" }
// RoutesProvider — mount HTTP routes
func (m *OrdersModule) Routes(r modules.Router) {
r.Handle("GET", "/", m.list)
r.Handle("POST", "/", m.create)
r.Handle("GET", "/{id}", m.get)
}
// Startup / Shutdown lifecycle hooks
func (m *OrdersModule) Startup(ctx context.Context) error { return nil }
func (m *OrdersModule) Shutdown(ctx context.Context) error { return nil }
textPython — coming soon
Python equivalent coming soon.
Registering modules
goGo
// Blank-import triggers init() — no other wiring needed
import (
_ "github.com/redelay/go-framework/modules/auth"
_ "github.com/redelay/go-framework/modules/users"
_ "myapp/modules/orders"
)
func main() {
inst, srv, _ := server.Default()
app.Run(inst, srv)
}
textPython — coming soon
Python equivalent coming soon.
Module interfaces (Go)
| Interface | Purpose |
|---|---|
Module | Base — Name(), Startup(), Shutdown() |
RoutesProvider | Mount HTTP routes via Routes(Router) |
MiddlewareProvider | Register middleware via Middleware(Router) |
MountProvider | Mount sub-routers at a path prefix |
Configurable | Discover other modules via Configure(*Registry) |
MCPProvider | Expose operations as MCP tools |
EventsProvider | Declare Kafka consumers via Consumers() |
Built-in modules
| Module | Package | Purpose |
|---|---|---|
auth | go-framework/modules/auth | JWT auth, token rotation, OAuth2 |
users | go-framework/modules/users | User CRUD, password hashing |
groups | go-framework/modules/groups | RBAC permission groups |
health | go-framework/modules/health | Health check endpoint |
openapi | go-framework/modules/openapi | Auto-generated API docs |
mcp | go-framework/modules/mcp | Model Context Protocol server |
modspec | go-framework/modules/modspec | Visual module browser |