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 ClaimsCore box holds the common workflow: validate, look up, assess, record. Next to it, the plug-in registry maps NY to ny-rules, CA to ca-rules and TX to tx-rules. Under both runs the ClaimRule 2.x contract band, and under the band sit the plug-ins ny-rules, ca-rules, tx-rules, each a jar in the plugins folder
The core talks only to the contract; the registry says which plug-in handles which state.

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-inContractRuleSample claimPayout
ny-rules 1.32.0$500 deductible, 80%NY, $3000$2000
ca-rules 2.12.0$250 deductible, 90%CA, $2000$1575
tx-rules 1.02.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.4refusedWA, $1200manual 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)

Two panels. Left, microkernel: tx-rules is marked off with a cross, ny-rules and ca-rules stay up; the fix ships as tx-rules 1.0.1 and core releases stay at 1. Right, every rule in the core: the bug is in the tx method inside ClaimsCore, there is no switch to turn Texas off, and the fix ships as core release 2 with every rule retested
A plug-in bug is switched off and fixed alone; the same bug inside the core needs a core release.

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.

ChangeMicrokernelEvery rule in the core
Add FloridaNew jar, registered while running; core releases stay 1New branch and method; core release 2
Bug in the Texas ruleCore disables tx-rules; other states keep workingThe exception comes from the core's own code; no switch for Texas alone
Fix the Texas ruleNew plug-in version onlyAnother core release; every rule retested
Old rule built for an older contractRefused at registrationNo 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.

On the mind map

Open the Software Design mind mapSoftware DesignPrinciples: keep each change localPrinciplesDesign patterns: named fixes for common designsDesign patternsArchitecture: the shape of a whole appArchitectureEnterprise app patterns: logic, SQL, locks, money (PoEAA)Enterprise app patternsGit storage: content named by its hashGit storageGit branches & merging: pointers to commits, then mergeGit branches & mergingTesting: check code in isolationTestingHexagonal architectureHexagonal architecturedomain in the middle, adapters at portsLayered vs Pipes vs EventsLayered vs Pipes vs EventsClosed layers add hops; queues absorb faultsMicrokernel plug-insSmall core; rules plug in via a contractUML Sequence DiagramUML Sequence DiagramTime runs down; one arrow per callUML class diagramUML class diagramA field is a line; diamond = whole and partsUse Case DiagramUse Case Diagraminclude always runs, extend is optionalState and activity diagramsState and activity diagramsExits inside out, entries outside inVirtual DOM diffingVirtual DOM diffingdiff new tree vs old, patch only changesMVC vs MVVMMVC vs MVVMController routes input; view-model bindsOpen the Software Design mind mapSoftware Designthe shape of a whole appArchitectureHexagonal architectureHexagonal architecturedomain in the middle, adapters at portsLayered vs Pipes vs EventsLayered vs Pipes vs EventsClosed layers add hops; queues absorb faultsMicrokernel plug-insSmall core; rules plug in via a contractUML Sequence DiagramUML Sequence DiagramTime runs down; one arrow per callUML class diagramUML class diagramA field is a line; diamond = whole and partsUse Case DiagramUse Case Diagraminclude always runs, extend is optionalState and activity diagramsState and activity diagramsExits inside out, entries outside inVirtual DOM diffingVirtual DOM diffingdiff new tree vs old, patch only changesMVC vs MVVMMVC vs MVVMController routes input; view-model binds
This page on the Software Design mind map · 41 pages in 7 branches · open it to see the whole map and test yourself in recall mode.