This guide is for teams adopting modkit in existing services without a full rewrite.
Use one bounded module first, then expand.
Recommended order:
- Introduce one feature module (for example,
users) with explicit exports. - Keep existing router and handlers around unaffected routes.
- Move one route group to a modkit controller.
- Expand module-by-module.
- Keep your current
chi.Muxas the main router. - Bootstrap modkit modules for new route groups.
- Register modkit controllers into your existing route tree.
- Reuse existing DB/repository types.
- Wrap them as providers and export only needed tokens.
- Avoid rewriting storage code during initial migration.
- Start with
ModuleDef,Imports,Exportsdiscipline. - Delay controller migration if HTTP stack migration is not needed yet.
Use this checklist for each module migration:
- Define module name and exported tokens.
- Add provider factories with explicit error handling.
- Add controller registration.
- Add tests for provider resolution and route behavior.
- Roll out behind feature flags if needed.
If a migration step underperforms:
- Revert only the migrated module integration commit.
- Keep unaffected modules/routes running.
- Reintroduce old handler wiring for that route group.
You can also exit modkit entirely by:
- replacing
kernel.Bootstrap(...)composition with explicit manual wiring, - keeping provider/controller implementations as regular Go structs.
- Do not migrate every route and module at once.
- Do not couple migration with large DB/schema redesigns.
- Do not bypass module exports with cross-module direct state access.
After each migration slice:
make testFor full repository gates:
make fmt && make lint && make vuln && make test && make test-coverage
make cli-smoke-build && make cli-smoke-scaffold