PrimLagic

A full demo with no backend: mocking the API with axios-mock-adapter

By Ali Abdolahi · · 1 min read

A full demo with no backend: mocking the API with axios-mock-adapter

I wanted a public ClassBan demo without a database or server, and above all without real data or SMS keys anywhere near it. The solution: simulate the entire backend inside the browser.

The idea

All ClassBan pages send requests through one shared axios instance. Intercept that instance with axios-mock-adapter and I can build the response for every URL (such as /api/students). No page changes; the real interface stays untouched.

What is simulated

Username login and phone login with a fixed verification code; students, teachers, absences and message templates (full CRUD); SMS sending (only written to the log, nothing is sent); users and roles with the same restrictions as the real app (an assistant cannot open user management); dashboard statistics. Data lives in memory and sessionStorage and resets every 30 minutes or with the reset button.

Fake data

Students get made-up Persian names from random first and last name combinations and phone numbers from an unreal 0900000xxxx pattern. The random generator uses a fixed seed so every visitor starts from the same data and resets are predictable.

Benefits

Deployment is one static build; there is no database, key or real data; each visitor gets their own copy and cannot hurt anyone else.

Limits (honestly)

Backend logic is written twice and can drift. Direct fetch calls are not intercepted; ClassBan's "forgot password" page used fetch and needed a separate fix. It does not test real server security. The seven-day SMS chart has no per-day data and stays flat.

If the goal is to show the interface and workflow, mocking the API is the cheapest route. If the goal is to test real server behaviour, it is not. See the demo at classban.primlagic.ir and the product page at ClassBan.

Reactdemoarchitecture