A modern, secure, and scalable SaaS application template built with FastAPI, featuring multi-tenancy, authentication, and role-based access control.
-
🔐 Secure Authentication
- JWT-based authentication
- Password hashing with bcrypt
-
🏢 Multi-tenancy
- Tenant isolation
- Tenant-specific data access
- User-tenant associations
- Primary tenant selection
-
🛠 Modern Tech Stack
- FastAPI for high-performance API
- SQLAlchemy for database operations
- Pydantic for data validation
- Alembic for database migrations
-
🔄 Database
- PostgreSQL support
- Async database operations
- Unit of Work pattern
- Repository pattern
- Python 3.8+
- PostgreSQL 12+
- Docker (optional)
- Clone the repository:
git clone https://github.com/yourusername/fastapi-saas-template.git
cd fastapi-saas-template
- Create and activate a virtual environment:
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
- Install dependencies:
pip install -r requirements.txt
- Set up environment variables:
cp .env.example .env
# Edit .env with your configuration
- Run database migrations:
alembic upgrade head
uvicorn app.main:app --reload
uvicorn app.main:app --host 0.0.0.0 --port 8000
Once the application is running, you can access:
- Swagger UI:
http://localhost:8000/docs
- ReDoc:
http://localhost:8000/redoc
app/
├── auth/ # Authentication and authorization
├── core/ # Core functionality and utilities
├── db/ # Database configuration and models
├── tenants/ # Tenant management
├── users/ # User management
└── main.py # Application entry point
- JWT-based authentication
- Role-based access control
- Secure password handling
- Tenant isolation
- User-tenant associations
- Tenant-specific data access
- PostgreSQL with SQLAlchemy
- Async database operations
- Migration support with Alembic
- JWT token-based authentication
- Password hashing with bcrypt
- Role-based access control
- Tenant isolation
- Secure session management
- Input validation with Pydantic
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
For support, please open an issue in the GitHub repository or contact the maintainers.