Reaching 88 mph with Systemic

A minimal dependency injection library for node.js
...

Matteo Di Paolantonio 10/07/2020

Agenda

  1. What
  2. Why
  3. Main Concepts
    • Systems and Components
    • Dependency injection
    • Systems manifest and runners
  4. Systemic and microservices
    • Generator-systemic
    • Hexagonal architecture

WHAT

“ A minimal dependency injection library ”

Created bearing in mind the

twelve-factor app methodology

for building software-as-a-service apps


WHY

  1. Managing dependencies in Node.js
  2. Lean and unopnionated
    • Not a framework
    • Wires components through their manifest
    • Everything can be a component

The Systemic redemption

  • Common microservices structure
  • No concern about start / stop order
  • Graceful shutdown out-of-the-box

  • Steep learnign curve
  • Not widely used
...

Main concepts

  • SYSTEMS
    • COMPONENTS
      • START interface
        • Starts the component
        • Exposes component's methods
      • STOP interface
        • Stops the component
        • Closes any dangling connection
      • DEPENDENCY INJECTION
    • MANIFESTS
    • RUNNERS

talk is cheap

...
code examples here

Systems and Runners

system


const components = path.join(__dirname, 'components')
const exampleSystem = () => new System({ name: 'exampleSystem' }).bootstrap(components);
					

runner


runner(exampleSystem(), { logger: emergencyLogger }).start((err, components) => {
  	if (err) {
		emergencyLogger.error(err, message);
		process.exit(1);
  	}
  	logger.info('The system has started');
});
					

Manifests and Components

manifest


const loggerSystem = () => new System({ name: 'loggerSystem' })
	.add('logger', logger())
	.dependsOn('config')
					

component


const logger = () => {
	const start = async ({config}) => {
		console.log(`starting logger with config: ${config}`);
		return console
	};
	const stop = async () => {
		console.log('stopping logger');
	};

	return { start, stop };
};
					

wrap up

...

Systemic and microservices

  • Hexagonal architecture
  • Single responsibility
  • Fine-grained separation of concerns
  • Versioning and aliasing
  • Tests stubs
  • Out-of-the-box systemic components
...

Generator-Systemic

“ A generator for a systemic microservice ”

  • yo systemic
  • yo systemic --showcase

yo systemic

A white canvas service into which creating the components you do prefer according to your specific business logic.

...

Out-of-the-box non-business-logic-related components

Config - Logger - Server

yo systemic

...

yo systemic --showcase

A not so white canvas with a given business logic already in place to help you better understand how to get the best out of Systemic.

... ...

yo systemic --showcase

...

yo systemic --showcase

service-systemic-showcase
...

Thank you

...