Flask web app with authentication (Google sign in and magic link) for SaaS (multi-tenant)

Test this app for free
19
import logging
from flask import Flask, url_for, request, session
from gunicorn.app.base import BaseApplication
from routes import routes as routes_blueprint
from authentication import auth, auth_required
from models import db, User
from abilities import apply_sqlite_migrations

# Setup logging
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)

def create_app():
    app = Flask(__name__, static_folder='static')
    app.secret_key = 'supersecretkey'
    app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///database.sqlite'
    db.init_app(app)

    with app.app_context():
        apply_sqlite_migrations(db.engine, db.Model, 'migrations')

    app.register_blueprint(routes_blueprint)
    app.register_blueprint(auth)
Get full code

Frequently Asked Questions

What types of businesses or applications would benefit most from this Flask web app template?

This Flask web app template with authentication is ideal for SaaS (Software as a Service) businesses and multi-tenant applications. It's particularly suitable for startups or companies looking to build web applications where users need individual accounts to manage their own data. For example, it could be used for: - Project management tools - Personal finance trackers - E-learning platforms - Customer relationship management (CRM) systems - Health and fitness apps

The template's focus on individual user authentication without team features makes it a great starting point for these types of applications.

How does this template support scalability for growing SaaS businesses?

The Flask web app template supports scalability in several ways: - It uses SQLAlchemy ORM, allowing easy database migrations as your data model evolves. - The authentication system supports both Google sign-in and magic links, providing flexibility for user onboarding. - The use of Gunicorn as the WSGI HTTP server allows for easy deployment and scaling on various cloud platforms. - The template's modular structure (separate files for routes, models, authentication) promotes maintainable and extensible code as your application grows.

These features make it easier for SaaS businesses to start small and scale up as their user base and feature set expand.

How can I customize the landing page to reflect my specific SaaS offering?

The template includes a landing.html file that you can easily customize to reflect your SaaS offering. To update it:

How does the authentication system in this Flask web app template work?

The authentication system in this Flask web app template uses a combination of Google sign-in and magic links. It's implemented in the authentication.py file using a custom decorator auth_required. Here's a brief explanation of how it works:

Can I add more user profile information to this template? How would I do that?

Yes, you can easily add more user profile information to this Flask web app template. Here's how you can do it:

Created: | Last Updated:

This is a good starting point for any app that requires login and registration. Unlike the internal tool skeleton this one has no team features which means it's more suitable for application where multiple users can manage their own data. So for a SaaS web app for example this makes more sense than for an internal tool.

Here's a step-by-step guide on how to use the Flask web app template with authentication for SaaS (multi-tenant):

Introduction

This template provides a solid foundation for building a SaaS (Software as a Service) web application using Flask with built-in authentication. It supports Google Sign-In and magic link authentication, making it suitable for multi-tenant applications where users can manage their own data.

Getting Started

  1. Click "Start with this Template" to begin using this template in the Lazy Builder interface.

Test the Application

  1. Press the "Test" button to deploy the application and launch the Lazy CLI.

Using the App

  1. Once the app is deployed, you'll receive a server link. Open this link in your web browser to access the application.

  2. You'll see a landing page with a "Log in" button. Click this button to proceed to the authentication page.

  3. On the authentication page, you can choose to sign in with Google or use a magic link (email authentication).

  4. After successful authentication, you'll be redirected to the home page for logged-in users.

Customizing the App

To tailor the app to your specific SaaS needs:

  1. Modify the /home_logged_in route in the routes.py file to add your core functionality.

  2. Update the landing.html template to reflect the purpose of your SaaS application. You can add features, benefits, and call-to-action elements relevant to your service.

  3. If needed, add new routes in routes.py and create corresponding HTML templates in the templates folder.

  4. Customize the styles in the CSS files (sidebar.css, profile.css, and landing.css) to match your brand's look and feel.

Database Operations

The template includes basic user management functionality:

  • create_user: Creates a new user in the database
  • get_user_by_email: Retrieves user information by email
  • update_user_profile_picture: Updates a user's profile picture

You can extend these operations in the database_operations.py file to include additional functionality specific to your SaaS application.

Authentication

The template uses the flask_app_authenticator from the abilities module for handling authentication. You can customize the authentication settings in the authentication.py file if needed.

Conclusion

This template provides a robust starting point for building a SaaS web application with Flask. It includes user authentication, basic user management, and a responsive layout. You can now focus on adding your specific SaaS features and functionality to meet your business needs.



Template Benefits

  1. Rapid SaaS Development: This template provides a solid foundation for quickly building Software-as-a-Service (SaaS) applications, reducing development time and allowing businesses to launch their products faster.

  2. Secure Authentication: With built-in Google Sign-In and magic link authentication, the template ensures robust security measures are in place, protecting user data and reducing the risk of unauthorized access.

  3. Multi-Tenant Architecture: The template is designed for multi-tenant applications, allowing businesses to serve multiple customers from a single instance, improving scalability and reducing operational costs.

  4. User-Centric Design: The responsive layout with a sidebar and profile management features offers a user-friendly interface, enhancing user experience and potentially increasing user engagement and retention.

  5. Customizable and Extensible: The modular structure of the template makes it easy to customize and extend functionality, allowing businesses to tailor the application to their specific needs and add new features as they grow.

Technologies

Streamline CSS Development with Lazy AI: Automate Styling, Optimize Workflows and More Streamline CSS Development with Lazy AI: Automate Styling, Optimize Workflows and More
Optimize Your Django Web Development with CMS and Web App Optimize Your Django Web Development with CMS and Web App
Flask Templates from Lazy AI – Boost Web App Development with Bootstrap, HTML, and Free Python Flask Flask Templates from Lazy AI – Boost Web App Development with Bootstrap, HTML, and Free Python Flask
Enhance HTML Development with Lazy AI: Automate Templates, Optimize Workflows and More Enhance HTML Development with Lazy AI: Automate Templates, Optimize Workflows and More
Streamline JavaScript Workflows with Lazy AI: Automate Development, Debugging, API Integration and More  Streamline JavaScript Workflows with Lazy AI: Automate Development, Debugging, API Integration and More
Python App Templates for Scraping, Machine Learning, Data Science and More Python App Templates for Scraping, Machine Learning, Data Science and More
Optimize SQL Workflows with Lazy AI: Automate Queries, Reports, Database Management and More Optimize SQL Workflows with Lazy AI: Automate Queries, Reports, Database Management and More

Similar templates

We found some blogs you might like...