Skip to main content

A CLI tool for scaffolding Python backend projects

Project description

backendctl

Stop rewriting the same boilerplate. Start with a solid foundation.

backendctl is an interactive CLI that generates a batteries-included backend project — auth, database, migrations, rate limiting, tests, linting, and optional AI-assistant config — for the framework of your choice. Pick FastAPI, Flask, or Django REST Framework, answer a few questions, and start coding your actual business logic.

Features

  • Three frameworks — FastAPI (SQLModel), Flask (SQLAlchemy), or Django REST Framework.
  • JWT auth out of the box — register / login / refresh, Argon2 password hashing, a User model, and a /users/me endpoint.
  • Database choice — PostgreSQL (with SQLite for tests), MongoDB, or both.
  • Sane defaults — rate limiting, CORS, env-based config, layered settings.
  • Migrations — Alembic (FastAPI), Flask-Migrate, or Django migrations.
  • Tests includedpytest suite wired up with fixtures.
  • Toolingruff, mypy, .pre-commit-config.yaml, .editorconfig.
  • AI-assistant ready — optional CLAUDE.md/AGENTS.md, .cursorrules, mcp.json, and SDK dependency.
  • uv or pip — your choice of package manager.

Installation

Requires Python 3.11+.

# Run without installing (recommended)
uvx backendctl new

# Or install as a tool
uv tool install backendctl

# Or with pip
pip install backendctl

From source

git clone https://github.com/dipto0321/backendctl
cd backendctl
uv sync
uv run backendctl --help

Usage

Interactive wizard

backendctl new

You'll be guided through:

  1. Project name
  2. Package manager (uv / pip)
  3. Framework (FastAPI / Flask / Django REST Framework)
  4. Database (PostgreSQL+SQLite / MongoDB / both)
  5. Database name / user / password (defaults: slug / slug / auto-generated)
  6. Authentication (JWT / none)
  7. Optional name field on the User model
  8. AI-assistant config (Claude / OpenAI / none)
  9. Git initialization

Non-interactive flags

Any flag you pass skips the matching wizard step:

backendctl new myapi --framework fastapi --db postgres --pm uv --no-ai
Flag Values Description
project_name string Name of the new project (positional).
--framework, -f fastapi | flask | django Web framework.
--db postgres | mongodb | both Database.
--db-name string Database name (default: project slug).
--db-user string PostgreSQL user (default: project slug).
--db-password string PostgreSQL password (default: auto-generated).
--pm uv | pip Package manager.
--no-git flag Skip git initialization.
--no-ai flag Skip AI-assistant setup.
--version, -v flag Print version and exit.

What you get

After generation, backendctl runs pre-flight checks, writes the project, sets up git (optional), and installs dependencies. A docker-compose.yml is generated for your chosen database, and .env ships with working credentials that already match it — no manual copying or editing required to get a database running. Then:

cd myapi
docker compose up -d      # start the database
uv run fastapi dev        # or: flask run / python manage.py runserver

Generated project layout

FastAPI
myapi/
├── src/myapi/
│   ├── main.py                 # app factory + lifespan
│   ├── core/                   # config, database, security
│   ├── middleware/             # rate limiting
│   ├── api/v1/router.py        # versioned router
│   └── modules/
│       ├── auth/               # models, schemas, service, deps, router
│       └── users/              # /me endpoint
├── alembic/                    # migrations
├── tests/                      # pytest suite
├── pyproject.toml
└── .env.example
Flask
myapi/
├── src/myapi/
│   ├── __init__.py             # app factory
│   ├── config.py               # Config / TestConfig
│   ├── extensions.py           # db, jwt, limiter, migrate
│   ├── models/user.py
│   └── blueprints/
│       ├── auth/               # routes + service
│       └── users/              # /me endpoint
├── migrations/                 # Flask-Migrate
├── tests/
├── pyproject.toml
└── .env.example
Django REST Framework
myapi/
├── config/
│   ├── settings/               # base / development / production
│   ├── urls.py, wsgi.py, asgi.py
├── apps/
│   ├── users/                  # custom User model + /me
│   └── authentication/         # register + JWT token views
├── core/                       # pagination, exception handler
├── tests/
├── manage.py
├── pyproject.toml
└── .env.example

Development

uv sync                 # install dev dependencies
uv run pytest           # run the test suite
uv run ruff check src   # lint
uv run ruff format src  # format
uv run mypy src         # type-check

The repository is laid out as:

src/backendctl/
├── main.py              # Typer entry point
├── cli/new.py           # `new` command + interactive wizard
├── core/                # config dataclasses, console helpers, pre-flight checks
├── generators/          # per-framework file writers (BaseGenerator + subclasses)
└── templates/           # pure functions returning file contents

To add or change generated output, edit the relevant function in templates/ and the matching _scaffold() in generators/. The test suite compiles every generated .py file, so syntax regressions are caught automatically.

License

MIT © Dipto Karmakar

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

backendctl-0.3.0.tar.gz (81.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

backendctl-0.3.0-py3-none-any.whl (39.6 kB view details)

Uploaded Python 3

File details

Details for the file backendctl-0.3.0.tar.gz.

File metadata

  • Download URL: backendctl-0.3.0.tar.gz
  • Upload date:
  • Size: 81.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for backendctl-0.3.0.tar.gz
Algorithm Hash digest
SHA256 9c7d0b284da9a5e9f0437a5810478f737c7a142341d57aa5f5a7dc16d5ce08e9
MD5 bfc7ddd18c3770627282fe35ed8ecda5
BLAKE2b-256 a9e5d6aa91533c9ddf1849350679a07833f128e29850a9c2a357dc71f6f1782d

See more details on using hashes here.

File details

Details for the file backendctl-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: backendctl-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 39.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for backendctl-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 177a30d9637abd28b3aa1b57e8842737f3380dbb09c5001bbe1b689fd609540d
MD5 21eaa0512eee76873ad45f8197505a15
BLAKE2b-256 03ebcec3b6f70993750490fa868b197d3c5c09a59dfe11253f708c5e71340e44

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page