# Package simulators

A **package simulator** is a small product-owned package that uses
`@x12i/api-simulator` as the engine and ships its own:

- **logic** — `simulation` handlers (and optional `createStore` state)
- **data** — seeds under `api.data` and/or fixture JSON
- **metadata** — when the product speaks Memorix, declarative packs and explorer fixtures

The core library stays **zero runtime dependencies** and does not load data or
metadata from disk, MongoDB, or HTTP. Your package (or an example like
[`examples/flowstate-simulator`](../examples/flowstate-simulator)) owns that.

## With `@x12i/static-memorix`

For Memorix Explorer (`/api/explorer/*`) and Metadata (`/api/metadata/*`)
parity without MongoDB/Redis, compose
[`@x12i/static-memorix`](https://www.npmjs.com/package/@x12i/static-memorix):

1. Keep a shared `mocks/` tree (`data/`, `metadata/`, `metadata-packs/`).
2. Load seeds into package REST via small helpers (see the FlowState example’s
   `src/bridge.mjs`).
3. Run `buildServer()` / `startServer()` with `MOCKS_DIR` pointing at that tree.
4. Optionally serve one port: `tryDispatch` package routes, then forward misses
   to static-memorix (`inject` or a reverse proxy).

Full walkthrough: [`examples/flowstate-simulator/TUTORIAL.md`](../examples/flowstate-simulator/TUTORIAL.md).

## Without Memorix

If the API is ordinary REST, follow
[`examples/library-demo/TUTORIAL.md`](../examples/library-demo/TUTORIAL.md) —
data modules + simulations + `createApiSimulator`, no static-memorix.
