This project is a full-stack serverless SaaS application template built with SST (Serverless Stack) and running on AWS. This template is an extension of the notes app created in the SST guide, modifying the storage based pricing model in the example to a flat-rate subscription model.
- Serverless architecture using AWS services
- User authentication and authorization with Amazon Cognito
- API Gateway for RESTful endpoints
- DynamoDB for data storage
- S3 for file storage
- Automated Stripe product and pricing integration
- React frontend with TypeScript
- Stripe Integration: This template automatically pulls your products and their associated prices from your Stripe account. There's no need for manual configuration of products or prices within the template itself.
- Dynamic Plan Picker: The PlanPicker component displays your Stripe products and prices in cards, offering a ready-to-use subscription interface.
- Serverless Secrets Management: Environment variables, including Stripe credentials, are securely managed using the
sst.Secret
component, ensuring best practices for secret management in a serverless environment.
-
If you haven't done so, get started by going through the SST guide to get familiar with the basics of this project and its workflow.
-
Use this template to create your own repo.
-
Clone the new repo.
git clone MY_APP cd MY_APP
-
Rename the files in the project to the name of your app.
npx replace-in-file /aws-sst-saas-template/g MY_APP **/*.* --verbose
-
Install dependencies:
npm install
-
Configure Stripe secrets: Use the SST CLI to set your Stripe secret key:
npx sst secrets set STRIPE_SECRET_KEY your_stripe_secret_key npx sst secrets set STRIPE_PUBLIC_KEY your_stripe_public_key
-
Deploy!
npx sst deploy
-
Optionally, enable git push to deploy.
This template uses npm Workspaces. It has the following packages:
-
core/
: This is for any shared code. It's defined as modules. -
functions/
: This is for your Lambda functions and it uses thecore
package as a local dependency. -
frontend/
: This contains the React frontend application. -
scripts/
: This is for any scripts that you can run on your SST app using thesst shell
CLI andtsx
.
The infra/
directory allows you to logically split the infrastructure of your app into separate files. This can be helpful as your app grows.
These resources are imported in the sst.config.ts
.
api.ts
: Defines API Gateway routes and integrationsauth.ts
: Configures Cognito user pool and identity poolstorage.ts
: Sets up DynamoDB tables and S3 bucketweb.ts
: Configures the static site hosting for the frontend
App.tsx
: Main React component and routingcontainers/
: React components for different pagescomponents/
: Reusable React components, including PlanPickerlib/
: Utility functions and custom hooks
- Modify the DynamoDB table schemas in
storage.ts
to fit your data model. - Update API routes in
api.ts
to add or modify endpoints. - Customize the React components in the
packages/frontend/
directory to match your UI requirements. - Adjust the Stripe product configurations in your Stripe dashboard to reflect your desired pricing model.
Run the test suite with:
npm test
To deploy to production:
npx sst deploy --stage prod
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.
If you have any questions or need help with setup, please open an issue in the GitHub repository.