The idea: a small core that knows no rules
An insurance company pays claims in many US states. The steps are the same everywhere: check the claim, work out the payout, record it. But each state has its own rule for the payout, and the rules change often. The microkernel architecture, also called the plug-in architecture, splits such a system in two. A small core system runs the common steps. Each state's rule is a separate plug-in. The core finds the right plug-in in a registry and calls it through a fixed contract.
The core system
The core, ClaimsCore, does four things for every claim, shown as four rows in its box:
validate(claim), registry.lookup(state), assess(claim) through the
contract, and record the payout or send the claim to manual review. Nothing in it mentions New York or
Texas. A good core is small and changes rarely; its job is the workflow and the plumbing.
The contract and its version
Core and plug-ins meet only through the contract. Here it is an interface,
ClaimRule, with three methods: id(), handles() and
assess(claim): Payout. A contract can also be a message format or a REST API.
Each plug-in jar carries a manifest: its id, its version, the contract version it was built for and the state it handles. The core implements contract 2.1 and accepts any plug-in built for major version 2. A new minor version only adds things, so a 2.0 plug-in still fits. A new major version may remove or change methods, so a 1.x plug-in is refused.
The registry and start-up
At start-up the core scans the plugins/ folder. For each jar it reads the manifest, checks
the contract version, and adds a line to the registry: NY → ny-rules 1.3. After three
checks the registry has three entries, and the core still has no line about any state.
(Demo: start-up, check the contract, register)
Routing one claim
A claim from New York for $3000 arrives. The core validates it, looks up "NY" and gets
ny-rules. It calls assess(); the plug-in subtracts its deductible and pays its
share. The core records the result. The registry lookup replaces an if per state: the core
picks the plug-in by key. (Demo: a claim routed to its plug-in)
| Plug-in | Contract | Rule | Sample claim | Payout |
|---|---|---|---|---|
ny-rules 1.3 | 2.0 | $500 deductible, 80% | NY, $3000 | $2000 |
ca-rules 2.1 | 2.0 | $250 deductible, 90% | CA, $2000 | $1575 |
tx-rules 1.0 | 2.0 | $1000 deductible, 100% | TX, $1500 | $500 |
fl-rules 1.0 (added) | 2.1 | $300 deductible, 70% | FL, $800 | $350 |
wa-rules 0.9 (added) | 1.4 | refused | WA, $1200 | manual review |
The rules are made up and much simpler than real insurance law. They only need to differ by state.
Adding a plug-in while running
Before Florida is supported, a Florida claim finds no registry entry and goes to manual review. Then
fl-rules.jar is dropped into plugins/. The core watches the folder, checks the
manifest (contract 2.1, major 2) and registers FL → fl-rules. There is no restart and no
core release. The next Florida claim pays $350. (Demo: add a plug-in while running)
wa-rules 0.9 was built for contract 1.4. The core refuses it at registration, before any
claim reaches it, so a Washington claim goes to review instead of calling a method that may not exist.
(Demo: an old-contract plug-in is refused)
A faulty plug-in stays contained
The core never trusts a plug-in blindly. It wraps every assess() call in try/catch with a
2 second timeout. When tx-rules throws, the core catches the exception, marks the plug-in
off in the registry and sends the claim to review. The next Texas claim is not even sent
to the plug-in. A New York claim right after still pays $2000.
(Demo: a faulty plug-in is isolated)
The fix is a new plug-in version, tx-rules 1.0.1. It has the same contract, so the core
registers it again, and Texas claims pay $500. The core is not rebuilt.
(Demo: fix only the plug-in)
Every rule in the core
The right panel builds the same system without plug-ins: one if … else if branch per state
inside ClaimsCore.assess(), and one method per rule. For a single claim it gives the same
payout. The difference shows over time.
| Change | Microkernel | Every rule in the core |
|---|---|---|
| Add Florida | New jar, registered while running; core releases stay 1 | New branch and method; core release 2 |
| Bug in the Texas rule | Core disables tx-rules; other states keep working | The exception comes from the core's own code; no switch for Texas alone |
| Fix the Texas rule | New plug-in version only | Another core release; every rule retested |
| Old rule built for an older contract | Refused at registration | No contract to check |
With a few stable rules, the plain if is simpler and fine. The plug-in style pays off when
rules are many, change on their own schedule, or come from other teams.
Where you meet it
Eclipse and other OSGi applications load bundles into a small runtime. VS Code runs extensions that declare what they contribute in a manifest. Jenkins, browsers with extensions, and rules engines in insurance and tax software follow the same shape. The name comes from operating systems, where a microkernel keeps only a few services in the kernel and runs the rest as separate servers; see Monolithic vs Microkernel for that meaning.
What it costs
The contract is the hard part. Once many plug-ins depend on it, a breaking change means rebuilding all of them, so contracts grow slowly and carry versions. The registry and the checks are extra code. Plug-ins should not call each other, or they become one tangled system again. And every combination of plug-in versions that can be installed together needs to be tested.
See also Strategy and Factory Method, the same idea at class level; Hexagonal Architecture, where adapters plug into ports the core owns; Layered, Pipe-and-Filter and Event-Driven for other architecture styles; and Decorator, Proxy and Adapter for wrapping a call, as the core's try/catch does.
What the page leaves out
A try/catch in the same process is weak isolation: a plug-in that leaks memory, loops forever or calls
System.exit can still hurt the core. Real systems add separate class loaders, permissions,
or a separate process, like the VS Code extension host. Also left out: unloading old versions, plug-ins
that depend on other plug-ins, signed plug-ins from a marketplace, and remote plug-ins reached over the
network.