Welcome to the "Let's Build It: Multi Tenanted SaaS App in TypeScript" course on Dometrain!
On the course you will build a full stack SaaS application in TypeScript. The code is ordered into three folders in this repository
- ./backend - The back end (NodeJS/AWS CDK)
- ./frontend - The front end (React)
- ./common - TypeScript types & code shared across the stack
The main
branch contains the final working version of the project. There are also branches you can check out as starting points for each section:
- Starting point for Front End (branch 01) - A new Vite application with most of the demo code removed
- Mocked Front End, No Auth (branch 02) - A working front end using mocked API responses
- Starting Point for Back End (branch 03) - A new AWS CDK application with some helper Constructs
- Backend services created (branch 04) - Backend services created (except API)
- Hosted UI For Authentication (branch 05) - Hosted UI Configured and Integrated with FrontEnd
- API Created (branch 06) - Back end API endpoints created, FrontEnd now works with no mocks
- Stripe Integration Added (branch 07) - Stripe added to both front end and back end to process
To use a branch, clone this repository and switch to the required section:
git clone https://github.com/Dometrain/lets-build-it-multi-tenant-saas-app-in-typescript.git
cd lets-build-it-multi-tenant-saas-app-in-typescript
# Check out the branch for the starting point of required section...
git checkout section/01
In order to deploy this project you will need:
- An AWS Account
- AWS CLI
- Bootstrapped AWS CDK
- A domain name (optional)
- A Stripe account (optional)
Visit https://aws.amazon.com to set up a new account.
Everything you deploy in this project will fit well within the AWS free tier, except for a Route53 Hosted Zone which costs $0.50 per month. Realistically you could run this multi tenanted SaaS application for approximately 20 customers before reaching the limits of the AWS Free Tier, depending on usage.
This project will be deployed from the command line using the AWS CLI tool. After setting up your AWS account, follow this guide to download the AWS CLI and connect it to your AWS account.
https://docs.aws.amazon.com/cli/latest/userguide/getting-started-quickstart.html
Test your CLI connection with:
aws sts get-caller-identity
And check the output:
{
"UserId": "<YOUR USER ID>",
"Account": "<YOUR AWS ACCOUNT ID",
"Arn": "arn:aws:iam::<ACCOUNT-ID>:user/<IAM-USER>"
}
The project will be deployed to the us-east-1 region. Due to restrictions on AWS ACM certificates you must deploy to this region. You can set the default region with export AWS_REGION=us-east-1
NOTE CLI commands referenced in this course will use bash. If you are using a Windows machine you should install WSL 2.0 to follow along. You can deploy the application using the standard Windows terminal but some of the commands refernced in the videos may not work.
You will be creating AWS resources in TypeScript using the AWS CDK. You can install this globally with
npm install -g [email protected]
cdk bootstrap
To get the most out of this course, it is recommended to register a custom domain and link it to your AWS account.
- Register a domain via any provider (eg Namecheap)
- Create a public hosted zone in Route53 (follow this guide)
- Link your custom domain to Route53 nameservers (guide for Namecheap)
- Make a note of your hosted zone id
aws route53 list-hosted-zones --output text
{
"HostedZones": [
{
"Id": "/hostedzone/<YOUR-HOSTED-ZONE-ID>", # <-- find your ID here
"Name": "mysaasproduct.com.",
}
]
}
The course takes you through integrating the payment processor Stripe so you can start selling your SaaS!
Create an account with Stripe here: https://dashboard.stripe.com/register
You will use your Stripe account in the later sections of the course.