Unlocking Development Efficiency: Introducing Platformatic Stackables

Unlocking Development Efficiency: Introducing Platformatic Stackables

In the ever-evolving landscape of software development, time is of the essence. Enterprises today strive for a balance between creativity and efficiency, seeking ways to streamline workflows without compromising on the uniqueness of their applications.

As backend developers navigate increasingly complex systems and time pressures, organizations must prioritize creating an efficient, simple, and enjoyable development environment. This starts with understanding developers' workflows, pain points, and collaboration dynamics, and subsequently moves towards the automation of repetitive tasks, particularly through the use of configurable tools.

A Deep Dive into Tools Used to Speed up the Development Process

As a technical leader, understanding where bottlenecks lie and subsequently offering your team of developers the freedom to choose tools that best suit their preferences in order to overcome these bottlenecks is vital to the success of both your team and the application that it maintains.

We took a look at some of the most commonly used tools to overcome the repetitive, time-consuming foundational work that plagues backend developers, taking them away from more complex and thought-provoking development tasks.

  • Starter kits: These repositories provide foundational code for an application, allowing you to spin it up quickly. Starter kits enable users to create a new app in minutes, however it can also quickly fall behind without diligent maintenance, and can be cumbersome during setup to remove unnecessary features. Moreover, starter kits do not provide a way to simply and deterministically create applications, leading to increased operational expenditure and ultimately, invisible technical debt.

  • Archetypes: This refers to a predefined, standardized template or model that serves as a starting point for an application or a specific component with preconfigured files, directories and settings. While archetypes can help streamline the building of new applications, they can be rigid in terms of customization capability and also present maintenance challenges.

  • Code generators: A code generator is a tool that automatically generates source code or other artifacts based on predefined templates, rules, or models. Generators can help developers reduce manual coding efforts, improve consistency, and accelerate the development process, however they offer limited customization options and debugging challenges.

  • Code templates: These are reusable code outlines for routine functions which contain basic structures and syntax. Templates help save time by providing a customizable and extendable foundation for developers. They can however cause bloated code, maintenance overhead, and code duplication.

So, what is the alternative?

Enter Platformatic Stackables, a revolutionary approach that redefines how applications are built, shared, and scaled.

Platformatic Stackables offer a deterministic, composable template model that you can use to build your base application quickly and simply. Platformatic Stackable’s templates come fully loaded with everything your team needs, including automatic updates, and allow for the simple layering of your specific configurations.

Imagine creating, maintaining, and growing a robust, feature-rich application without the need to start from scratch every time. Similarly, imagine being able to minimize onboarding costs without having to deal with the fragmentation brought on by the use of starter kits.

Using Stackables allows you to avoid building a monolith, instead providing the building blocks and practices you need to create a modular system that can be assembled in a myriad of combinations, across your organization. With Stackables, you can create an internal Open Source community, simplifying the distribution of templates and assets across your organization’s dispersed teams.

Getting Started with Stackables

Platformatic Service and Platformatic DB offer a good starting point to create new applications, with Service providing a base layer, and DB enabling you to spin up an out-of-the-box API in a matter of seconds. However, most developers or organizations might want to create reusable services or applications built on top of Platformatic– this is where Stackables come into play.

Diving into the world of Stackables is a straightforward process which starts with the simple task of packaging a Platformatic application as a module.

In this guide, we will lead you through the steps required to create a modular application that can be seamlessly integrated into your projects.

Creating a Custom Service

We are creating the module foo.js as follows:

const { schema, platformaticService } = require('@platformatic/service')

/**  @type {import('fastify').FastifyPluginAsync<{}>} */
async function foo (app, opts) {
  const text = app.platformatic.config.foo.text
  app.get('/foo', async (request, reply) => {
    return text

  await platformaticService(app, opts)

foo.configType = 'foo'

// break Fastify encapsulation
foo[Symbol.for('skip-override')] = true

// The schema for our configuration file
foo.schema = {
  $id: 'https://example.com/schemas/foo.json',
  title: 'Foo Service',
  type: 'object',
  properties: {
    server: schema.server,
    plugins: schema.plugins,
    metrics: schema.metrics,
    watch: {
      anyOf: [schema.watch, {
        type: 'boolean'
      }, {
        type: 'string'
    $schema: {
      type: 'string'
    module: {
      type: 'string'
    foo: {
      type: 'object',
      properties: {
        text: {
          type: 'string'
      required: ['text']
  additionalProperties: false,
  required: ['server']

// The configuration for the ConfigManager
foo.configManagerConfig = {
  schema: foo.schema,
  envWhitelist: ['PORT', 'HOSTNAME'],
  allowToWatch: ['.env'],
  schemaOptions: {
    useDefaults: true,
    coerceTypes: true,
    allErrors: true,
    strict: false

module.exports = foo

Note that the $id property of the schema identifies the module in our system, allowing us to retrieve the schema correctly. It is recommended, but not required, that the JSON schema is actually published in this location. Doing so allows tooling such as the VSCode language server to provide autocompletion.

In this example, the schema adds a custom top-level foo property that users can use to configure this specific module.

ESM is also supported.

Consuming a custom application

Consuming foo.js is simple. We can create a platformatic.json file as follows:

  "$schema": "https://example.com/schemas/foo.json",
  "module": "./foo",
  "server": {
    "port": 0,
    "hostname": ""
  "foo": {
    "text": "Hello World"

Note that we must specify both the $schema property and module. The module can also be any modules published on npm and installed via your package manager.

Building your own CLI

It is possible to build your own CLI with the following cli.mjs file:

import foo from './foo.js'
import { start } from '@platformatic/service'
import { printAndExitLoadConfigError } from '@platformatic/config'

await start(foo, process.argv.splice(2)).catch(printConfigValidationErrors)

This will also load platformatic.foo.json files.

Wrapping Up

As we have seen in this guide, with Stackables we can easily publish applications and application templates on a public or private npm registry, including building your own CLI, or create specialized templates for your organization to allow for centralized bugfixes and updates.

Stackables empower developers to construct foundational applications with automatic updates, enabling swift changes that resonate throughout the organization. Upon launching a new application, users can leverage the Stackables, prompting them to choose from a range of pre-determined templates, ensuring that they remain aligned with a standardized framework, expediting consistency and accelerating progress.

Get started with Platformatic