Installation
Pick a setup path before installing dependencies. Product teams usually want a standalone app. Contributors working on the framework need the monorepo.
Product teams looking to build on Open Mercato should start with the standalone app – it gives you a clean project without cloning the full monorepo. Core contributors should follow the main branch track instead.
Tip · Standalone app
If you want to build a production app without cloning the monorepo, use create-mercato-app instead.
Tip · Windows users
If you are on Windows, prefer the Windows native local development flow below: Docker Desktop for infrastructure services, then run the app natively with Node.js and Yarn. The full Docker development setup remains available as a container-only option, but on Windows it is usually much slower for this monorepo because bind-mounted file watching and filesystem I/O cross the Windows/WSL boundary.
Scaffold a standalone project with a single command – no need to clone the monorepo:
npx create-mercato-app my-app
cd my-app
Then follow the post-install steps in the full standalone app guide.
If you are working on the Open Mercato monorepo and need to validate scaffold changes before publishing:
yarn test:create-app
yarn test:create-app:integration
See the standalone app guide for what each command does.
git clone https://github.com/open-mercato/open-mercato.git
cd open-mercato
main is where development happens; released minors live on release/vX.Y.x branches. Continue with the setup steps below.
Use this track if you want to run the entire stack inside Docker with hot reload – no local Node.js or Yarn required. This works on macOS/Linux and remains available on Windows as a container-only option, but Windows contributors should usually prefer the native local workflow above because it is faster and more reliable for this monorepo.
See the full Docker Development Setup section below for step-by-step instructions.
Follow these steps after the prerequisites are in place:
Use the main branch
cd open-mercato
git checkout main
Start Docker services
yarn infra:up
This starts PostgreSQL 15 with pgvector and Redis 7. The pgvector extension is automatically installed, enabling vector search features.
Install workspace dependencies
yarn install
Install agent skills (optional – only if you use an AI coding agent)
yarn install-skills
yarn install does not install agent skills. This command installs the repo's committed local-tier skills together with the full shared open-mercato/skills collection (om-code-review, om-auto-review-pr, om-auto-fix-pr, om-merge-buddy, and others) into the gitignored .agents/skills/ directory. Run it once per clone/worktree if you plan to use Codex, Claude Code, Cursor, or another supported coding agent; re-run it any time to refresh the collection. See .ai/skills/README.md for the tier system and --list/--clean flags. A Docker equivalent, yarn docker:install-skills, is documented in Docker Wrapper Commands.
This step is intentionally manual and is deliberately not wired into yarn install or a postinstall hook: it downloads an external collection over the network, and contributors who do not use an AI coding agent should not pay that cost on every install.
Copy the environment template
cp apps/mercato/.env.example apps/mercato/.env
Make sure these required variables are set in apps/mercato/.env before continuing:
DATABASE_URL=postgres://postgres:<url-encoded-password>@localhost:5432/open-mercato
JWT_SECRET="<jwt-secret>"
REDIS_URL=redis://localhost:6379
If you prefer a separate events Redis, set EVENTS_REDIS_URL instead of REDIS_URL.
Build packages and generate registries
yarn build:packages
yarn generate
yarn build:packages
Run yarn build:packages again after yarn generate on a fresh local setup. This second build makes sure newly generated scripts are compiled before yarn initialize runs; otherwise yarn initialize may not detect them and can fail during bootstrap.
Bootstrap data
yarn initialize
This script prepares module registries, generates/applies migrations, seeds default roles, provisions an admin user, and loads demo CRM data (companies, people, deals, activities, todos). Add --no-examples if you prefer to skip the demo content while keeping core identities, --stresstest (optionally with -n <count>) to preload thousands of synthetic contacts, companies, deals, activities, and notes, or combine --stresstest --lite for high-volume contacts without the heavier extras when you need raw throughput.
Launch the app
yarn dev
yarn dev starts the compact development runtime. On native local runs it serves a startup splash screen with live progress on http://localhost:4000 by default, auto-opens that page when possible, and prints the backend URL in the terminal. Once the runtime is ready, continue to http://localhost:3000/backend and sign in with the credentials printed by yarn initialize.
To run multiple persistent local instances against the same PostgreSQL server (e.g. one per client repo), pass an optional --database-name[=<name>] flag. Without the flag, behavior is unchanged.
# explicit name; .env update is offered with default-yes
yarn dev:greenfield --database-name=client_a
# bare flag derives the database name from the current directory
yarn dev --database-name
# one-off run that does not edit .env
yarn dev --database-name=client_a --no-update-env
The override only rewrites the database segment of DATABASE_URL; credentials, host, port, and query parameters are preserved. CI/non-interactive runs default to updating .env – pass --no-update-env to opt out.
This is the recommended Windows setup for day-to-day work on the monorepo. Docker Desktop runs the infrastructure services, while Node.js and Yarn run directly on Windows. The full starters/docker/compose.fullapp.dev.yml stack remains available for isolated or fully containerized workflows, but on Windows it is usually much slower because a large Node.js monorepo with bind-mounted source files does heavy watched file reads across the Windows/Linux filesystem boundary.
Install the prerequisites with the following PowerShell commands.
corepack enable
corepack prepare yarn@stable --activate
winget install Microsoft.VisualStudio.2022.BuildTools
winget install Microsoft.VCRedist.2015+.x64
corepack enable
corepack prepare yarn@stable --activate
If you install Build Tools through the UI, make sure the C++ build tools workload is included. Git, Node.js 24.x, Yarn/Corepack, and Docker Desktop must be installed and configured separately before continuing with the monorepo setup.
Start only infrastructure services from the repository root:
yarn infra:up
The infra compose file (starters/docker/compose.infra.yml) starts the local service stack, including PostgreSQL, Redis, and Meilisearch. It does not run the application container.
Microsoft Defender exclusion is optional, but strongly recommended on Windows because without it repository operations and local development can be noticeably slower. Run it manually in PowerShell if you want the recommended setup:
Start-Process powershell -Verb RunAs -ArgumentList "-NoProfile -ExecutionPolicy Bypass -Command `"Add-MpPreference -ExclusionPath '$((Get-Location).Path)'`""
Continue with the normal monorepo setup:
yarn install
yarn install-skills # optional — only if you use an AI coding agent
yarn build:packages
yarn generate
yarn build:packages
yarn initialize
yarn dev
yarn build:packages is a monorepo-only step that compiles workspace packages to dist/. It does not exist in standalone apps. On a fresh local setup, run it both before and after yarn generate so yarn initialize can see the generated scripts.
For an existing database where you only need to apply new migrations:
yarn db:migrate
yarn generate
yarn dev
When you run yarn dev on the host, Open Mercato starts a compact development runtime with a dedicated splash page that shows startup progress while packages, generators, and the app server warm up.
http://localhost:4000http://localhost:3000/backendd while yarn dev is running to toggle raw logsStart building with Cezar button opens Cezar for the current project by running plain npx cezar-run in a new terminal; it works while the app is still startingStart building with Cezar to choose another detected coding tool; the dropdown toggle also supports keyboard and touchghFor the standalone splash features, install these recommended tools up front:
gh) for the GitHub publish panel: cli.github.comTo override the splash port for native local runs:
OM_DEV_SPLASH_PORT=4100 yarn dev
To use a random free splash port instead of the stable default:
OM_DEV_SPLASH_PORT=random yarn dev
To keep the splash from opening automatically:
OM_DEV_AUTO_OPEN=0 yarn dev
To hide the standalone GitHub publish panel from the splash:
OM_DEV_CREATE_GIT_REPO_FLOW=false yarn dev
To hide the combined Start building with Cezar control from the splash:
OM_ENABLE_CODING_FLOW_FROM_SPLASH=false yarn dev
To keep idle memory low, yarn dev now runs two things in-process inside the mercato server dev runtime instead of as separate long-running Node processes:
mercato generate when module files change is hosted by the dev server itself. Collapsing this dedicated sidecar saves ~190 MB of resident memory.This is the right default for most local development. If you need higher throughput – for example a heavy import/reindex, or to profile worker behavior in isolation – opt back into separate parallel processes with these flags.
Run the generate watcher as a standalone sidecar process again:
OM_DEV_GENERATE_WATCH_MODE=legacy yarn dev
Stop the dev runtime from hosting workers, then run dedicated worker processes alongside it (each process runs its own event loop, so several in parallel scale throughput):
# In the dev runtime: do not auto-spawn in-process workers
AUTO_SPAWN_WORKERS=false yarn dev
# In separate terminals: dedicated worker processes, tuned per queue
yarn mercato <module> worker <queue-name> --concurrency=5
Tune --concurrency per the queue guidelines (I/O-bound 5–10, CPU-bound 1–2, DB-heavy 3–5; never exceed 20). For production-grade parallelism across machines, set QUEUE_STRATEGY=async to use the Redis-backed BullMQ strategy.
To poll for jobs lazily instead of holding eager in-process workers (lower idle cost, slightly higher pickup latency):
OM_AUTO_SPAWN_WORKERS_LAZY=true yarn dev
# optional: tune the poll interval (ms, default 1000)
OM_AUTO_SPAWN_WORKERS_LAZY_POLL_MS=500 yarn dev
Stop services:
yarn infra:down
View logs:
docker compose --project-directory . -f starters/docker/compose.infra.yml logs -f
Complete reset (deletes all data):
docker compose --project-directory . -f starters/docker/compose.infra.yml down -v
yarn infra:up
yarn mercato init
Verify pgvector installation:
docker exec mercato-postgres psql -U postgres -d open-mercato -c "SELECT extname, extversion FROM pg_extension WHERE extname = 'vector';"
Run the entire Open Mercato stack inside Docker with hot reload. Source code is mounted from the host so every file change is picked up automatically – no local Node.js, Yarn, or native build tools required. This is a convenient option on any OS, but on Windows it is usually slower than the native local workflow because of bind-mounted monorepo file watching.
Info · Windows-specific notes
git config --global core.autocrlf input
# Clone the repository
git clone https://github.com/open-mercato/open-mercato.git
cd open-mercato
# (Optional) Copy and customize environment
cp apps/mercato/.env.example apps/mercato/.env
# Build and start the full dev stack
docker compose --project-directory . -f starters/docker/compose.fullapp.dev.yml up --build
The first run takes several minutes – Docker builds the image, installs dependencies, builds packages, runs migrations, and seeds demo data. Subsequent starts are much faster because initialization is cached in a named volume.
The app container uses the same compact yarn dev runtime as native local development, including the splash screen with live startup progress. In Docker, the container cannot open a browser on your host automatically, so use the URLs printed in the logs instead:
http://localhost:4000http://localhost:3000/backendOnce the runtime is ready, open the backend URL and sign in with the default credentials printed during initialization (typically [email protected] / <password printed during initialization>).
The starters/docker/compose.fullapp.dev.yml file orchestrates five services:
| Service | Image | Purpose |
|---|---|---|
| app | Built from Dockerfile (dev stage) | Next.js app with hot reload |
| postgres | pgvector/pgvector:pg17-trixie | PostgreSQL 17 with pgvector |
| redis | redis:7-alpine | Caching and event persistence |
| meilisearch | getmeili/meilisearch:v1.11 | Full-text search |
| opencode | Custom | Claude Code integration (optional) |
The app container:
/appnode_modules, .next, and package dist/ directories so the container manages its own buildsCHOKIDAR_USEPOLLING, WATCHPACK_POLLING) for reliable change detection on all platformsyarn mercato init (migrations + seeding); on subsequent runs, applies pending migrations onlyStart in detached mode (background):
docker compose --project-directory . -f starters/docker/compose.fullapp.dev.yml up -d
View logs:
docker compose --project-directory . -f starters/docker/compose.fullapp.dev.yml logs -f # all services
docker compose --project-directory . -f starters/docker/compose.fullapp.dev.yml logs -f app # app only
Rebuild after pulling new changes:
docker compose --project-directory . -f starters/docker/compose.fullapp.dev.yml up --build
Stop all services:
docker compose --project-directory . -f starters/docker/compose.fullapp.dev.yml down
Full reset (deletes all data and cached builds):
docker compose --project-directory . -f starters/docker/compose.fullapp.dev.yml down -v
docker compose --project-directory . -f starters/docker/compose.fullapp.dev.yml up --build
The repository also exposes root-level yarn docker:* commands that run the matching workflow inside the running app container. These wrappers exist so container-first contributors can use the same command surface without translating everything to docker compose exec ... manually.
The wrappers are implemented by scripts/docker-exec.mjs. The helper:
starters/docker/compose.fullapp.dev.yml, then falls back to starters/docker/compose.fullapp.ymlDOCKER_COMPOSE_FILE=...app container is runningStart the dev stack first:
yarn docker:dev:up
Then run monorepo workflows from the host:
yarn docker:build:packages
yarn docker:generate
yarn docker:initialize
yarn docker:initialize -- --reinstall
yarn docker:reinstall
yarn docker:db:generate
yarn docker:db:migrate
yarn docker:lint
yarn docker:typecheck
yarn docker:test
yarn docker:install-skills # container equivalent of `yarn install-skills` — optional, only if you use an AI coding agent
Use yarn docker:dev when you want to restart the app service and immediately tail logs:
yarn docker:dev
For a faster restart that skips the install/build/generate phase handled by the dev entrypoint, pass the wrapper flag through to docker-exec:
yarn docker:dev -- --skip-rebuilt
This flow is the documented replacement for manually running:
docker compose --project-directory . -f starters/docker/compose.fullapp.dev.yml restart app
docker compose --project-directory . -f starters/docker/compose.fullapp.dev.yml logs -f app
The production-like fullapp profile is runtime-focused. It supports operational commands, but not monorepo development workflows such as generate, build:packages, lint, typecheck, test, or install-skills.
Start the fullapp stack:
yarn docker:up
Supported runtime-oriented examples:
yarn docker:db:migrate
yarn docker:mercato auth:list-users
If you run a dev-only wrapper against the fullapp stack, the helper fails closed and tells you to switch back to the dev profile:
DOCKER_COMPOSE_FILE=starters/docker/compose.fullapp.dev.yml yarn docker:generate
When both stacks exist, or when you want to target a specific profile regardless of auto-detection, set DOCKER_COMPOSE_FILE explicitly:
DOCKER_COMPOSE_FILE=starters/docker/compose.fullapp.dev.yml yarn docker:generate
DOCKER_COMPOSE_FILE=starters/docker/compose.fullapp.yml yarn docker:db:migrate
Error: No running Open Mercato app container found., start either yarn docker:dev:up or yarn docker:up first.DOCKER_COMPOSE_FILE="..." does not exist., fix the path and re-run the command.All environment variables are pre-configured with sensible defaults inside the compose file. To customize, edit apps/mercato/.env before starting – the compose file reads from it automatically.
Key variables you may want to override:
| Variable | Default | Description |
|---|---|---|
APP_PORT | 3000 | Host port for the app |
OM_DEV_SPLASH_PORT | 4000 | Host and container port for the dev splash progress page |
OM_DEV_AUTO_OPEN | 1 | Set to 0 to disable browser auto-open for the splash on supported local runs |
OM_DEV_CREATE_GIT_REPO_FLOW | true | Set to false to hide the standalone splash GitHub publish panel |
OM_ENABLE_CODING_FLOW_FROM_SPLASH | true | Set to false to hide the combined Start building with Cezar splash control |
OM_DEV_SPLASH_VSCODE_PATH | auto-detect | Optional path override for the VS Code CLI used by the splash coding menu |
OM_DEV_SPLASH_CURSOR_PATH | auto-detect | Optional path override for the Cursor CLI used by the splash coding menu |
OM_DEV_SPLASH_CLAUDE_CODE_PATH | auto-detect | Optional path override for the Claude Code CLI used by the splash coding menu |
OM_DEV_SPLASH_CODEX_PATH | auto-detect | Optional path override for the Codex CLI used by the splash coding menu |
POSTGRES_USER | postgres | Database username |
POSTGRES_PASSWORD | Set a password for your environment. | Database password |
JWT_SECRET | required, no default | Auth token secret – generate with openssl rand -hex 32. The full-app compose stacks refuse to start without it |
OPENAI_API_KEY | – | Enables OpenAI-backed AI features; add it with OM_DISABLE_VECTOR_SEARCH_AUTOINDEXING=false only when you want vector auto-indexing on |
OM_DISABLE_VECTOR_SEARCH_AUTOINDEXING | true in the shipped example env | Set to false or remove it to enable automatic vector indexing |
DEMO_MODE | true | Demo-deployment behaviour: shows the backend contact/feedback widget, locks attachment partition settings, and keeps the demo superadmin during mercato init. The demo notice bar is dropped only by the literal value false. To hide just the contact widget while leaving the rest on, use the ff_om_hide_contact browser flag |
If you need a different splash port in Docker, set it before startup so the host/container mapping stays aligned:
OM_DEV_SPLASH_PORT=4100 docker compose --project-directory . -f starters/docker/compose.fullapp.dev.yml up --build
Container fails to start on Windows:
core.autocrlf=input to avoid CRLF issues in shell scriptsFile changes not detected:
CHOKIDAR_USEPOLLING=true and WATCHPACK_POLLING=true by default. If changes are still not picked up, restart the app container:
docker compose --project-directory . -f starters/docker/compose.fullapp.dev.yml restart app
Port conflicts:
APP_PORT=3001 docker compose --project-directory . -f starters/docker/compose.fullapp.dev.yml upOM_DEV_SPLASH_PORT=4100 docker compose --project-directory . -f starters/docker/compose.fullapp.dev.yml upyarn generate, yarn db:generate) and localhost:5432 is occupied by another local PostgreSQL instance, start Docker Postgres on another port and use the same port in DATABASE_URL:
POSTGRES_PORT=55432 docker compose --project-directory . -f starters/docker/compose.infra.yml up -d postgres
DATABASE_URL=postgresql://postgres:<url-encoded-password>@localhost:55432/open-mercato
Slow file watching on Windows/WSL 2:
\\wsl$\Ubuntu\home\...) rather than on the Windows filesystem (/mnt/c/...) for significantly better I/O performance.Run the complete Open Mercato stack with Docker Compose, including the application, PostgreSQL, Redis, and Meilisearch. This approach is ideal for quick demos, testing, or containerized deployments.
.env file (see Environment Variables below)# Clone the repository
git clone https://github.com/open-mercato/open-mercato.git
cd open-mercato
# Copy environment template
cp apps/mercato/.env.example apps/mercato/.env
# Edit apps/mercato/.env with your configuration (see next section)
# Build and start all services
docker compose --project-directory . -f starters/docker/compose.fullapp.yml up --build
The application will be available at http://localhost:3000/backend. Sign in with the default admin credentials printed during initialization (typically [email protected]).
Before starting the Docker stack, configure apps/mercato/.env with at least these required variables:
# Database (container uses these to initialize PostgreSQL)
POSTGRES_USER=postgres
POSTGRES_PASSWORD="<postgres-password>"
POSTGRES_DB=open-mercato
DATABASE_URL=postgres://postgres:<url-encoded-password>@postgres:5432/open-mercato
# Authentication — required. Generate with `openssl rand -hex 32`.
# Compose reads this from the .env file next to the compose file, not apps/mercato/.env.
JWT_SECRET=
# Application
APP_URL=http://localhost:3000
NODE_ENV=development
# Caching
CACHE_REDIS_URL=redis://redis:6379
CACHE_STRATEGY=redis
# Search (optional but recommended)
MEILISEARCH_HOST=http://meilisearch:7700
MEILISEARCH_API_KEY="<meilisearch-api-key>"
MEILISEARCH_MASTER_KEY="<meilisearch-master-key>"
# AI Features (optional)
OPENAI_API_KEY="<openai-api-key>"
# Vector search auto-indexing is off by default in the shipped example env.
# Enable it only when you want real-time embedding jobs:
OM_DISABLE_VECTOR_SEARCH_AUTOINDEXING=false
If you keep OM_DISABLE_VECTOR_SEARCH_AUTOINDEXING=true (the default in apps/mercato/.env.example), semantic search can still be configured and reindexed manually, but record changes will not enqueue embeddings automatically. The legacy alias DISABLE_VECTOR_SEARCH_AUTOINDEXING=1 still works, but prefer the OM_ name for new setups.
Note: The container hostnames (postgres, redis, meilisearch) match the service names in starters/docker/compose.fullapp.yml.
Start services in detached mode:
docker compose --project-directory . -f starters/docker/compose.fullapp.yml up -d
View logs from all services:
docker compose --project-directory . -f starters/docker/compose.fullapp.yml logs -f
View logs from app only:
docker compose --project-directory . -f starters/docker/compose.fullapp.yml logs -f app
Rebuild after code changes:
docker compose --project-directory . -f starters/docker/compose.fullapp.yml up --build
Stop all services:
docker compose --project-directory . -f starters/docker/compose.fullapp.yml down
Stop and remove volumes (deletes all data):
docker compose --project-directory . -f starters/docker/compose.fullapp.yml down -v
Restart a specific service:
docker compose --project-directory . -f starters/docker/compose.fullapp.yml restart app
Data is stored in named Docker volumes. Volume names end with your DEPLOY_ENV value (local by default):
mercato-postgres-data-local - PostgreSQL databasemercato-redis-data-local - Redis cache and eventsmercato-meilisearch-data-local - Meilisearch indexesmercato-attachments-storage-local - Uploaded attachmentsVolumes persist between container restarts unless explicitly removed with docker compose down -v.
Backup volumes:
# Backup PostgreSQL
docker compose --project-directory . -f starters/docker/compose.fullapp.yml exec -T postgres pg_dump -U postgres open-mercato > backup.sql
# Restore PostgreSQL
cat backup.sql | docker compose --project-directory . -f starters/docker/compose.fullapp.yml exec -T postgres psql -U postgres -d open-mercato
When deploying to production environments, consider these recommendations:
Security:
JWT_SECRET (use openssl rand -base64 32)POSTGRES_PASSWORD and MEILISEARCH_MASTER_KEYInfrastructure:
Monitoring & Operations:
Application Configuration:
NODE_ENV=production in production environmentsAPP_URL with your domainContainer fails to start:
# Check logs for errors
docker compose --project-directory . -f starters/docker/compose.fullapp.yml logs app
# Verify environment variables
cat apps/mercato/.env
# Check if ports are already in use
lsof -i :3000
lsof -i :5432
lsof -i :6379
Database connection errors:
# Verify PostgreSQL is running
docker compose --project-directory . -f starters/docker/compose.fullapp.yml ps postgres
# Check if database exists
docker compose --project-directory . -f starters/docker/compose.fullapp.yml exec postgres psql -U postgres -c "\l"
# Verify DATABASE_URL matches container configuration
grep DATABASE_URL apps/mercato/.env
Build errors:
# Clean build cache
docker compose --project-directory . -f starters/docker/compose.fullapp.yml build --no-cache
# Remove old images
docker image prune -a
Out of disk space:
# Check Docker disk usage
docker system df
# Clean up unused resources
docker system prune -a --volumes
Reset everything:
# Stop and remove all containers, networks, and volumes
docker compose --project-directory . -f starters/docker/compose.fullapp.yml down -v
# Rebuild from scratch
docker compose --project-directory . -f starters/docker/compose.fullapp.yml up --build
The starters/docker/compose.fullapp.yml stack includes:
Services communicate via a dedicated Docker network (mercato-network-fullapp) and use health checks to ensure proper startup order.
For advanced/manual flows (custom migration control, selective seeding, etc.) see the CLI reference in the repository README.