Plugin Architecture
ELI5 — The Vibe Check
Plugin architecture is building your app so features can be added, removed, or swapped without changing the core. Think of VS Code — it's just a shell, and extensions add all the magic. Your app defines hooks, and plugins plug into them. Very extensible, very cool.
Real Talk
Plugin architecture designs an application as a core system with well-defined extension points where plugins can add, modify, or replace functionality. The core provides a plugin API, lifecycle hooks, and a registration mechanism. Plugins are loaded dynamically and operate independently. Examples include Webpack plugins, Vite plugins, Hapi plugins, and Fastify plugins.
Show Me The Code
// Core defines plugin interface
interface Plugin {
name: string;
setup(app: App): void;
}
// Plugin implementation
const authPlugin: Plugin = {
name: 'auth',
setup(app) {
app.addMiddleware(authMiddleware);
app.addRoute('/login', loginHandler);
}
};
app.register(authPlugin);
When You'll Hear This
"Fastify's plugin architecture keeps our codebase modular and each feature isolated." / "Build a plugin architecture so teams can add features without touching core code."
Related Terms
Design Pattern
Design patterns are like recipe cards for solving common coding problems.
Middleware
Middleware is like a security checkpoint at an airport.
Modular Monolith
Modular Monolith is the best of both worlds: one deployable app (monolith) but organized into clear, separate modules that could become microservices somed...