Skip to content

Multi-Tenant SaaS is a FastAPI-based application that enables multi-tenancy using PostgreSQL schemas. It includes JWT authentication, Google OAuth login, role-based access control (RBAC), admin management, and audit logging. The application is containerized with Docker, supports Alembic migrations for database versioning

Notifications You must be signed in to change notification settings

Moretti-Fool/multi_tenant_saas_api

Repository files navigation

Multi-Tenant SaaS Platform

Python FastAPI PostgreSQL

A secure, scalable multi-tenant application with schema-based isolation, featuring robust authentication and admin management.

✨ Key Features

  • Multi-Tenant Architecture

    • PostgreSQL schema isolation
    • Automated tenant provisioning
    • Per-tenant database connections
  • Authentication & Security

    • JWT token authentication
    • Google OAuth 2.0 integration
    • BCrypt password hashing
    • Email verification flow
  • Admin Features

    • Audit logging system
    • Superadmin privileges
    • User activity monitoring
  • DevOps Ready

    • Docker containerization
    • Alembic database migrations
    • Environment variable configuration

🚀 Getting Started

Installation

1️⃣ Clone the Repository

git clone https://github.com/Moretti-Fool/multi_tenant_saas_api.git
cd multi-tenant-saas

2️⃣ Create a Virtual Environment

python3 -m venv venv
source venv/bin/activate  # On Windows use: venv\Scripts\activate

3️⃣ Install Dependencies

pip install -r requirements.txt

4️⃣ Setup Environment Variables

Rename .env.example to .env and update the database credentials.

5️⃣ Run Database Migrations

alembic upgrade head

6️⃣ Initialize Admin User

python admin_create.py create-admin

7️⃣ Start the Application

uvicorn main:app --host 0.0.0.0 --port 8000

🐳 Docker Setup

To run the application using Docker:

docker-compose -f docker-compose-prod.yml up --build

About

Multi-Tenant SaaS is a FastAPI-based application that enables multi-tenancy using PostgreSQL schemas. It includes JWT authentication, Google OAuth login, role-based access control (RBAC), admin management, and audit logging. The application is containerized with Docker, supports Alembic migrations for database versioning

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published