This repository contains code for the DBOS Cloud account management app, which is built with DBOS Transact (TypeScript), Fastify, and Stripe, and deployed on DBOS Cloud.
When a customer clicks "Upgrade to Pro" on the DBOS Console, this app redirects them to a customized Stripe checkout page, where they enter payment information. After they pay, Stripe sends a notification to a webhook endpoint on this app. The webhook retrieves the customer's updated subscription status from Stripe, maps their Stripe customer ID to a DBOS Cloud account ID, and updates their subscription status in DBOS Cloud.
This repo demonstrates a complete production DBOS application, including cloud deployment and CI/CD, written in <600 lines of code. Specifically, it highlights:
- Use of DBOS workflows, steps, and transactions for reliable, exactly-once execution
- Asynchronous and reliable event processing for Stripe Webhook
- Using Fastify for HTTP serving
- Integration with Stripe Billing and the Stripe Customer Portal
- Integration with Auth0 for authentication and authorization
- Using Knex.js for schema management and queries
- Automated testing and deployment with the DBOS CLI and GitHub Actions
- Unit tests for individual functions and endpoints with jest.
The main source code files:
src/server.tsMain entrypoint for the HTTP serversubscription.tsWorkflows, steps, transactions, and HTTP endpoints for subscriptionssubscription.test.tsUnit tests
dbos-config.yamlDBOS configuration filemigrations/Schema definition in Knex.js format
Files for CI/CD:
scripts/dbos_deploy.shScript that deploys this app to DBOS Cloudsubscription_integration_test.pyAutomated integration test for subscription that runs against staging and prod
.github/workflows/Github Actions for deployment and testing