Skip to main content

flaskforge

A Django-like CLI for Flask. It scaffolds a large, well-structured Flask project (app factory, settings per environment, Django-style INSTALLED_APPS, tests, Docker) and wires up Flask extensions with a single command.

pipx install flaskforge-cli          # or: pip install flaskforge-cli
flaskforge startproject shop --preset web
cd shop
python -m venv .venv && source .venv/bin/activate
pip install -r requirements-dev.txt
python manage.py makemigrations -m "initial" && python manage.py migrate
python manage.py createsuperuser
python manage.py runserver           # http://127.0.0.1:8000

The PyPI package is called flaskforge-cli; the command and the Python package are flaskforge. Requires Python 3.9+.

Commands

Global (flaskforge ...):

Command What it does
startproject NAME [DIR] [--preset P] [-e EXT,...] [--install] Create a project. Presets: minimal, web, api, full
startapp NAME [--api] Create an app under apps/ and register it in INSTALLED_APPS
add EXT... [--no-install] [--force] pip install extensions and wire them into the project
extensions List supported extensions and which are installed

startapp, add and extensions work from any subdirectory of a project.

Initialising inside an existing directory (e.g. a fresh git clone)

git clone git@github.com:you/flask-notes-app.git && cd flask-notes-app
flaskforge startproject flask_notes . --preset web

startproject works in a non-empty directory. Existing files are never clobbered:

Existing file What happens
README.md kept exactly as is
.gitignore missing entries are appended, your lines stay first
.env, .env.example missing KEY=value pairs are appended, your values stay
.git/, LICENSE, any file flaskforge does not generate untouched
any other file flaskforge generates (manage.py, config/settings.py, ...) conflict

All conflicts are detected before anything is written; if there are any, the command lists them and exits without changing a single file. Move the files away, or pass --force to overwrite them (README.md, .gitignore and .env files are still preserved, and directories are never replaced). Use --dry-run to preview the result without writing anything.

Project-level (python manage.py ...) - the commands above plus:

Command What it does
runserver [-h HOST] [-p PORT] Dev server (port 8000, autoreload and debugger in development)
makemigrations [-m MSG] Create migrations (runs init the first time)
migrate / rollback Apply / revert migrations
createsuperuser Create an admin user (when login is installed)
check Load the app and report blueprints and routes
shell, routes, run Built-in Flask commands

Generated layout

config/settings.py   Base / Development / Testing / Production configs, INSTALLED_APPS
core/__init__.py     create_app() factory; loads every app in INSTALLED_APPS
core/extensions.py   extension instances (db, login_manager, ...), filled in by `add`
apps/<name>/         views.py (bp), models.py, templates/<name>/, tests in tests/
templates/ static/   shared templates (base.html) and assets
tests/               pytest, with app/client fixtures
wsgi.py Dockerfile .env

Each app in INSTALLED_APPS is auto-loaded:

File Purpose
models.py Imported so the ORM and migrations see your models
events.py Imported (e.g. Flask-SocketIO handlers)
admin.py Imported (Flask-Admin model views, like Django's admin.py)
views.py Must define bp (or a blueprints list)
commands.py commands = [...] are added to the CLI

Apps are named in the plural and classes in the singular: startapp products creates apps/products/ (URL /products/, templates in products/) with Product, ProductForm and ProductSchema; only the last word of a snake_case name is singularized (blog_categories -> BlogCategory), and irregular plurals (people -> Person) and uncountable words (news -> News) are handled.

Blueprints mounted under /api are exempt from CSRF (token-authenticated JSON APIs).

Supported extensions

Key Package Notes
sqlalchemy Flask-SQLAlchemy db, TimestampMixin in core/mixins.py
migrate Flask-Migrate Requires sqlalchemy
login Flask-Login Scaffolds apps/accounts (User, register, login, logout, createsuperuser)
admin Flask-Admin Panel at /admin, restricted to is_admin users; requires login
wtf Flask-WTF Forms and global CSRF protection
mail Flask-Mail
cors Flask-CORS Applied to /api/*
jwt Flask-JWT-Extended
cache Flask-Caching
limiter Flask-Limiter
babel Flask-Babel
marshmallow Flask-Marshmallow Requires sqlalchemy
socketio Flask-SocketIO runserver uses socketio.run() automatically
debugtoolbar Flask-DebugToolbar Dev dependency, active only when DEBUG=True
talisman Flask-Talisman HTTPS forced in production
compress Flask-Compress

Dependencies are resolved automatically (add admin also adds login and sqlalchemy). Add a new extension by appending one Extension(...) entry to src/flaskforge/registry.py.

Admin panel

python manage.py add admin
python manage.py createsuperuser
python manage.py runserver
# sign in at /accounts/login, then open /admin/

Register models of your own apps in apps/<name>/admin.py (generated automatically by startapp when admin is installed). Always use SecureModelView from core/admin_views.py: a bare Flask-Admin view has no access control. Anonymous visitors are redirected to the login page and signed-in non-admins get 403.

If Flask-Babel is installed in your environment, also run add babel: Flask-Admin uses it automatically and it must be initialised.

How it works

add inserts code above the # forge:... marker comments in core/extensions.py and config/settings.py - please keep those comments. Operations are idempotent (running the same command twice changes nothing) and existing files are never overwritten without --force. Project metadata lives in .flaskforge.json.

Development

git clone https://github.com/dvrone/flaskforge.git && cd flaskforge
pip install -e ".[dev]"
pytest
python -m build && twine upload dist/*   # release (bump the version first)

License

See LICENSE.

Metadata

Release files for flaskforge-cli 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for flaskforge-cli 0.1.3
File Size Uploaded Provenance Actions
flaskforge_cli-0.1.3.tar.gz 38.8 kB Without provenance Details for flaskforge_cli-0.1.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for flaskforge-cli 0.1.3
File Interpreter ABI Platform Actions
flaskforge_cli-0.1.3-py3-none-any.whl Python 3 none any Details for flaskforge_cli-0.1.3-py3-none-any.whl

Total release size: 83.4 kB

Release files / flaskforge_cli-0.1.3.tar.gz

Download URL flaskforge_cli-0.1.3.tar.gz
Size 38.8 kB
Tags Source
SHA-256 checksum
How to use checksums
259466aca720d9dccad383d6db6cecc52f76350988ce0702a87b0dcfd98e10ec
BLAKE2b-256 checksum
How to use checksums
ea307baad61e7e9581230cd14c5e37c955f427f3e2295af8cb55f591d54dea62
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.15.2

Release files / flaskforge_cli-0.1.3-py3-none-any.whl

Download URL flaskforge_cli-0.1.3-py3-none-any.whl
Size 44.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2345dc604c2b9dc2c199993d0667700cf9688c217da743c908fb0f3e2b4fed3b
BLAKE2b-256 checksum
How to use checksums
498ba88dbf1f1353500de7ed6f1fbc99054d3308eb03a1e97214f705ab851884
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.15.2

Security for flaskforge-cli 0.1.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page