Guided Tour
Awesome, you now have your very own SaaS app up and running! But, first, here are some important things you need to know about your app in its current state:
- When signing up with a new user, you will get a message to check your email for a verification link. But, in development, these emails are simply written to your terminal. So, to continue with the registration process, check your server logs after sign up!
- Your app is still missing some key configurations (e.g. API keys for Payment Processors, OpenAI, AWS S3, Auth, Analytics). These services wonβt work at the moment, but donβt fear, because weβve provided detailed guides in these docs to help you set up all the services in this template.
- If you want to get a feel for what your SaaS could look like when finished, check out OpenSaaS.sh in your browser. It was built using this template! So make sure to log in, play around with the demo app, make a test payment, and check out the admin dashboard.
In the sections below, we will take a short guide through the codebase and the appβs main features. Then at the end of this tour, we also prepared a checklist of likely changes you will want to make to the app to make it your own.
Weβre looking forward to seeing what you build!
Getting acquainted with the codebase
Now that youβve gotten a first look at the app, letβs dive into the codebase.
At the root of our project, you will see three folders:
app
contains the Wasp project files, which is your full-stack React + NodeJS + Prisma app along with a Wasp config file, main.wasp
, which will be explained in more detail below.
blog
contains the Astro Starlight template for the blog and documentation section.
e2e-tests
contains the end-to-end tests using Playwright, which you can run to test your appβs functionality.
App File Structure
Weβve structured this full-stack app template vertically (by feature). That means that most directories within app/src
contain both the React client code and NodeJS server code necessary for implementing its logic.
Letβs check out whatβs in the app
folder in more detail:
The Wasp Config file
This template at its core is a Wasp project, where Wasp is a full-stack web app framework that letβs you write your app in React, NodeJS, and Prisma and will manage the βboilerplateyβ work for you, allowing you to just take care of the fun stuff!
Waspβs secret sauce is its use of a config file (main.wasp
) and compiler which takes your code and outputs the client app, server app and deployment code for you.
In this template, weβve already defined a number of things in the main.wasp
config file, including:
- Auth
- Routes and Pages
- Prisma Database Models
- Operations (data read and write functions)
- Background Jobs
- Email Sending
By defining these things in the config file, Wasp continuously handles the boilerplate necessary with putting all these features together. You just need to focus on the business logic of your app.
Wasp abstracts away some things that you would normally be used to doing during development, so donβt be surprised if you donβt see some of the things youβre used to seeing.
Client
The src/client
folder contains any additional client-side code that doesnβt belong to a feature:
Server
The src/server
folder contains any additional server-side code that does not belong to a specific feature:
Main Features
Auth
This template comes with a fully functional auth flow out of the box. It takes advantages of Waspβs built-in Auth features, which do the dirty work of rolling your own full-stack auth for you!
By defining the auth structure in your main.wasp
file, Wasp manages all the necessary code for you, including:
- Email verified login with reset password
- Social login with Google and/or GitHub
- Auth-related database entities for user credentials, sessions, and social logins
- Custom-generated AuthUI components for login, signup, and reset password
- Auth hooks for fetching user data
Weβve set the template up with Waspβs email
, google
, and gitHub
methods, which are all battle-tested and suitable for production.
You can get started developing your app with the email
method right away!
We will explain more about these auth methods, and how to properly integrate them into your app, in the Authentication Guide.
Subscription Payments with Stripe or Lemon Squeezy
No SaaS is complete without payments, specifically subscription payments. Thatβs why this template comes with a fully functional Stripe or Lemon Squeezy integration.
Letβs take a quick look at how payments are handled in this template.
- a user clicks the
BUY
button and a Checkout session is created on the server - the user is redirected to the Checkout page where they enter their payment info
- the user is redirected back to the app and the Checkout session is completed
- Stripe / Lemon Squeezy sends a webhook event to the server with the payment info
- The app serverβs webhook handler handles the event and updates the userβs subscription status
The payment processor you choose (Stripe or Lemon Squeezy) and its related functions can be found at src/payment/paymentProcessor.ts
. The Payment Processor
object holds the logic for creating checkout sessions, webhooks, etc.
The logic for creating the Checkout session is defined in the src/payment/operation.ts
file. Actions are a type of Wasp Operation, specifically your server-side functions that are used to write or update data to the database. Once theyβre defined in the main.wasp
file, you can easily call them on the client-side:
a) define the action in the main.wasp
file
b) implement the action in the src/payment/operations
file
c) call the action on the client-side
The webhook handler is defined in the src/payment/webhook.ts
file. Unlike Actions and Queries in Wasp which are only to be used internally, we define the webhook handler in the main.wasp
file as an API endpoint in order to expose it externally to Stripe
Within the webhook handler, we look for specific events that the Payment Processor sends us to let us know which payment was completed and for which user. Then we update the userβs subscription status in the database.
To learn more about configuring the app to handle your products and payments, check out the Payments Integration guide.
Analytics and Admin Dashboard
Keeping an eye on your metrics is crucial for any SaaS. Thatβs why weβve built an administratorβs dashboard where you can view your appβs stats, user data, and revenue all in one place.
To do that, weβve leveraged Waspβs Jobs feature to run a cron job that calculates your daily stats. The app stats, such as page views and sources, can be pulled from either Plausible or Google Analytics. All you have to do is create a project with the analytics provider of your choice and import the respective pre-built helper functions!
For more info on integrating Plausible or Google Analytics, check out the Analytics guide.
App Customization Walkthrough
General Considerations
When you first start your Open SaaS app straight from the template, it will run, but many of the services wonβt work because they lack your own API keys. Here are list of services that need your API keys to work properly:
- Auth Methods (Google, GitHub)
- Stripe or Lemon Squeezy
- OpenAI (Chat GPT API)
- Email Sending (Sendgrid) β you must set this up if youβre using the
email
Auth method - Analytics (Plausible or Google Analytics)
- File Uploading (AWS S3)
Now would be a good time to decide which features you do and do not need for your app, and remove the ones from the codebase that you donβt need.
For the features you will use, the next section of the documentation, Guides
, will walk you through how to set each one up!
But before you start setting up the main features, letβs walk through the customizations you will likely want to make to the template to make it your own.
Customizations Checklist
main.wasp
Config File
- Change the app name and title:
- Update meta tags in
app.head
(even if you donβt have a custom domain yet, put one you would like to have, as this wonβt affect development). - Update
app.emailSender.defaultFrom.name
with the name of your app/company/whatever you want your users to see in their inbox, if youβre using theemailSender
feature and/oremail
Auth method. - Remove any features you might not use or need:
- Auth methods -
app.auth.methods
- If youβre not using
email
Auth method, remove the routes/pagesRequestPasswordReset
,PasswordReset
, andEmailVerification
- If youβre not using
- Email Sending -
app.emailSender
,job emailChecker
- Plausible analytics -
app.head
- File Uploading -
entity File
,route FileUploadRoute
,action createFile
,query getAllFilesByUser
,getDownloadFileSignedURL
- Auth methods -
- Rename Entites and their properties, Routes/Pages, & Operations, if you wish.
Customizing the Look / Style of the App
- Update your favicon at
public/favicon.ico
. - Update the banner image used when posting links to your site at
public/public-banner.png
.- Update the URL for this banner at
og:image
andtwitter:image
inapp.head
of themain.wasp
file.
- Update the URL for this banner at
- Make changes to your landing page,
landingPage.tsx
.- Customize the
navBar
,features
,testimonials
, andfaqs
in thecontentSections.ts
file. - Change/rename the
logo.png
and main banner (open-saas-banner.png
) in thestatic
folder.
- Customize the
- If you want to make changes to the global styles of the app, you can do so in
tailwind.config.cjs
. Be aware that the current custom global styles defined already are mostly used in the appβs Admin Dashboard!
Customizing the Analytics & Admin Dashboard
- If youβre using Plausible, update the
app.head
with your Plausible domain. - Update the
calculateDailyStats
function insrc/server/workers/calculateDailyStats.ts
to pull the stats from the analytics provider youβve chosen (Plausible or Google Analytics). - Change the cron schedule in the
dailyStatsJob
in themain.wasp
file to match how often you want your stats to be calculated. - Update the
AdminDashboard
components to display the stats you do/donβt want to see.
.env.server
and .env.client
Files
- After youβve followed the
Guides
in the next section, youβll need to update the.env.server
and.env.client
files with your API keys and other environment variables for the services youβve decided to use. - Delete any redundant environment variables that youβre not using, from the
.env.*
files as well as the.env.*.example
files.
Other Customizations
- Make a new GitHub Repo for your app.
- Deploy your app to a hosting provider.
- Buy a domain name for your app and get it set up with your hosting provider.
- Read the
e2e-tests
README and get your end-to-end tests set up.- Change the tests to suit the changes youβve made to your app
- Get the CI pipeline set up for your app (you can get started by using the Open SaaS development CI example here)
Whatβs next?
In the following Guides
sections, weβll walk you through getting those API keys and setting up the finer points of features such as Payments & Webhooks, Auth, Email Sending, Analytics, and more.