Welcome to the SaaS Starter Kit! This project provides a comprehensive, production-ready foundation for building modern, scalable Software-as-a-Service (SaaS) applications. It features a monorepo structure powered by Turborepo and Bun, a universal frontend application built with React Native/Expo, a robust NestJS backend with GraphQL, and infrastructure-as-code using AWS CDK.
- Monorepo Architecture: Managed with Turborepo and Bun for optimized builds, efficient dependency management, and a streamlined developer experience across multiple packages and applications.
- Universal Frontend: A single React Native codebase using Expo to build applications for iOS, Android, and the Web.
- UI & Styling: Gluestack UI v2 component library with NativeWind for Tailwind CSS utility-first styling.
- Navigation: Expo Router for file-system based routing.
- API Communication: Apollo Client for interacting with the GraphQL backend.
- Scalable Backend: A NestJS API built with:
- GraphQL: Apollo Server using a code-first schema approach.
- Database: PostgreSQL integration via TypeORM.
- Deployment: Configured for serverless deployment using the Serverless Framework.
- Authentication: Secure user authentication and management via AWS Cognito.
- Infrastructure as Code (IaC): Manage and deploy your AWS infrastructure repeatably and reliably using the AWS CDK (Cloud Development Kit).
- Developer Experience:
- End-to-end TypeScript for robust type safety.
- Pre-configured linting with ESLint and code formatting with Prettier.
- Shared configurations for TypeScript, ESLint, and Prettier located in the
packages/directory. - Unit and integration testing setup with Jest.
- (Planned) Multi-Tenancy: Architectural considerations for organization-based multi-tenancy.
- (Planned) Role-Based Access Control (RBAC): Foundation for a flexible permission system.
- Monorepo Management: Turborepo, Bun
- Frontend:
- Core: React Native, Expo, Expo Router
- UI: Gluestack UI v2
- Styling: NativeWind v4, Tailwind CSS
- Data: Apollo Client (for GraphQL)
- Backend:
- Framework: NestJS
- API: GraphQL with Apollo Server
- ORM: TypeORM
- Database: PostgreSQL
- Deployment: Serverless Framework
- Authentication: AWS Cognito
- Infrastructure: AWS CDK (Cloud Development Kit)
- Language: TypeScript
- Linting & Formatting: ESLint, Prettier
- Testing: Jest, (Planned: Playwright for E2E)
- CI/CD: GitHub Actions
Ensure the following tools are installed and configured on your system:
- Bun: v1.0.0 or higher.
- Node.js: v18 or v20 (LTS versions recommended). Use nvm to manage Node versions.
- Git: For version control.
- Docker: For running local development services (e.g., PostgreSQL database for the backend).
- AWS CLI: Configured with appropriate AWS credentials.
- AWS CDK Toolkit: v2 or higher (
npm install -g aws-cdk).
-
Clone the Repository:
git clone https://github.com/your-org/saas-starter.git my-saas-app cd my-saas-app(Replace
your-org/saas-starter.gitwith your actual repository URL) -
Install Dependencies: From the root of the monorepo, run:
bun install
This installs dependencies for all workspaces.
-
Environment Configuration:
- Root
.env: Copy.env.exampleto.envat the project root. Update withTURBO_TOKENandTURBO_TEAMif using Turborepo Remote Caching. - Frontend (
apps/frontend):- Copy
apps/frontend/.env.exampletoapps/frontend/.env.local(for local development). - Set
EXPO_PUBLIC_GRAPHQL_BASE_URL(e.g.,http://localhost:3000/graphqlor your deployed backend URL). - Update
EXPO_PUBLIC_SENTRY_DSNif using Sentry. - Important: Update the EAS Project ID in
apps/frontend/eas.jsonand potentially inapps/frontend/app.config.ts.
- Copy
- Backend (
apps/backend):- Copy
apps/backend/.env.exampletoapps/backend/.env.dev(used byserverless-offline). - Set
DATABASE_URL(e.g.,postgresql://postgres:postgres@localhost:5432/saas_starter_dbfor the local Docker setup). COGNITO_USER_POOL_IDandCOGNITO_CLIENT_IDwill be outputs from your Cognito CDK stack deployment.- Update
SENTRY_DSNif using Sentry.
- Copy
- Root
-
AWS Setup (for cloud deployments):
- Configure your AWS CLI with SSO or IAM credentials:
aws configure sso(recommended) oraws configure. - If your organization uses an AWS VPN for specific environments, ensure it's connected.
- Configure your AWS CLI with SSO or IAM credentials:
-
(Optional) Local Database with Docker: A
docker-compose.ymlis provided inapps/backend/for a local PostgreSQL instance.# From the apps/backend directory docker-compose up -d
The monorepo is organized to promote separation of concerns and scalability:
apps/: Contains the deployable applications.docs/: Project-level documentation, including architecture, development guides, and decision records.CONTRIBUTING.md: Guidelines for contributing.- (Links to other key documents like
CODING_STANDARDS.md,WORKFLOWS.mdwill be added here as they are created).
infrastructure/: AWS CDK code for defining and provisioning cloud infrastructure. Seeinfrastructure/README.md.packages/: Shared TypeScript packages.config/: Shared runtime configurations (e.g., branding).eslint-config/: Shared ESLint configurations.prettier-config/: Shared Prettier configuration.tsconfig/: Shared TypeScript base configurations.
scripts/: Utility scripts for automation and development tasks. Seescripts/README.md.
Execute commands from the root of the monorepo using bun run <script>.
- Start all apps in development mode:
bun run dev - Lint all code:
bun run lint - Format all code:
bun run format - Run all tests:
bun run test - Build all apps and packages:
bun run build - Type check all packages:
bun run typecheck - Clean build artifacts & caches:
bun run clean
- Frontend:
- Dev server (Expo Go, Web):
bun run dev:frontendorbun run dev:web - iOS simulator:
bun run dev:ios - Android emulator:
bun run dev:android - Environment-specific start:
bun start:local-frontend(seeapps/frontend/README.md) - Generate GraphQL types:
bun generate:types:frontend
- Dev server (Expo Go, Web):
- Backend:
- Dev server (NestJS + Serverless Offline):
bun run dev:backend - GraphQL Playground/Sandbox:
http://localhost:3000/graphql(or configured port) - Generate GraphQL schema/types:
cd apps/backend && bun run generate:typings - Database migrations:
cd apps/backend && bun run migration:run:local(ormigration:runfor cloud)
- Dev server (NestJS + Serverless Offline):
Refer to individual app READMEs in apps/ for more detailed commands.
- VS Code: Recommended. Install workspace-recommended extensions (prompt on open or check
.vscode/extensions.json). Key extensions include ESLint, Prettier, GraphQL, Apollo Client Devtools, Jest. - Prettier: Configured via
packages/prettier-config. Enable "Format on Save" in VS Code.
Shared configurations ensure consistency across the monorepo:
- ESLint:
packages/eslint-config - Prettier:
packages/prettier-config - TypeScript:
packages/tsconfig - Runtime Config:
packages/config(for branding, etc.)
See each package's README for usage details.
- Infrastructure (AWS CDK): From
infrastructure/:cd infrastructure # bun run cdk bootstrap --profile <aws-profile> # If first time bun run deploy:<dev|staging|prod>
- Backend API (Serverless Framework): From
apps/backend/:cd apps/backend bun run deploy:<dev|staging|prod>
- Frontend App (Expo EAS): From
apps/frontend/:Web builds (cd apps/frontend eas build -p <android|ios|all> --profile <development|preview|production> eas submit -p <ios|android> --profile <production> --latest
bun run build:webinapps/frontend) are deployed to static hosting.
Contributions are welcome! Please review our CONTRIBUTING.md for guidelines on commit messages, the PR process, coding standards, and more.
(Note: CONTRIBUTING.md will be created/populated with content moved from apps/backend/README.md in a separate step/task).
- Backend Documentation Index
- Frontend Documentation Index
- Infrastructure Documentation Index
- (More specific guides like CODING_STANDARDS.md, WORKFLOWS.md, etc., will be added to the
/docsdirectory and linked here).
- Stale Cache/Build Issues:
bun run clean rm -rf node_modules bun.lockb apps/*/node_modules apps/*/bun.lockb packages/*/node_modules packages/*/bun.lockb bun install
- Type Errors: Run
bun run typecheckto identify TypeScript issues. - Environment Variables: Double-check
.envfiles in the root and app directories.
This project is licensed under the MIT License. See the LICENSE file for details.# SaasStarter