Skip to main content
BackAnt’s code generator lets you scaffold routes with mock data so your API is immediately testable without a database. Seeding in BackAnt means replacing that generated mock data with real repository calls.

How mock data is generated

When you run ant generate route users --mock '[{"id": 1, "name": "Alice"}]', the generated service returns the mock data directly:

Replacing mock data with real logic

Open the service file and replace the mock return with a repository call:
Then implement get_all_users() in the repository:

Seeding initial data

To seed the database with initial records, add a seed function to a repository and call it from init_db() in startup/Alchemy.py:

Using the dry-run flag

Before generating a project, you can validate a spec without creating any files:
This lets you iterate on your spec (including mock data) until it’s correct, then generate for real.

Mock data formats

Mock data can be any valid JSON value:
Mock data is embedded directly in the generated Python file as a literal — replace it with real repository calls when you are ready to connect to the database.