Open MercatoDocsSearch docsAPI reference

Tutorials

Tutorial - build your first Open Mercato app

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.

1) Prerequisites

2) Install and Prepare

This 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:

3) Seed Roles and Create Admin

If you ran yarn initialize, this step is already done. Otherwise:

4) Run the App

5) How Modules Load and Override

6) Create Your Own Module (as a package)

  1. Scaffold a local package:
packages/my-module/package.json
{
  "name": "@open-mercato/my-module",
  "version": "0.1.0",
  "private": true,
  "type": "module",
  "exports": { "./modules/*": "./src/modules/*" }
}
  1. Add source tree:
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.',
}
  1. Add a TS alias so imports resolve:
  1. Enable the module in 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' },
]
  1. Regenerate + run:

Now 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.

7) Override the Auth Login Screen

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.

8) Override Services (DI)

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() })
}

9) Entities and Migrations

10) CLI Commands

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