A CLI tool to generate backant backend projects
Project description
Backant CLI
Backant CLI is a powerful Linux native command-line interface designed to streamline the development of Flask-based REST APIs. It automates the generation of a complete and scalable project structure, allowing developers to focus on business logic rather than boilerplate code.
Key Features
- Automated Project Scaffolding: Generate a new Flask API with a single command, including a well-organized directory structure.
- Layered Architecture: The generated project follows a clean, layered architecture (Models, Repositories, Services, Routes) to promote separation of concerns and maintainability.
- Database-Ready: Includes SQLAlchemy for database modeling and interaction, with a pre-configured
DBSessionfor easy database access. - Dockerized Environment: Comes with
Dockerfileanddocker-compose.ymlfiles for a consistent development and production environment. - Extensible by Design: Easily add new routes, services, and models using the provided CLI commands.
- Pre-configured for Deployment: Includes a GitHub Actions workflow for building and pushing Docker images to Amazon ECR.
Installation
Ubuntu/Debian (Recommended)
Install the Backant CLI using the .deb package for Ubuntu/Debian systems:
# Download and install the .deb package
sudo dpkg -i backant-cli.deb
Alternative: Python Package
You can also install using pip:
pip install backant-cli
Getting Started
Generating a New API
To create a new Flask API project, use the generate api command:
ant generate api <your_project_name>
This will create a new directory named <your_project_name> with the complete project structure.
Generating API from JSON Specification
You can generate a complete API with routes and subroutes from a JSON specification using the --json option:
Using JSON String:
ant generate api my-project --json '{"routes": {"products": {"type": "GET", "subroutes": {"create": {"type": "POST"}}}}}'
Using JSON File:
ant generate api ecommerce --json api-spec.json
Additional Options:
--verboseor-v: Show detailed generation progress--dry-run: Validate JSON specification without generating files
Examples:
# Generate API with verbose output
ant generate api shop --json api-spec.json --verbose
# Validate JSON specification without creating files
ant generate api test --json api.json --dry-run
JSON Specification Format:
The JSON specification should follow this structure:
{
"routes": {
"route_name": {
"type": "GET|POST|PUT|DELETE",
"mock": {},
"subroutes": {
"subroute_name": {
"type": "GET|POST|PUT|DELETE",
"mock": {}
}
}
}
}
}
Generating a New Route
Once you have a project, you can easily add new routes and their corresponding components (service, repository, model) with the generate route command:
ant generate route <your_route_name>
This command will automatically create:
- A new route in
api/routes/ - A new service in
api/services/ - A new repository in
api/repositories/ - A new model in
api/models/
Generating a Mock Route
You can also generate a route with mock data for testing and development purposes. Use the --mock option with a JSON string or a path to a JSON file.
Using a JSON String:
ant generate route <your_route_name> --mock '{"key": "value", "another_key": "another_value"}'
Using a JSON File:
ant generate route <your_route_name> --mock /path/to/your/mock_data.json
This will generate the same files as the standard generate route command, but the service will return the provided JSON data.
Project Structure
The generated project follows a structured and scalable architecture:
<your_project_name>/
├── api/
│ ├── apis/ # For third-party API integrations
│ ├── decorators/ # Custom decorators (e.g., for authentication)
│ ├── helper/ # Helper functions and utilities
│ ├── models/ # SQLAlchemy database models
│ ├── repositories/ # Data access layer
│ ├── routes/ # API endpoints (controllers)
│ ├── schemas/ # Data validation schemas
│ ├── services/ # Business logic layer
│ └── startup/ # Application startup and configuration
├── .github/
│ └── workflows/ # CI/CD workflows
├── .gitignore
├── docker-compose.yml
├── Dockerfile
└── requirements.txt
Telemetry
BackAnt CLI includes opt-in anonymous telemetry to help us improve the tool. On first run, you'll be asked if you want to participate.
Quick Disable
# Environment variable (permanent)
export DO_NOT_TRACK=1
# Per-command flag
ant --no-telemetry generate api my-project
# View telemetry settings
ant --privacy
We never collect file paths, project names, usernames, or any personally identifiable information. See docs/telemetry.md for full details.
Contributing
Contributions are welcome! If you have any ideas, suggestions, or bug reports, please open an issue or submit a pull request.
Development Setup
- Clone the repository:
git clone https://github.com/backant/backant-cli.git
- Create a virtual environment:
python3 -m venv venv source venv/bin/activate
- Install the dependencies:
pip install -r requirements.txt
- Install the CLI in editable mode:
pip install -e .
Now you can run the CLI locally using the ant command.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file backant_cli-0.7.3.tar.gz.
File metadata
- Download URL: backant_cli-0.7.3.tar.gz
- Upload date:
- Size: 28.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f86962e6d98490d604de25741fb2850bc7999e086e122746920cf3ee84d16efe
|
|
| MD5 |
5b1d42ada9fb1e641cf9f908d15260fc
|
|
| BLAKE2b-256 |
1aeca3f32333acf979d1000fbd16a99233ad16c5d68b98633d468d5f8345bd37
|
Provenance
The following attestation bundles were made for backant_cli-0.7.3.tar.gz:
Publisher:
publish.yml on backant-io/backant-cli
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
backant_cli-0.7.3.tar.gz -
Subject digest:
f86962e6d98490d604de25741fb2850bc7999e086e122746920cf3ee84d16efe - Sigstore transparency entry: 1012023950
- Sigstore integration time:
-
Permalink:
backant-io/backant-cli@1ffe0c6d20b825b8f55b4d43bb406c856e131029 -
Branch / Tag:
refs/tags/v0.7.3 - Owner: https://github.com/backant-io
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@1ffe0c6d20b825b8f55b4d43bb406c856e131029 -
Trigger Event:
release
-
Statement type:
File details
Details for the file backant_cli-0.7.3-py3-none-any.whl.
File metadata
- Download URL: backant_cli-0.7.3-py3-none-any.whl
- Upload date:
- Size: 36.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
96c633809c9c1c118bfe7bf0160ffdc4ffd6831791aae01158d3768f0ca614d4
|
|
| MD5 |
ac61120720af88131379dc50aa94255c
|
|
| BLAKE2b-256 |
db1097db9bcc2e70cfa0b33f2b41be049f5dd2c911e9eb089f46779db1d2314f
|
Provenance
The following attestation bundles were made for backant_cli-0.7.3-py3-none-any.whl:
Publisher:
publish.yml on backant-io/backant-cli
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
backant_cli-0.7.3-py3-none-any.whl -
Subject digest:
96c633809c9c1c118bfe7bf0160ffdc4ffd6831791aae01158d3768f0ca614d4 - Sigstore transparency entry: 1012024012
- Sigstore integration time:
-
Permalink:
backant-io/backant-cli@1ffe0c6d20b825b8f55b4d43bb406c856e131029 -
Branch / Tag:
refs/tags/v0.7.3 - Owner: https://github.com/backant-io
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@1ffe0c6d20b825b8f55b4d43bb406c856e131029 -
Trigger Event:
release
-
Statement type: