https://github.com/amssdias/multitenant-blog-platform
Multi-tenant blog platform with per-user subdomains and isolated content.
https://github.com/amssdias/multitenant-blog-platform
authentication django multitenant postgres redis schema
Last synced: 2 months ago
JSON representation
Multi-tenant blog platform with per-user subdomains and isolated content.
- Host: GitHub
- URL: https://github.com/amssdias/multitenant-blog-platform
- Owner: amssdias
- Created: 2025-03-20T14:35:14.000Z (about 1 year ago)
- Default Branch: master
- Last Pushed: 2026-02-02T22:27:01.000Z (4 months ago)
- Last Synced: 2026-02-03T11:41:30.264Z (4 months ago)
- Topics: authentication, django, multitenant, postgres, redis, schema
- Language: Python
- Homepage:
- Size: 536 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ๐๏ธ Django Multitenant Blog Platform
[](https://github.com/amssdias/multitenant-blog-platform/actions/workflows/tests.yml)






## ๐ Overview
This is a **Django Multitenant Blog Platform** where users can sign up on the **main domain**, and upon registration,
they get their own **subdomain** with an isolated schema to create and manage their own blog.
## ๐ง Key Concepts
- **Schema-based multitenancy** using PostgreSQL
- **Subdomain routing** per tenant
- **Isolated data per tenant**
- **Shared users table** on the public schema
- **CI-tested architecture**
## ๐ฅ Features
### ๐ Main Domain (`example.com`)
- User registration & authentication
- Tenant provisioning on signup
- Subdomain assignment (`user.example.com`)
### ๐งฉ Tenant Subdomains (`user.example.com`)
- Automatic redirect after login
- Blog post creation & management
- Fully isolated PostgreSQL schema per tenant
### โ๏ธ Technical Highlights
- Django + schema-based multitenancy
- PostgreSQL (schemas)
- Redis support
- Docker-ready
- GitHub Actions CI (tests on push & PR)
## ๐๏ธ Architecture
> Each user owns a tenant schema while authentication and tenant metadata live in the public schema.
## ๐ ๏ธ Installation & Setup
### 1๏ธโฃ Clone the Repository
```sh
git clone https://github.com/yourusername/multitenant-blog.git
cd multitenant-blog
```
### 2๏ธโฃ Install Dependencies
```sh
pip install pipenv
pipenv install --dev
```
### 3๏ธโฃ Configure the Environment
Copy the example environment file and adjust values if needed:
```bash
cp .env.example .env
```
Required to run the project:
- Django settings (`DJANGO_SECRET_KEY`, `DJANGO_ALLOWED_HOSTS`)
- PostgreSQL connection (`DB_NAME`, `DB_USER`, `DB_PASSWORD`, `DB_HOST`, `DB_PORT`)
- Redis connection (`REDIS_PROTOCOL`, `REDIS_PORT`, `REDIS_PASSWORD`, `REDIS_DB_CELERY`)
Optional (only if you want to test email/Celery email tasks):
- SMTP settings (`EMAIL_HOST`, `EMAIL_PORT`, `EMAIL_USE_TLS`, `EMAIL_HOST_USER`, `EMAIL_HOST_PASSWORD`,
`DEFAULT_FROM_EMAIL`)
### 4๏ธโฃ Run Migrations
```sh
python manage.py migrate
```
### 5๏ธโฃ Start the Development Server
```sh
python manage.py runserver --settings=bloggies.settings.settings_development
```
## ๐ฅ๏ธ Local subdomain setup
To enable subdomains locally, configure your hosts file:
๐ [Localhost multitenancy setup guide](https://github.com/amssdias/multitenant-blog-platform/wiki/Multitenancy-Localhost-Setup)
## ๐งช Testing & CI
- Automated tests run on every push request
- PostgreSQL-backed test environment
- GitHub Actions workflow: tests.yml
```shell
pipenv run python manage.py test --settings=bloggies.settings.settings_tests
```
## ๐ฏ Use Cases
- SaaS blog platforms
- Multi-tenant CMS systems
- Portfolio-ready Django architecture
- Learning reference for schema-based multitenancy
## ๐งฉ Built to demonstrate real-world Django multitenant architecture

This project is intentionally designed as a **production-style reference** for building
**schema-based multitenant applications** with Django.
It focuses on **architectural correctness and real constraints**, rather than shortcuts
commonly used in tutorials.
Specifically, it demonstrates:
- Schema-based data isolation using **PostgreSQL schemas**
- Subdomain-driven tenant resolution (`user.example.com`)
- A shared **public schema** for authentication and tenant metadata
- Clean separation between **public** and **tenant-specific** concerns
- A CI pipeline that validates the architecture using real services
The goal is to showcase how a real SaaS-style multitenant Django application can be structured,
tested, and reasoned about.
---
๐ Happy Coding! ๐ฏ