libmodulor v0.19.0 is out 🚀 => Check it out on GitHub or npm !
libmodulor
Guides

Create an app

An app is a logical group of use cases. It's like a "module" (whatever that means), inspired by Domain-driven design (DDD) bounded contexts.

Its logical representation is a directory named src/apps/{AppName} that has the following structure :

📁 src
    📁 lib
    📁 ucds
    📄 i18n.ts
    📄 manifest.ts
📁 test
📄 index.ts

src => Source

lib

This folder contains data types, policies, types, interfaces, classes, functions, consts... that are used across one or multiple use cases.

You are free to organize this folder the way you want.

ucds => use case definitions

This folder contains the use case definitions of the app. Check Create a use case for more details.

manifest

It's a file named manifest.ts exporting a const named Manifest that must satisfy the AppManifest interface.

src/manifest.ts
import type { AppManifest } from 'libmodulor';

export const Manifest = {
    languageCodes: ['en'],
    name: 'Trading',
    ucReg: {},
} satisfies AppManifest;

languageCodes lists all the country codes that the app supports. For any language listed here, i18n (see below), must contain the corresponding entry.

name must be the same as the app directory name.

ucReg stands for "use case registry". It lists all the use cases of the app. Check out Create a use case for more details.

i18n

It's a file named i18n.ts exporting a const named I18n that must satisfy the AppI18n interface.

src/i18n.ts
import type { AppI18n } from 'libmodulor';

export const I18n: AppI18n = {
    en: {},
};

It contains translations for the common things that can be translated in the app. Check out Translate an app for more details.

You can leave translations empty and things will still work. In this case, the library will humanize the fields. Although it can work in some cases, it's not ideal in terms of UX.

test

Check Test an app for more details.

index

It's a barrel file exporting only what's consumed outside the app (typically i18n, manifest and some use case defs).

index.ts
// Expose only what's necessary

export { I18n } from './src/i18n.js';
export { Manifest } from './src/manifest.js';