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

Download

Purchase the boilerplate from Gumroad.

After the purchase, you'll be able to download an app-XX.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

As the artifact is a zip file, you need to extract it 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 GeniePy, the following commands should set everything up.

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

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

# cleanup
$ rm app-22.01.01.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 docker-compose-backed local development, we use the env_file configuration option to ask Docker to set the environment variables for a specific container from a specific file.

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.

All the available settings are defined under app/settings.py. If you'd like to see what else is available, this is the file you should refer to.

Run

Run make up in the project directory, followed by make migrate.

The first command will bring up all the necessary containers and build any necessary images using docker-compose and link them with each other. The second command runs the database migrations script, such that all the necessary database tables exist.

That's it! You should now be able to visit the application in the browser at http://localhost:9001.

Lint

Run make lint in the project directory.

At the time of this writing, the project's code is linted using three tools: flake8, black, and isort.

flake8 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. undefined variables).

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 topmost 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 make test in the project directory.

This should 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 end-users can benefit from.