Important
This project is currently under active development. I'm regularly making updates and additions to improve its completeness and functionality.
- Table of Contents
- π Showcase
- π About
- β¨ Features
- π¦ Structure
- π Libraries
- π Install & Run
- β€οΈ Thanks
- π License
Note
Some images coming some day ...
This is a fully featured template for building a Django-based SaaS application, containerized with Docker. It includes everything from user authentication and background task processing to a REST API with complete documentation.
The frontend is developed using Vite and Svelte, compiled into static assets and served via Djangoβs template system.
For development, testing, and production, the stack incorporates tools such as PostgreSQL, Redis, Caddy, MailHog, Sentry, Grafana, and Prometheus.
Project
-
π Reproducibility: The project is built using uv, enabling seamless setup replication across different machines for consistent environments.
-
π Well-Documented: Source files include thorough comments and, where applicable, links and explanations to clarify key settings.
Program
-
π§± Django-based backend Powerful and extensible backend using Django, ideal for SaaS applications.
-
π Built-in authentication system User registration, login, password reset, and more out of the box.
-
βοΈ Background task support Integrated support for background processing (e.g., with Celery or Django Q).
-
π REST API with documentation Fully functional REST API with auto-generated documentation (e.g., Swagger or ReDoc).
-
π¨ Modern frontend with Vite and Svelte Responsive and fast frontend built with Svelte and bundled via Vite, served through Django templates.
-
π³ Docker-based development and deployment Consistent environments using Docker for local development, testing, and production.
-
π Monitoring and observability tools Integrated support for Prometheus and Grafana for metrics and monitoring.
-
π¬ Email testing with MailHog Catch and inspect outgoing emails during development.
-
π Error tracking with Sentry Real-time error logging and alerting for faster debugging and maintenance.
-
π Caddy as a web server and reverse proxy Automatically manages HTTPS and routing for production-ready deployments.
-
π PostgreSQL database Reliable and robust relational database for handling application data.
-
π Redis integration In-memory data store for caching, session management, and background tasks.
Note
The project's structure should speak for itself, but here are the most important parts just in case you're wondering
Directories
.github
- Contains GitHub Actions CI/CD workflows..vscode
- VS Code-specific settings and helper documentation.ansible
- Ansible configuration files (currently empty).assets
- Static image resources used in the project.docker
- Scripts to run services via Docker (e.g. Django, Celery, Gunicorn).etc
- Configuration files for infrastructure components (e.g. Grafana, Traefik, Caddy, Prometheus).frontend
- Frontend app using Svelte, Vite, and TypeScript.server
- Main Django application, including apps, configuration, static files, templates, and localization.terraform
- Infrastructure-as-code configuration with Terraform (currently empty).
Files
.dockerignore
,.gitignore
,.gitattributes
- Ignore rules and Git configurations..editorconfig
,.flake8
,.pre-commit-config.yaml
- Formatting and linting configurations..env.prod
,db.prod.env
- Environment variable files for production setup..python-version
- Python version specification (for pyenv and tooling).Dockerfile.test
,docker-compose*.yml
- Docker configuration files for different environments.Jenkinsfile
- CI/CD pipeline configuration for Jenkins.Justfile
,Makefile
- Task runners for development and automation.Procfile
- Process declaration file for deployment (e.g. Heroku).LICENSE
,README.md
- License and documentation files.pyproject.toml
,requirements.txt
,uv.lock
- Python environment and dependency configuration.
Note
Below are some of the key libraries and dependencies used in this project. For the full list, refer to the pyproject.toml
file.
-
π Web Framework & Core
django
: Full-featured web framework for building modern web apps.django-environ
: Environment variable management for 12-factor app configs.whitenoise[brotli]
: Efficient static file serving in production.
-
βοΈ API & Serialization
djangorestframework
: Build robust REST APIs with Django.drf-spectacular
: Automatically generate OpenAPI/Swagger schema.
-
π Authentication & Payments
django-allauth
: Integrated auth with support for social login, MFA, and OIDC.dj-stripe
: Connects Django to Stripe for payments and subscriptions.
-
β‘ Async & Real-time
-
β±οΈ Task Queue & Scheduling
django-celery-beat
: Schedule periodic tasks with Celery and Django.redis
: In-memory data store used as Celery broker and cache.
-
π Monitoring & Observability
sentry-sdk
: Real-time error monitoring and performance tracing.
-
πͺ΅ Logging & Notifications
If you'd like to run this Django app on your machine, here are two versions of how to do so by either doing on your system or using docker.
First, make sure the uv
Python package manager is installed on your system.
Once that's done, clone the repository
git clone https://github.com/leoraclet/django-saas-template
cd django-saas-template
Then, install the project dependencies:
uv sync
Tip
You may need to create a virtual environment beforehand:
uv venv
Finally, if you have either Make or Just installed, you can launch the development server accordingly.
make migrate # To migrate the Database (MANDATORY)
make run # To run the developement server
or you can just run simple commands using
uv run {YOUR_COMMAND}
Ensure that Docker is installed on your system and that the docker
command is available in your terminal.
To start the Docker setup, run:
docker compose up -d
Tip
To rebuild the image from scratch (without using the cache), use the following command:
docker compose build --no-cache
As with local development, you can use the Makefile
(or Justfile
) to manage Docker-related tasks easily with the following commands:
make up # Build (if needed) and start the containers
make down # Stop and remove containers and associated networks
make build # Build or rebuild the Docker services
make logs # View the output logs from running containers
Projects and blog posts that inspired this template :
- Cookiecutter Django
- Testdriven Blog
- SaaS Pegasus Guides
- Digital Ocean
- Django Astro Demo
- Medium Article
This project is licensed under the MIT License - see the LICENSE file for details.