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.
Your Next.js application
Shared: access control · commands · data queries · events
Code and documentation
Follow an example
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.
Example
You open a customer record
Follow a read through a module API. The selected organization determines which records the request may access.
Step 1 / 4
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.
Where to look when something goes wrong
| Symptom | Start here |
|---|---|
| Your page does not appear | Module registration, generated routes, then the permission required by the page. |
| The form sends data but the save is rejected | API response, input schema and access scope; then the command and its guards. |
| The save succeeds but an external system is unchanged | Event 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
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.