Tutorials
Start a local app, provision access and sign in with the user you created. Complete that loop before adding a module so you can distinguish setup issues from feature issues.
nvm use 24 or fnm use 24 to switch)apps/mercato/.env.example to apps/mercato/.env and set:
DATABASE_URL=postgres://postgres:<url-encoded-password>@localhost:5432/open-mercatoJWT_SECRET="<jwt-secret>"REDIS_URL=redis://localhost:6379yarn infra:upyarn installyarn initializeThis single command prepares module registries, generates/applies migrations, seeds default roles, provisions an admin user, and loads demo CRM data.
Alternatively, you can run the steps manually:
yarn generateyarn db:generateyarn db:migrateIf you ran yarn initialize, this step is already done. Otherwise:
yarn mercato auth seed-rolesyarn mercato auth setup --orgName "Acme" --email [email protected] --password "$OM_USER_PASSWORD" --roles superadmin,admin --skip-password-policyyarn devpackages/core, packages/search, etc.) and are enabled in apps/mercato/src/modules.ts.apps/mercato/src/modules/<module>/... and take precedence over packages with the same relative path.generated/.packages/my-module/package.json
{
"name": "@open-mercato/my-module",
"version": "0.1.0",
"private": true,
"type": "module",
"exports": { "./modules/*": "./src/modules/*" }
}
packages/my-module/src/modules/my_module/
index.ts # module metadata
acl.ts # (optional) RBAC features
setup.ts # (optional) default role features, tenant init
di.ts # (optional) register(container)
frontend/
page.tsx # serves "/my_module" (Next-style page)
backend/
page.tsx # serves "/backend/my_module"
api/
hello.ts # new API at "/api/my_module/hello"
i18n/
en.json # (optional) module dictionary
data/
entities.ts # (optional) MikroORM entities
validators.ts # (optional) zod validation schemas
Example index.ts:
import type { ModuleInfo } from '@open-mercato/shared/modules/registry'
export const metadata: ModuleInfo = {
name: 'my_module',
title: 'My Module',
version: '0.1.0',
description: 'A custom module.',
}
tsconfig.json paths add: "@open-mercato/my-module/*": ["./packages/my-module/src/*"]apps/mercato/src/modules.ts:export const enabledModules: ModuleEntry[] = [
{ id: 'auth', from: '@open-mercato/core' },
{ id: 'directory', from: '@open-mercato/core' },
{ id: 'customers', from: '@open-mercato/core' },
{ id: 'my_module', from: '@open-mercato/my-module' },
]
yarn generateyarn devNow visit /my_module and /backend/my_module.
Tip · App-level modules
For simpler modules that do not need to be published as separate packages, you can place them directly under apps/mercato/src/modules/ and use from: '@app' instead. See the Customization Tutorials for this approach.
To customize login without touching core, create the override file in the app overlay:
apps/mercato/src/modules/auth/frontend/login.tsx
This file overrides the package page @open-mercato/core/modules/auth/frontend/login.tsx.
Delete it to fall back to the package implementation.
Use apps/mercato/src/di.ts to register app-level DI overrides (runs after all module registrars):
import type { AppContainer } from '@open-mercato/shared/lib/di/container'
import { asClass } from 'awilix'
// import { CustomAuthService } from './services/CustomAuthService'
export function register(container: AppContainer) {
// container.register({ authService: asClass(CustomAuthService).scoped() })
}
packages/<pkg>/src/modules/<module>/data/entities.ts.apps/mercato/src/modules/<module>/data/entities.override.ts.yarn db:generate (writes to packages/<pkg>/src/modules/<module>/migrations; app-local modules write to apps/mercato/src/modules/<module>/migrations).yarn db:migrate.modules/<module>/cli.ts.yarn mercato <module> <command> [...args].apps/mercato/src/cli.ts (listed under module app).You now have an app running with core modules, your own module package, and an overridden auth login screen -- all without editing core.
Previous: Devices & Push Notifications — Getting Started · Next: Tutorial - testing modules