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 }

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)
}

Module interfaces (Go)

InterfacePurpose
ModuleBase — Name(), Startup(), Shutdown()
RoutesProviderMount HTTP routes via Routes(Router)
MiddlewareProviderRegister middleware via Middleware(Router)
MountProviderMount sub-routers at a path prefix
ConfigurableDiscover other modules via Configure(*Registry)
MCPProviderExpose operations as MCP tools
EventsProviderDeclare Kafka consumers via Consumers()

Built-in modules

ModulePackagePurpose
authgo-framework/modules/authJWT auth, token rotation, OAuth2
usersgo-framework/modules/usersUser CRUD, password hashing
groupsgo-framework/modules/groupsRBAC permission groups
healthgo-framework/modules/healthHealth check endpoint
openapigo-framework/modules/openapiAuto-generated API docs
mcpgo-framework/modules/mcpModel Context Protocol server
modspecgo-framework/modules/modspecVisual module browser