← back to Microsite Engine

README.md

39 lines

# microsite-engine

A config-generator dashboard that **drives the `dw-domain-fleet`** — the platform
that runs the 40+ generic DW sister microsites (one shared Express app, one
`sites/<slug>.json` per site, over a shared `data/catalog.json`).

Instead of hand-editing a `sites/<slug>.json` and guessing the niche keywords,
you: define the site → **preview the exact product grid live against all ~15k real
products** (identical `nicheSlice`/`sortProducts` logic to production) → emit a
validated, deploy-ready `sites/<slug>.json`.

It **reinvents nothing** — it `require()`s the fleet's own `shared/catalog.js` and
`shared/sort.js` and reads its `data/catalog.json`, all read-only.

## Run
```bash
node server.js                 # http://localhost:9770  (admin / DW2024!)
FLEET_DIR=/path/to/dw-domain-fleet node server.js   # point at a different fleet checkout
NO_AUTH=1 node server.js       # drop basic auth (local only)
```

## What it does
- **Live niche preview** — match count + a sortable, density-adjustable product grid
  that updates as you edit the include/exclude keywords + product types.
- **Facets helper** — real product-types + top tags pulled from the catalog, click to add.
- **Generate** — writes `output/<slug>.json` in the fleet's **exact schema**, assigns the
  next free port, and runs a **collision guard** (warns if slug/domain/port already
  exists in the live fleet).
- **Saved drafts** — admin cards, each with created date + time, niche summary, live match count.

## Hard gates (by design)
- **Never writes into the live fleet `sites/` dir. Never deploys. Never touches DNS.**
- Generated configs land in this project's `output/`; a `cp … sites/<slug>.json` command is
  surfaced for Steve to run (staging into the fleet is a manual, gated step).

## Endpoints
`/api/facets` · `/api/preview` (POST) · `/api/generate` (POST) · `/api/live-sites` ·
`/api/drafts` · `/api/delete-draft` (POST) — all behind basic auth `admin / DW2024!`.