Skip to content

codingforentrepreneurs/SaaS-Foundations

Repository files navigation

SaaS Foundations

Build the foundations for a Software as a Service business by leveraging Django, Tailwind, htmx, Neon Postgres, Redis, and more.

The goal of this project is to learn how to create a reusable foundation for building SaaS products. When release, this course will span multiple topics and give you a solid foundation into build your business.

References

Getting Started

Clone

mkdir -p ~/dev/saas
cd ~/dev/saas
git clone https://github.com/codingforentrepreneurs/SaaS-Foundations .

Create Virtual Environment

macOS/Linux

python3 --version # should be 3.11 or higher
python3 -m venv venv
source venv/bin/activate

Windows

c:\Python312\python.exe -m venv venv
.\venv\Scripts\activate

Install Requirements with Rav

Rav is a simple way to run commands and download static files (css, images, js, etc) from external sources.

# with venv activated
pip install pip rav --upgrade
rav run install

Use python -m rav run install if for some reason rav is not in your path.

Sample dotenv to dotnev

cp .env.sample .env
cat .env

Values include:

  • DJANGO_DEBUG=1
  • DJANGO_SECRET_KEY=""
  • DATABASE_URL=""
  • EMAIL_HOST="smtp.gmail.com"
  • EMAIL_PORT="587"
  • EMAIL_USE_TLS=True
  • EMAIL_USE_SSL=False
  • EMAIL_HOST_USER=""
  • EMAIL_HOST_PASSWORD=""
  • ADMIN_USER_EMAIL=""
  • STRIPE_SECRET_KEY=""

Create the DJANGO_SECRET_KEY

python -c 'from django.core.management.utils import get_random_secret_key; print(get_random_secret_key())'

or

openssl rand -base64 64

or

python -c 'import secrets; print(secrets.token_urlsafe(64))'

Once you have this value, add update DJANGO_SECRET_KEY in .env.

Run Migrations

source venv/bin/activate 
# or .\venv\Scripts\activate if windows
cd src
python manage.py migrate

Create a Superuser

python manage.py createsuperuser

Pull Vendor Static Files

python manage.py vendor_pull

Create a Stripe Account

  1. Sign up on Stripe.com for an account
  2. Get or create a Stripe Secret API Key (Dashboard > Developers > API keys > Secret key )
  3. Update dotenv (.env) with the value STRIPE_SECRET_KEY with your key.

Run the Server

python manage.py runserver

Ready to roll! 🚀

Useful Rav Commands

Review the rav.yaml (or rav documentation) for available command shortcuts, here are some useful ones:

  • rav run install - Install requirements based on scripts.install
  • rav run install_dev - Install requirements for development
  • rav run makemigrations - Make migrations
  • rav run migrate - Run migrations
  • rav run dev - Run the development server
  • rav run test - Run the tests
  • rav run vendors_pull - Download vendor static files
  • rav run collectstatic - Collect static files
  • rav download staticfiles_prod - Download vendor static files for production
  • rav download staticfiles_dev - Download vendor static files for development

Upcoming Changes

  • [] Remove Django Allauth-UI and Slippers. While these tools can be great, they have been causing more issues than they have been worth.
  • [] Docker Compose support for Postgres, Redis, and more.

Changelog

  • 2025-09-02:
    • Upgraded to Django 5.2
    • Added Slippers for better AllAuth UI Support
    • Implemented Rav to manage requirements and static files
    • Updated Dockerfile to use Rav
    • Updated README to include Rav
    • Dropped only Neon in favor of any Postgres database (aim to make it more generic)

About

Django tutorial integrating TailwindCSS, Neon Postgres, Stripe API, User auth, deployment, & more.

Topics

Resources

License

Stars

Watchers

Forks