Skip to main content

What is ModuleKit?

ModuleKit is a lightweight Java module framework. It lets you split one application into many small, self-contained modules, and then it does the tedious part for you: it finds those modules, works out the order they have to start in, hands each one the services it needs, and drives every module through a managed lifecycle.

It has no runtime dependencies in its core, works in any plain Java program, and ships with ready-made adapters for the Minecraft server platforms Paper, Folia and Minestom.

:::tip New here? Read in this order

  1. This page — the mental model.
  2. Installation and Your First Module — get something running.
  3. The Core Concepts section — understand why it works, so you can use it well. :::

The core idea in one sentence

A module declares the service types it provides and the service types it requires — and ModuleKit wires the two together.

A module never names another module. It never reaches into a global registry to "find" a collaborator. It simply lists the interfaces it needs in its constructor, and by the time ModuleKit constructs it, those interfaces are already available. This is constructor injection, and it is what keeps modules decoupled and independently testable.

// This module needs a DatabaseService and an AuthService.
// It does NOT know or care which module provides them.
public ReportingModule(DatabaseService db, AuthService auth) {
this.db = db;
this.auth = auth;
}

What you get

FeatureWhat it means for you
Automatic discoveryDrop a module on the classpath, list it in one file, and it is found — no central registry to edit.
Dependency resolutionDeclare what you need by type; ModuleKit finds the provider and injects it.
Safe load orderingProviders always start before the modules that consume them, computed with a topological sort.
Fault isolationA broken module is quarantined and skipped. The rest of the application still starts.
Managed lifecycleEach module runs through clear phases (load → enable → disable) with hooks you override.
Platform adaptersPaper, Folia and Minestom integrations that map the lifecycle onto the host and add platform niceties.

The three parts of the project

ModuleKit is one library plus two adapters. Everything below api and core is plain Java; the adapters are thin layers on top.

modulekit-apithe contract · Module · ModuleDescriptor · LoadContextmodulekit-corethe engine · discovery · graph · sort · injectionmodulekit-paperPaper / Bukkitmodulekit-minestomMinestomimplemented bysubclassed by
api & core are platform-agnostic; each adapter is a thin layer on the core.
SubprojectRoleDepends on
modulekit-apiThe pure contract you write modules against: Module, ModuleDescriptor, LoadContext.Nothing.
modulekit-coreThe engine: discovery, the dependency graph, topological sort, constructor injection.api
modulekit-paperAdapter for Paper plugins. Maps the lifecycle onto JavaPlugin, tracks Bukkit listeners, registers commands.api, core, Paper API
modulekit-minestomAdapter for Minestom. A standalone manager you drive from your own main().api, core, Minestom

Read more in The three parts, in depth.

The lifecycle at a glance

When your application starts, ModuleKit runs a pipeline. Each stage is documented in its own page in Core Concepts — this is the 30-second version:

discoverbuild graphtopologicalsortinjectonLoadonEnablefind modulesprovides→requiresorder + cyclesconstructregister servicesgo live

When should you use it?

ModuleKit is a good fit when:

  • Your application has grown past the point where one file tree comfortably owns everything, and you want feature-per-module separation.
  • Several features need to share services (a database, an auth layer, a config provider) without hard-wiring them together.
  • You cannot afford one broken feature to take down the whole process — you want fault isolation.
  • You are building a Paper or Minestom server and want each feature as an independently toggleable module.

It is deliberately not an everything-framework. See Scope & limits for what it leaves to you.

Next step

Head to Installation to add ModuleKit to your build, then build Your First Module.