๐Ÿง Installation

Let's get the ball rolling

Prerequisites

To get started with PySaaS, you'll need to install the following system requirements if you don't already have them:

  1. Python 3.9+

This looks different for each OS you could be installing to. The following installation will be on Ubuntu 20.

Clone the Boilerplate

After you purchase PySaaS, we'll invite you as a collaborator with read permissions to the private GitHub repository. From there, you can clone the codebase and start building your application.

git clone https://github.com/getpysaas/pysaas.git
cd pysaas

Virtual Environment

We recommend creating a virtual environment for development. If you don't know how to create one, you can do it using Python's venv module.

python3 -m venv venv
source venv/bin/activate

Install Requirements

A requirements.txt file is included in the root directory of the repository. To install requirements required to run the template applications, run:

pip install -r requirements.txt

There also exists a requirements_dev.txt file, but that is only needed if you are running the tests (in the works). Running the tests is recommended, but not necessary.

Project Structure

The boilerplate code structure is as follows.

pysaas
โ”œโ”€โ”€ README.md
โ”œโ”€โ”€ assets
โ”œโ”€โ”€ tests
โ”œโ”€โ”€ pysaas
โ”‚ย ย  โ”œโ”€โ”€ auth
โ”‚ย ย  โ”œโ”€โ”€ components
โ”‚ย ย  โ”œโ”€โ”€ pages
โ”‚ย ย  โ”œโ”€โ”€ utilities (coming soon)
โ”‚ย ย  โ”œโ”€โ”€ pysaas.py
โ”‚ย ย  โ””โ”€โ”€ styles.py
โ”œโ”€โ”€ requirements.txt
โ”œโ”€โ”€ requirements_dev.txt
โ”œโ”€โ”€ pytest.ini
โ”œโ”€โ”€ .flake8
โ””โ”€โ”€ rxconfig.py

assets

The assets directory contains static assets you can use in your application. The boilerplate codebase includes SVG and PNG images in the assets directory, but you can include any images, fonts, or other files.

pysaas

This is your main project directory. Your app's logic will be written here.

pysaas.py contains the App, State classes and variables, and page details.

The pages directory includes files for the separate pages of your application.

The components directory contains components used within pages.

The auth directory contains the code for the different authentication and database connections. You should not have to edit this code on your own unless you are adding a new authentication method yourself.

rxconfig.py

This file contains the configuration details for your application. Here, you can set your app name, environments, ports, database, and API URL.

tests

This directory contains the actual test files. You can add tests for your own application here. There will be tests already populated that cover the PySaaS deployment itself.

pytest.ini and .flake8

These are configuration files for the linter and testing. These files will be updated as the linting and testing are refined and developed further. You can edit these to tune them to your specific application.

Reflex

We highly recommend taking about 30 minutes to read more about Reflex and become familiar with the framework. PySaaS builds on the Reflex web framework to enable full-stack web development and deployment in pure Python.

Read the documentation here.

Environment Variables

When you clone the repository, you'll see a file named .env.example in the root directory with the following content:

##### Subscriptions #####
# LemonSqueezy
LM_API_KEY=""
LM_SIGNING_SECRET=""
LM_URL=""

##### Blog #####
# Notion
NOTION_API_KEY=""
NOTION_DB_ID=""

##### Authentication/Database #####
# Set your authentication package to use
# Options: FIREBASE, SUPABASE
AUTHENTICATION_PACKAGE="FIREBASE"

# Firebase
FIREBASE_API_KEY=""
FIREBASE_AUTH_DOMAIN=""
FIREBASE_DB_URL=""
FIREBASE_PROJECT_ID=""
FIREBASE_STORAGE_BUCKET=""
FIREBASE_MSG_SENDER_ID=""
FIREBASE_APP_ID=""
FIREBASE_MEASUREMENT_ID=""

# Supabase
SUPABASE_URL=""
SUPABASE_KEY=""

##### Google Analytics #####
# Options: TRUE, FALSE
GOOGLE_ANALYTICS="FALSE"
GOOGLE_TAG=""

Your app will need these variables configured to connect to different sources during runtime.

There are currently two authentication/database options, Firebase and Supabase. You will not use both of these simultaneously, so you will need to choose your preferred option.

For now, let's copy the .env.example to .env and we will get the information needed throughout the rest of the installation.

For Ubuntu, here is the command to do this:

cp .env.example .env

Important!

Depending on the authentication package you want to use, there will be different instructions. If you are using Firebase, proceed to the next page and skip the Supabase section afterwards. If you are using Supabase, skip the Firebase section and proceed to the Supabase section.

Last updated