Local JSON fake API
Use editable sample JSON and asynchronous browser-only requests without running a backend.
Default data flow
React pages → BusinessProvider or AdminProvider → fake API request → local JSON seed or saved browser records → JSON response → React state. The shipped template needs no backend server.
Files to customize
| File | Purpose |
|---|---|
| src/data/mock/workspace.json | Customers, projects, products, orders and activity seed records. |
| src/data/mock/admin.json | Team members, support tickets, file metadata, subscription plan and audit seed records. |
| src/services/fakeBackend.ts | Scoped asynchronous Request/Response transport, browser persistence and errors. |
| src/features/business/seed.ts | Validates workspace JSON and shifts dates to keep sample reporting periods current. |
| src/features/admin/model.ts | Validates admin JSON and handles admin actions. |
| src/config/backend.ts | Demo/HTTP selection for the connected workspace. |
Requests and responses
GET /workspace and GET /admin load complete snapshots. POST /workspace/actions and POST /admin/actions accept typed actions and return the committed snapshot. The browser-only transport uses Request, Response and JSON serialization with a short delay. It does not send a network request or install a global fetch interceptor. The fake-api.invalid URL is only a request identifier, never a network destination.
This is API-style simulation. Browser Network tools will not show these simulated POST requests. For actual network traffic, use your own backend with HTTP mode, or the separate optional customer CRUD teaching server in the mock-backend chapter.
Edit and reset records
- Edit the relevant JSON file and preserve the documented types and record IDs.
- Rebuild or let Vite reload the source.
- For workspace records, use Workspace settings → Reset demo so saved records do not hide the new JSON.
- For admin records, clear only navrenza:admin:v1 in browser storage and reload.
Successful changes are saved under adminbag:business:v2 or navrenza:admin:v1. JSON files on disk are never overwritten. Uploaded file bytes use IndexedDB separately. Different origins keep separate demo records.
Loading and errors
Providers load asynchronously and show a retry state for failed loads. Saves are awaited before closing forms or showing success. Workspace failure simulation rejects saves without changing records. Demo role restrictions are checked at the mutation boundary. Browser storage failures retain in-memory records and show a persistence warning.
Scope and buyer integration
This JSON service covers connected workspace and admin operations. Legacy dashboard charts, component examples and other showcase fixtures are still illustrative page data, not a complete API. The existing HTTP switch connects the workspace contract; replace the admin service with your own endpoints when building real team, support, files or billing workflows. No production authentication, database or payment backend is supplied.
Keep page components and typed data contracts. Replace the fake transport with your fetch/Axios service, map your API responses and enforce authorization on your server. Read Demo / API switch for the workspace configuration.