Metadata-Version: 2.4
Name: bro-sba-py
Version: 0.1.0
Summary: Generate Flask and admin projects from Peewee models
Author: selimbenali
Maintainer: selimbenali
License-Expression: MIT
Keywords: flask,peewee,scaffold,admin,code-generator
Classifier: Development Status :: 3 - Alpha
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Code Generators
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: license-file

# Bro-Py

Generate Flask backend code and a browser-based admin dashboard from [Peewee](https://docs.peewee-orm.com/) models. The tool creates CRUD API routes and services, an admin UI, and optional authentication, role permissions, live Socket.IO updates, audit history, migrations, API docs, and test files.

The project is in active development. Try it with a disposable demo database first, and review generated code and configuration before using it with real data.

## Install the CLI

Install the commands in an isolated environment with:

```console
pipx install bro-py
```

Then run `bro-py-admin` and `bro-py` from the user's project folder. The generators run locally and read the `models/` folder there. The package includes Python source code; this distribution method makes installation easy, but does not hide the generator implementation.

Maintained by **selimbenali**.

To try the commands from a development checkout before the PyPI release, install the project into a virtual environment:

```console
python -m venv .venv
```

Activate `.venv`, then:

```console
python -m pip install --no-deps .
bro-py-admin --help
bro-py --help
```

## Quick start

You need Python 3.9 or newer. From the repository root, generate the admin pages first:

```console
bro-py-admin --models-dir examples/quickstart/models --output-dir examples/quickstart/generated
```

Then generate the backend. Choose SQLite for the local demo and answer the optional-feature questions:

```console
bro-py --models-dir examples/quickstart/models --output-dir examples/quickstart/generated
```

The backend generator detects and registers the frontend blueprint when it runs after the frontend generator.

Install and run the generated app:

```console
python -m venv .venv
```

Activate the environment, then:

```console
python -m pip install -r examples/quickstart/generated/requirements.txt
cd examples/quickstart/generated
python app.py
```

Open `http://127.0.0.1:5000/admin/`. The generated project’s [README](examples/quickstart/README.md) has the exact platform-specific commands, database notes, and the demo model’s API routes.

To regenerate existing files, pass `--force` and review the files it will replace first. Use `--dry-run` to preview changes. Files with the generated custom-code marker preserve the code below the marker.

## Features

- Peewee model scanning without importing or connecting to the application database.
- Generated Flask services, API blueprints, configuration, and startup app.
- Admin pages with search, sorting, pagination, CSV import/export, bulk update, and bulk delete.
- SQLite and MySQL setup; MySQL asks for database name, host, port, user, and hidden password.
- Optional JWT authentication, admin login, signup/email verification, and per-operation role checks.
- Optional Socket.IO record updates, dashboard status, notifications, and task progress messages.
- Optional audit history, OpenAPI/Swagger docs, and Peewee migration commands.
- Safe preview, template overrides, and trusted Python plugins.
- Generated README, environment example, dependency files, Dockerfile, and WSGI entry point.

For the complete first-time walkthrough, see [FEATURES_GUIDE.md](FEATURES_GUIDE.md). Review [SECURITY_AND_LIMITS.md](docs/SECURITY_AND_LIMITS.md) before using generated projects beyond local development.

## CLI overview

```console
bro-py --help
bro-py-admin --help
```

If you omit setup choices in an interactive terminal, the wizard asks about them. Use explicit positive or negative flags to skip individual questions, such as `--socketio` or `--no-socketio`. Use `--non-interactive` in scripts; omitted options use documented defaults and a starter `.env` is created for you to edit.

PostgreSQL is not currently supported. Supported database engines are SQLite and MySQL.

## Development

The generator checks use Python’s standard test runner. JavaScript syntax validation needs Node.js:

```console
python -m unittest discover -s tests -v
python tools/check_generated_javascript.py
```

See [CONTRIBUTING.md](CONTRIBUTING.md) to report a bug or prepare a change.

## License

This project is licensed under the MIT License. See [LICENSE](LICENSE).
