Skip to the article
Aniq-UI

Dashboard 2The built-in mock API

The built-in mock API

How the dashboard runs with no back-end on sample data kept in the browser, what works there, and how to switch it to your API or remove it.

For the Full Stack package

What it is

The dashboard carries a small server of its own that runs in the browser. It answers every request the dashboard makes, with the same answers, status codes and permission checks as the NestJS API, so every screen works with no back-end at all. It is what the Admin Dashboard package runs on out of the box, and what the Full Stack's dashboard falls back to when no API address is set.

A "Sample data" notice sits at the bottom of every page while it answers, so nobody mistakes it for a connected back-end.

Turning it on and off

There is no flag. One setting decides, NEXT_PUBLIC_API_BASE_URL, compiled in when the dashboard is built:

.env
# empty or missing: the mock API, no back-end needed
NEXT_PUBLIC_API_BASE_URL=

# set: your API, the mock never runs
NEXT_PUBLIC_API_BASE_URL=http://localhost:8000/api
  • Without Docker, the dashboard with no .env file runs on the mock. Restart yarn dev, or run yarn build again, after changing the value.
  • A Docker image built with no --build-arg runs on the mock. Docker Compose always builds the dashboard with the API's address.
  • When a browser that used the mock is pointed at a real API, the dashboard drops the sample session and data it kept, so the first request is not made with a token the API would refuse.

What works on it

AreaOn the mock API
Sign-inThe sample accounts: admin@example.com with Admin@123 (Super Admin), and the sample Viewers such as john.smith@admin.com with admin123. A wrong password is refused, as on the API.
DataThe API's own sample data: 12 admins, 5 roles and 25 permissions, 15 users and 12 deleted ones, 15 projects and 12 deleted ones, the Super Admin's 10 tasks, 13 app settings and 50 countries, plus three earlier assistant conversations.
ChangesReal: creating, editing, deleting, restoring, granting a permission and renaming a role all change the data and survive a reload, in that browser only.
PermissionsChecked from the signed-in admin's roles and refused as the API refuses them, so a Viewer sees exactly what a read-only account sees.
PicturesAn uploaded picture is kept in the browser and shows; nothing leaves it.
AI assistantOne model, Aniq Demo, with scripted answers built from the current data: figures, cards, lists and a chart. No provider, no key.

Every answer is delayed a fraction of a second on purpose, so the loading states the dashboard ships with are seen.

Start over

Clear the site's data for the dashboard's address in your browser's settings, or run this in the browser's console, and the samples come back as they shipped:

Browser console
localStorage.removeItem("mock_db_v1"); location.reload();

Remove it

Once you run on your own API for good, delete the mock from the code, in the dashboard's folder:

Terminal
yarn remove:mock

It deletes src/lib/mock/ and the sample data notice, and strips the blocks marked #region mock-api. The dashboard then needs NEXT_PUBLIC_API_BASE_URL set. It rewrites files and cannot be undone without version control, so commit first.

How it is built

Included with your purchase. Sign in to read, or open it in your download.

Where the mock lives, how a request reaches it, and adding a route of your own.

Stuck on a step?

Find a fix before you start over.

Troubleshooting

Cookie Preferences

We use cookies to enhance your browsing experience, analyze site traffic, and personalize content. By clicking "Accept All", you consent to our use of cookies for analytics and personalized advertising.