Skip to content

Web based portal to deploy an entire C# based SaaS application from start to finish to speed up development and deployment of new SaaS projects to increase development velocity

License

Notifications You must be signed in to change notification settings

saas-factory-labs/Saas-Factory

Repository files navigation

πŸ—οΈ SaaS Factory

Blueprint for deploying any type of B2B/B2B SaaS to massively accelerate development speed and time to market of a new SaaS web application by reducing the to create boilerplate code and infrastructure.

Database schema diagram for Appblueprint-Dev-Db

Explore database with Azimutt

Quality Gate Status

Bugs

Code Smells

Coverage

Duplicated Lines (%)

Security Rating

Reliability Rating

Maintainability Rating

Vulnerabilities

Technical Debt

Vision

Deploying a new SaaS app project working with one command via the Developer Cli and then adding features specific to the application, while all the fundamental is in place already in under 30 minutes

Purpose

Objectives

  • Fun to work with and develop
  • Consolidated shared infrastructure
  • Fast continuous deployment of code to infrastructure (deploy automatically after passing automated QA environment testing processes)
  • Cost-effective
  • Secure
  • Fast development on new or existing software-as-a-service projects
  • familiar tech stack (C# as much as possible)
  • Minimal technical debt (standardized implementations, code clean up, modular flexible structure, tracking, and maintenance of code and database migration drift)
  • Mono repo for SaaS deployment manager system and boilerplate code for deploying SaaS web app project in a separate repo
  • Automated processes
  • Disaster recovery implementation
  • Automated documentation
  • Dev, QA (automated), staging, and production environment
  • Cloudagnostic (can easiliy be migrated to another cloud provider such as Digital Ocean/Hetzner/Linode/Render.com/Railway.com

Complexities

  • Maintaining and keeping multiple deployed SaaS web applications up to date to mitigate technical debt
  • Adhering to a high-level perspective and focus while being able to deepdive into low level programming and troubleshooting
  • MVP status - When and how can the first SaaS Factory App be deployed?
  • Should Deployment Manager be added in version 2 of SaaS Factory and how can existing deployed SaaS web apps be consolidated and migrated?

Note

Useful information that users should know, even when skimming content.

Tip

Helpful advice for doing things better or more easily.

Important

Key information users need to know to achieve their goal.

Warning

Urgent info that needs immediate user attention to avoid problems.

Caution

Advises about risks or negative outcomes of certain actions.

ℹ️ Definitions

  • Entity
  • DTO
    • Request
    • Response
  • Interfaces
  • Services
  • Repositories
  • Database
    • Migrations
    • Contexts

πŸ”— Related repositories

Didact

Blazor Diagrams

πŸ› οΈ Prerequisites

Install prerequisites for development on Windows
  1. Open a PowerShell terminal as Administrator and run the following command to install Windows Subsystem for Linux (required for Docker):

    wsl --install

  2. Restart your computer if prompted.

  3. Install .NET, Git, Docker Desktop, Node.js, Azure CLI, and GitHub CLI using winget (available only on Windows 11):

    @(
        "Microsoft.DotNet.SDK.9",
        "Git.Git",
        "Docker.DockerDesktop",
        "OpenJS.NodeJS",
        "npm install wrangler --save-dev"
        "GitHub.cli"    	
    ) | ForEach-Object { winget install --accept-package-agreements --accept-source-agreements --id $_ }
    
    "gh extension install https://github.com/nektos/gh-act"

πŸ—‚οΈ File structure in the git repository

SaaS-Factory is a monorepo containing all application code, infrastructure, tools, libraries, documentation, etc. A monorepo is a powerful way to organize a codebase, used by Google, Facebook, Uber, Microsoft, etc.

β”œβ”€ .github                            # Separate GitHub workflows for deploying Infrastructure and app
β”œβ”€ Code                               # Contains the application source code
β”‚  β”œβ”€ AppBlueprint        
β”‚     β”œβ”€ Appblueprint.AppHost         # .NET Aspire project starting app and all dependencies in Docker
β”‚      β”œβ”€ Appblueprint.Gateway        # Blazor Server app utilizing Mudblazor components
β”‚      β”œβ”€ Appblueprint.Web            # Blazor Server app utilizing Mudblazor components
β”‚      β”œβ”€ Appblueprint.ApiService     # .Net Rest/GraphQL API
β”‚      β”œβ”€ Appblueprint.Workers        # Background workers for long-running tasks and event processing
β”‚      β”œβ”€ Appblueprint.SharedKernel   # Shared code between all projects
β”‚      β”œβ”€ Appblueprint.UiKit          # Shared UI components
β”‚      β”œβ”€ Appblueprint.Tests          # Tests for all projectsβ”‚  β”‚   

Use case features of App Blueprint

  • User management

    • Register a new user account
    • Login with existing user account
    • Logout from user account
    • Manage user profile
    • Manage user account settings
    • File management
      • Upload a file
      • Download a file
      • Delete a file
      • Share a file
      • Manage files
      • Search and filter for a file
      • Export user data
    • Notification management
      • View notifcations
      • Check off notifications as read
    • Data export
      • Export user data
  • Role and Permission management

    • Customer admin should be able to manage roles and permisions
    • Customer admin should be able to create a team
    • Customer admin should be able to assign members to a team
    • Customer admin should be able to create API keys
  • Tenant management

    • Automatically provision a new tenant for a customer that signs up
  • Subscription management

    • Create a new subscription for a customer that signs up to a paid plan
    • Cancel existing subscription
  • Payment management

    • Create a payment intent for a customer that signs up to a paid subscription plan
    • Create a payment intent for a customer that that purchases a perperual license
    • Create a payment intent for a customer that that purchases credits
  • Admin Management (My own access to manage my customers and their subscriptions across deployed SaaS app products)

    • Manage all users
    • Manage all tenants
    • Manage all subscriptions
    • Manage all payment intents
    • Manage all payment transactions
    • Manage all roles and permissions
    • Manage all customers
  • Invoice management

    • Create a new invoice for a customer that signs up to a paid plan
    • Send invoice to customer
    • Manage invoices
  • Audit log

    • User activity
    • User audit log
  • Settings

  • Dashboard

  • Reporting

  • Onboarding flow for new customers

    • Set user details such as name, age and so on
    • Set business details such as company name, VAT and so on

πŸ“™ Architectural decision record for SaaS Factory

  • Shared API vs. Separate API for each SaaS app project [Seperate API: APPROVED]

    • Purpose

      • Shared API for all deployed SaaS apps
      • Shared API for Deployment Manager
      • Shared API for App Blueprint
    • Disadvantages of shared API:

      • Higher complexity
        • Single point of failure for all projects
        • Risk of calling database from API Controller that does not belong to the correct SaaS app and possible data leakage
    • Advantages of shared API:

      • Lower technical debt as there is no code drift between Appblueprint and the app projects' code
      • No duplicated API code
      • Easier to maintain and update
  • Deployment Manager

    • Purpose
      • Command center to control deployment, monitoring and management of deployed SaaS apps
      • Shared Infrastructure with deployed SaaS apps
      • Integration application landscape
      • Manage customers and track growth metrics
  • App Blueprint

    • Purpose
      • Template for deploying a SaaS App
  • Deployed SaaS App

    • Purpose
      • Personal or commercial App (B2C or B2B or Developer first)

Application structure

  • Domain Driven Design
  • Clean Architecture
    • Low technical debt
    • Reliability

Self Contained Deployment Manager Modules

  • DeploymentManager.Web

    • Command center portal
  • DeploymentManager.Api

    • Rest API
    • GraphQL API
  • DeploymentManager.Codeflow

    • Dependency Tracker
  • DeploymentManager.Shared

    • Shared DTOs
    • Shared Enums
    • Shared Entities
  • Shared Infrastructure

Self Contained Deployed SaaS App

  • App-Blueprint template

  • FileDiscovery.Web

    • Customer management portal
    • Partner portal
    • Admin portal
  • FileDiscovery.Api

    • Rest API
    • GraphQL API

Tech stack

Frontend

  • Blazor
    • Dotnet familiarity
    • Performant
    • Can run everywhere as Web Assembly or hosted server web app
    • Strong integration with dotnet backend technologies
    • Mudblazor framework for fast user interface development

Backend

  • Dotnet
    • Familiarity => High productivity
    • Performant
  • YARP Proxy
  • Authentication solution eg. Supertokens

: Infrastruture

  • Railway
    • PostgreSQL databases
  • Cloudflare R2 blob storage
  • Redis Cloud
  • Algolia
  • Grafana Cloud
  • Cloudflare
  • Stripe
  • Resend
  • Azure Key Vault
  • Logsnag
  • Cookiebot
  • Microsoft Clarity
  • Google Recaptcha
  • Google Analytics
  • Google Tag Manager

Monitoring and observability

  • Open Telemetry

CI/CD

  • Github Actions
  • Pulumi Automation API
  • Cloudcostify API
  • Sonarcloud

Testing

  • NSubstitute
  • xUnit
  • Bogus
  • Architecture testing
  • Function testing
  • Integration testing
  • Performance test (Grafana K6)
    • Smoke test
    • Load test

Documentation

  • Deployment Manager dependency tracking map
  • Dive (docker image analysis)
  • Github Copilot automatic documentation
  • Automatic swagger Rest API documentation
  • Automatic GraphQL schema documentation
  • Open Telemetry dependencies map
  • Standards
    • Naming convention
    • Sonarcloud Gate
      • Technical debt under 1 hour
    • Project file structure

Security

  • CORS
  • CSRF
  • HSTS
  • CSP
  • Zero trust & no credentials
  • IP whitelisting
  • Monitoring
  • Pentesting
  • Cloudflare DDOS protection

Development tools

  • Microsoft SQL Studio
  • Visual Studio 2022
  • Github Copilot (Chat & Voice)
  • VS Code
  • Docker Desktop
  • Postman

Visualization of the codebase

https://themes.arctechonline.tech/export

About

Web based portal to deploy an entire C# based SaaS application from start to finish to speed up development and deployment of new SaaS projects to increase development velocity

Topics

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published