This page documents how to get the GeniePy boilerplate up and running for a new project.

Download

Purchase the boilerplate from Lemon Squeezy.

After the purchase, you'll be able to download an app-vXX.YY.ZZ.zip file to your machine. This is the base for setting up a new application.

Note that the XX.YY.ZZ in the file name will be different depending on the version you end up purchasing. Once you've made a purchase, all future versions will be made available to you at no additional cost.

Extract

Extract the zip file in the directory where you want to initialize the project.

Assuming that you store your work projects under $HOME/projects and the name of your new SaaS is Example, the following commands should set everything up.

# create the project directory
$ mkdir -p ~/projects/example
$ cd ~/projects/example

# move and extract the downloaded file into the target directory
$ mv /path/to/app-v1.2.3.zip .
$ unzip app-v1.2.3.zip

# cleanup
$ rm app-v1.2.3.zip

This should extract the application source code into the current working directory.

Configure

In line with the 12-factor methodology, GeniePy uses environment variables for application configuration.

In local development, this means using a .env file for the application to read. Make a copy of the sample.env file included in the codebase:

$ cp sample.env .env

... and edit the contents of this new file based on what your project needs.

The next time you start the application on your machine, this file will be used to load all the settings.

Prepare

Please note that you'll need to have a working installation of Python available for this section to work. For more details please refer to the Python pre-requisite.

Prepare a virtualenv in the current directory. The recent versions of Python make this easy using the in-built venv module.

$ python -m venv venv
$ source venv/bin/activate

If you'd like to set up the virtual environment a different way, pyenv is a good option to consider, especially if you're working a lot with Python codebases.

Initialize

Run the following three commands:

  1. poetry install: this will install all the Python dependencies needed to run the application.
  2. poetry run task migrate: this will run all the database migrations to set up the database tables. The default database engine is set to SQLite but can easily be changed using application settings.
  3. poetry run reflex init: this is a one-time command to initialize your project to work with Reflex.

Run

Run poetry run task server in the terminal!

You should now be able to visit the application in the browser at http://localhost:3000.

Lint

Run poetry run task lint in the project directory.

At the time of this writing, the project's code is linted using ruff, black, and isort.

ruff is used to ensure quality checks on Python codebases. It can point out issues related to style (eg. if some code is not conformant to PEP-8) or for discovering errors that would otherwise only be discovered at runtime (eg. NameError). It's also much faster than the other Python tools for the same job.

black is a code formatter for Python. If you've worked in a team of software developers, you've most likely ran into formatting issues at one time or another. black puts an end to such discussions by choosing a formatting style for you.

isort is responsible for sorting imports in Python code. This keeps the upper-most section of the file clean and consistent across the entire codebase.

These three tools have also been installed as pre-commit hooks. If you set up pre-commit as described in the previous section, all these linters will run sequentially whenever you run git commit. Any violations will prevent you from committing code.

Test

Run poetry run task test in the project directory.

This will run all the database migrations on the test database and then run the entire test suite using pytest. pytest is an excellent framework for writing better tests in Python. It is widely used in the Python community and has a rich plugin system which application developers can benefit from.

Next steps

At this point you should have a basic but functioning application running on your machine.

Check the post-installation steps for what you can do next!