Skip to main content
ant generate route generates all four layers for a new resource inside an existing project — route, service, repository, and model — and wires them into app.py and Alchemy.py automatically.

Syntax

ant generate route <name> [--mock <json>]
Run this command from the project root — the directory that contains api/.

Arguments

ArgumentDescription
nameRoute name (e.g. users, products). Must be a valid Python identifier.

Options

OptionDescription
--mock <json>JSON string or path to a .json file. The generated service returns this data instead of a placeholder string.

Examples

Basic route

ant generate route users

With inline mock data

ant generate route users --mock '[{"id": 1, "name": "Alice"}]'

With mock data from file

ant generate route users --mock mock_data.json

Machine-readable output

ant --report generate route users

Files created

FileDescription
api/routes/users_route.pyFlask Blueprint at /users with GET "" endpoint
api/services/users_service.pyService class with get_users() method
api/repositories/users_repository.pyRepository class with CRUD stubs
api/models/Users_model.pySQLAlchemy model (capitalized name)

Files modified

FileChange
api/startup/Alchemy.pyAdds import models.Users_model inside init_db()
api/app.pyAdds from routes.users_route import users_bp and app.register_blueprint(users_bp)

Success output

Successfully generated route, service, repository, and model for 'users'!
Successfully generated route, service, repository, and model for 'users' with mock data!

Naming rules

InputGenerated
Route fileapi/routes/users_route.py
Blueprint variableusers_bp
URL prefix/users
Service classUsersService
Repository classUsersRepository
Model classUsers
Table nameusers
Names must be valid Python identifiers: letters, digits, and underscores only, cannot start with a digit.
✅ users, user_posts, api_keys
❌ my-route, 1users, user posts