Introduction
App Compose — a tool for creating scalable, module-based applications with ease.
Motivation
Modern applications thrive on modular architecture, adapting seamlessly to evolving business needs. To achieve true modularity, though, you need more than just independent components—you need an efficient way to bring them together. This means controlling how modules load, in what order, and with which dependencies. It gets even trickier when you want to turn off parts of the system without any traces in the code, like if/else
statements, and without affecting the stability of other components.
How does this library solve this problem?
app-compose
is designed to make this seamless. It lets you dynamically enable or disable modules as needed, not only preventing their code from loading when they’re off but also excluding all related dependencies. This means no excess resource use and optimized performance, even as the app grows.
With app-compose
, you can scale your applications effortlessly—whether you’re building a lightweight tool or a complex, feature-rich system. By managing dependency flow and on-demand module loading, app-compose
provides the control you need to build applications that are both flexible and robust.
Example
There are three entities: users, accounts, and wallets.
If the user exists, then the accounts entity should be started. If the accounts entity is done, then the wallets entity should be started.
The library offers convenient functions for creating and composing modules into a single system. Each module is encapsulated in a container with a clear configuration, including parameters like id, dependsOn, optionalDependsOn, start, and enable. Developers describe containers and launch them using compose.up
fn, without the need to worry about the order of execution. This approach makes working with containers intuitive and close to natural language.
Strengths of the Library
- Provides a simple and intuitive developer experience (DX).
- Designed with a focus on quality and performance.
- Weighs less than 1.2 kB, making it lightweight.
- Covered by 100% tests, including type tests.
- Ensures high performance, suitable for scalable applications.
- Follows semantic versioning (semver), guaranteeing stability and predictability of changes with each release.