Skip to content
/ god-tier-saas Public template

A SaaS kit providing end-to-end type safety with ts-rest between Next.js and Nest.js, plus integrated services like AuthJS, PostHog, and Drizzle ORM with PostgreSQL.

License

Notifications You must be signed in to change notification settings

mit-27/god-tier-saas

Repository files navigation

🚀 God Tier SaaS - Build the next Enterprise application

og-image

A SaaS Kit offering end-to-end type safety with ts-rest between Next.js and Nest.js, along with integrated services like AuthJS for authentication, PostHog for analytics, and Drizzle ORM with PostgreSQL for database management.

Perfect to build scalable SaaS applications.

Key Features

  • End-to-end Type safety with ts-rest
  • Dashboard and Landing Page with NextJS
  • Optimistic UI with TanStack Query
  • Database management with Drizzle ORM
  • Authentication ready with NextAuth.js
  • Containerized development environment
  • Monorepo structure for efficient code organization
  • Analytics with PostHog
  • Ready-to-use ContentLayer for blog and changelog

Tech Stack

  • NextJS - Frontend framework
  • NestJS - Backend framewor
  • ts-rest - End-to-end type safety
  • Drizzle ORM - Database management
  • NextAuth.js - Authentication
  • Docker - Containerization
  • PostHog - Analytics
  • Content Collections - Blog and changelog

This stack ensures a robust, scalable, and maintainable application with strong typing throughout the entire codebase and secure authentication.

Project Structure

  • apps/web - The Next.js web application
  • apps/server - The Nest.js API server
  • packages/shared - The shared module which manages the database and ts-rest router for both the web and Server projects

Setup and Running Instructions

1. 🐳 Using Docker

To set up and run the project using Docker Compose:

  1. Ensure you have Docker and Docker Compose installed on your system.

  2. Open a terminal and navigate to the project's root directory.

  3. Copy the example environment files and add appropriate environment variables:

    cp apps/web/.env.example apps/web/.env.local
    cp .env.example .env
    cp apps/server/.env.example apps/server/.env
    cp packages/shared/.env.example packages/shared/.env

    Edit .env files and add the necessary environment variables. Follow instructions in each file and modify the values according to your environment and the way you want to run the app.

  4. Remove all node_modules

    rm -rf node_modules .pnpm-store ./apps/web/node_modules ./apps/server/node_modules ./packages/shared/node_modules ./apps/server/dist pg_data
  5. Run the following command:

    docker-compose -f docker-compose.dev.yml up

This command will build and start all the necessary containers defined in the docker-compose.dev.yml file.

2. 📦 Using pnpm (Local Development)

To set up and run the project locally using pnpm:

  1. Make sure you have Node.js (version 18 or higher) and pnpm installed on your system.

  2. Open a terminal and navigate to the project's root directory.

  3. Copy the example environment files and add appropriate environment variables:

    cp apps/web/.env.example apps/web/.env.local
    cp .env.example .env
    cp apps/server/.env.example apps/server/.env
    cp packages/shared/.env.example packages/shared/.env

    Edit both .env files and add the necessary environment variables. Here docker-compose.postgres.yml used db credentials from .env file. So make sure the credentails that you used in apps.server/.env and packages.shared/.env are same as root .env file. Follow instructions in each file and modify the values according to your environment and the way you want to run the app.

  4. Install the dependencies by running:

    pnpm install
  5. Build the shared module

    pnpm run build:shared 
  6. Start the PostgreSQL database using Docker Compose:

    docker-compose -f docker-compose.postgres.yml up -d
  7. Start the development servers by running:

    pnpm run dev

This command will concurrently start both the Next.js web application (on port 8090) and the NestJS API server with shared module which manages db and ts-rest router. It uses Turbo to manage the monorepo workspace and run the development scripts for both the web and API projects simultaneously.

Make sure your environment variables are properly configured to connect to the PostgreSQL database started by Docker Compose.

Support

Support me by giving a star ⭐ on this repository.

License

This project is licensed under the MIT License.

About

A SaaS kit providing end-to-end type safety with ts-rest between Next.js and Nest.js, plus integrated services like AuthJS, PostHog, and Drizzle ORM with PostgreSQL.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published