Docs_archive
Marketplace V2 scaling
Source docs/MARKETPLACE_V2_SCALING.md · All_docs
English product/ops notes for the in-app marketplace (app/).
1. Large catalogs (worker + DB index)
Problem: Redis + live registry fan-out works for moderate catalogs; very large federations need a durable index and a background rebuild.
Shipped:
- Table
marketplace_catalog_rows(registry_id,handle,agentJSONB,updated_at). npm run marketplace:index-sync— rebuilds the index from enabled registries and busts the Redis catalog cache.POST /api/marketplace/index-rebuild(operator) — same as the script, for cron or automation.MARKETPLACE_CATALOG_SOURCE=db—GET /api/marketplacereads from the index. If the index is empty, it falls back to the live Redis path (meta.catalog: db_fallback).
Recommended ops:
- Run migrations:
npm run db:migrate:run - Initial fill:
npm run marketplace:index-sync(or operator POSTindex-rebuild) - Cron (e.g. hourly): call
index-rebuildor run the script - Set
MARKETPLACE_CATALOG_SOURCE=dbwhen the index is populated
Next steps (not implemented): incremental per-registry sync, partial updates, and SQL-side search on extracted columns for multi-million-row catalogs.
2. Pagination and infinite scroll
Shipped:
GET /api/marketplacesupportslimit(max 200),offset,sort=name|handle,q,tags,registryUrl(normalized match).- Response includes
meta.tags— full-catalog tag union for filter chips while the grid is paginated. - UI: infinite scroll (intersection observer) + Load more, Sort (Name / Handle), server-driven search and filters.
3. E2E tests and CI
Shipped:
- Playwright (
@playwright/test), configapp/playwright.config.ts, specapp/e2e/marketplace.spec.ts. - The test is skipped unless
E2E_EMAILandE2E_PASSWORDare set (seeded admin or dedicated test user).
Run locally:
cd app
npx playwright install # once per machine
E2E_EMAIL=admin@... E2E_PASSWORD=... npm run test:e2e
CI: add a job that starts Postgres + Redis + npm run dev (or start), runs migrations + seed, then test:e2e with secrets from the vault. Keep smoke minimal (login + marketplace heading).
4. Product beyond the catalog (roadmap)
Not implemented as product features; planned scope:
Implementation map (main app vs marketplace service): see BILLING_METERING_SOURCES.md. ADR (Stripe + internal credits): ADR/001-billing-stripe-internal-credits.md.
Use this doc as the handoff for prioritizing V2.1+ work.