- Landing page with feature promotion
- Pricing page (/pricing) which connects to Stripe Checkout
- Dashboard pages with CRUD operations to modify user
- Admin role in firebase claims (admins sees activity)
- Subscription management with Stripe Customer Portal
- Authentication with firebase
- Activity logging system for any user events
-
Frontend Framework: Next.js
-
Backend Framework Encore.go
-
ORM: gorm go
-
Payments: Stripe
-
UI Library: shadcn/ui
When you have installed Encore, you can create a new Encore application and clone this example with this command.
encore app create my-app-name --example=encore-saas-templateRunning the backend requires the following scripts:
encore run # This has to be run to setup the postgres docker db and volume for later stepspnpm iSeeding the users in Firebase and Postgres. Find service-account.json in Firebase Console > Project Setting > Service Accounts > Generate new private key. (note: run script setup-firebase-and-users:clean to remove users)
pnpm setup-firebase-and-users --service-account "/path/to/service-account.json"Set Stripe secrets and setup a stripe webhook (requires Stripe CLI is installed)
This command also runs stripe listen to forward stripe webhooks to our backend locally.
pnpm run setup-stripecd frontend
pnpm i
pnpm gen:local # generate a client for the frontend to encores cli with
pnpm devTo test Stripe payments, use the following test card details:
Card Number: 4242 4242 4242 4242 Expiration: Any future date CVC: Any 3-digit number
While encore run is running, open http://localhost:9400/ to access Encore's local developer dashboard.
Here you can see API docs, make requests in the API explorer, and view traces of the responses.
Deploy your application to a staging environment in Encore's free development cloud:
git add .
git commit -m "first commit"
git push encoreModify encore.app to look like:
{
"id": "<encore-app-id>",
"global_cors": {
"allow_origins_with_credentials": [
"http://127.0.0.1:3000",
"http://localhost:3000",
"https://<vercel-app-name>.vercel.app"
]
}
}
Then head over to the Cloud Dashboard to monitor your deployment and find your production URL.
From there you can also connect your own AWS or GCP account to use for deployment.
- Push your code to a GitHub repository.
- Connect your repository to Vercel and deploy it.
- Follow the Vercel deployment process, which will guide you through setting up your project.
- Remember to setup the env variables in Vercel
- Go to Firebase Console
- Go to Authentication -> Settings
- Add the vercel domain to authorized domains.
- Go to the Stripe Dashboard and create a new webhook for your production environment.
- Set the endpoint URL to your production API route (e.g.,
https://yourdomain.com/api/stripe/webhook). - Select the events you want to listen for (e.g.,
checkout.session.completed,customer.subscription.updated).
encore secret set --type production StripeSecretKey
encore secret set --type production StripeWebhookSecret
encore secret set --type production CallbackURLSetup a production environment in Encore's cloud dashboard and link to the branch of choice. Then on the production branch:
git commit encoreencore secret set --type production FirebasePrivateKey < "/path/to/service-account.json"Remember to setup the environment variables required in Vercel.