How Open Mercato Works

Open Mercato runs as a Next.js application. Business modules share services for access control, data and background work. Start with that structure, then follow a read, a write or an integration through the diagram below.

On this page

What runs together?

Your application selects the business modules it needs. Generated registries connect their pages, API routes and services to the application. A module is a unit of source code; it does not automatically become a separately deployed service.

Architecture in practiceOne application, modules inside it, services around it
Browser / API clientHTTPS
request

Your Next.js application

CRM
Sales
Your module

Shared: access control · commands · data queries · events

↓ read / write↓ enqueue work
PostgreSQLBusiness records
Queue + workerFor configured background work
Code and documentation

generators/module-registry.ts

From user action to result

Choose a scenario, then a step. See which component does the work, what it receives and what it passes on.

You open a customer record

Follow a read through a module API. The selected organization determines which records the request may access.

Open the record

The page requests one customer using its identifier. It sends the signed-in session with the request.

Receives
customerId: "42"
Passes on
Request to the module API

ResultThe browser displays the customer data returned by the API.

What can go wrong?An unknown or inaccessible customer must not reveal data from another organization. Enforce this in the route and query scope.

Explore this mechanism →

Where to look when something goes wrong

SymptomStart here
Your page does not appearModule registration, generated routes, then the permission required by the page.
The form sends data but the save is rejectedAPI response, input schema and access scope; then the command and its guards.
The save succeeds but an external system is unchangedEvent emission, subscriber registration, queued job and worker error logs.
Code and documentation

generators/module-registry.ts · crud/factory.ts · src/factory.ts

Example: saving a customer

A customer form sends a request to an API route. A route built with makeCrudRoute can validate the input, check access and call a registered command. The command performs the change. DataEngine can coordinate persistence, declared events and index updates.

A direct ORM write can skip command logging, guards or event handling that the normal route uses. When an import updates the database but the screen or search results stay unchanged, compare the import path with the route used by the form.

Code and documentation

crud/factory.ts · commands/command-bus.ts · data/engine.ts

What do you deploy?

Plan the application and database first. Add workers, cache, search and file storage according to the features and strategies you enable. Record which service owns each piece of data and how it will be restored after a failure.

Code and documentation

src/service.ts · src/service.ts · src/factory.ts

Sources

Open Mercato source used in these explanations