Skip to main content

Flask scaffolding CLI and runtime library — component architecture, SQLAlchemy, Redis caching, async tasks, and Elasticsearch analytics

Project description

overflask

A CLI tool that scaffolds Flask projects with component-based architecture, and a runtime library that adds SQLAlchemy models, Redis caching, async/recurring tasks, and Elasticsearch analytics on top of Flask.

Create a project

Via Docker (no install required):

docker run --rm -it -u $(id -u):$(id -g) -v $(pwd):/workspace overflask/overflask create myapp

Or install and run locally:

pip install overflask @ git+https://gitlab.com/overflask/overflask.git
overflask create myapp

The CLI prompts for an initial component name and Postgres/Redis connection details, generates the project, pre-fills .env, and optionally starts the database containers.

myapp/
├── manage.py           # project CLI
├── settings.py         # configuration
├── requirements.pip    # dependencies
├── compose.yaml        # Docker Compose
├── conftest.py         # pytest fixtures
├── ops/
│   ├── env.template
│   ├── migrations/     # Alembic
│   └── setup-traefik.sh
├── docs/
└── components/
    └── myapp/
        ├── models.py
        ├── views.py
        ├── services.py
        ├── cli.py
        ├── tasks.py
        └── tests.py

Add a component

python manage.py component add auth

Creates components/auth/ with the same structure and registers it in settings.COMPONENTS.

Runtime library

Generated projects import directly from overflask:

Models

from overflask import ModelBase
from sqlalchemy.orm import Mapped, mapped_column

class User(ModelBase):
    # __tablename__ auto-set to "auth_users"
    id: Mapped[int] = mapped_column(primary_key=True)
    email: Mapped[str] = mapped_column(String(255), unique=True)

Table names are derived automatically as {component}_{plural_snake_case_model_name}.

Redis cache

from overflask import cached

@cached(ttl=300)
def get_user(user_id: int):
    ...

Backed by Redis db 15 with stampede prevention via locking.

Async tasks

from overflask import async_task

@async_task
def send_welcome_email(user_id: int, email: str) -> None:
    ...

# Enqueue immediately or with a delay
send_welcome_email.queue(user_id=42, email="alice@example.com")
send_welcome_email.queue(timedelta(minutes=5), user_id=42, email="alice@example.com")

Recurring tasks

from overflask import recurring_task

@recurring_task("0 9 * * MON-FRI")
def daily_report() -> None:
    ...

Tasks are stored in Elasticsearch and dispatched via Redis. Run the supporting processes:

python manage.py tasks scheduler   # polls ES, dispatches due tasks
python manage.py tasks worker      # executes tasks from Redis queue

Analytics

from overflask.analytics import Analytics

Analytics.record("user.registered", area="auth", plan="free")
Analytics.record("purchase.completed", area="billing", amount=99)

Events are buffered in-process and bulk-flushed to Elasticsearch in the background. Each area gets its own monthly index (myapp_analytics_auth-2026.03).

Database migrations

python manage.py db migrate -m "add users table"
python manage.py db upgrade
python manage.py db downgrade 001

Testing

pytest               # all tests
pytest -m unit       # unit tests only (no DB)
pytest -m integration
pytest -n auto       # parallel

Integration tests run against a real PostgreSQL instance using a cloned template database — fast isolation without create_all() per test. Redis is always replaced with fakeredis.

Deployment

The generated project ships with a Gunicorn config and Traefik integration for HTTPS:

bash ops/setup-traefik.sh   # one-time Traefik setup per server
docker compose up -d
docker compose exec web python manage.py db upgrade

See docs/traefik.md and docs/gunicorn.md in the generated project for details.

Development

pip install -e ".[dev]"
pytest
ruff check src/ tests/
ruff format src/ tests/

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

overflask-0.8.0.tar.gz (73.7 kB view details)

Uploaded Source

Built Distribution

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

overflask-0.8.0-py3-none-any.whl (77.2 kB view details)

Uploaded Python 3

File details

Details for the file overflask-0.8.0.tar.gz.

File metadata

  • Download URL: overflask-0.8.0.tar.gz
  • Upload date:
  • Size: 73.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for overflask-0.8.0.tar.gz
Algorithm Hash digest
SHA256 82543065991241b8c781569cbb7dccc3cfca62e48b3ac5f10eb1fb141a3190d8
MD5 e3fa4d91f924c3ce968e95559d475766
BLAKE2b-256 a8e2a4c3dd5a46f3b7ec6d9ee51638ce834d5131b139b90237892280aba2e65a

See more details on using hashes here.

File details

Details for the file overflask-0.8.0-py3-none-any.whl.

File metadata

  • Download URL: overflask-0.8.0-py3-none-any.whl
  • Upload date:
  • Size: 77.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for overflask-0.8.0-py3-none-any.whl
Algorithm Hash digest
SHA256 218ba9d3b28835bb095e172d1bdc8ecdaff3ea9d191c9d4b52c56776d84bfe20
MD5 5d3662685a7b274c38bf3b28456db6fb
BLAKE2b-256 43ee677f11106b14fcf13bc6b7502cf3ca9f8b82ceca725f66317b452ee1095f

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