A modern full-stack TypeScript monorepo using:
- Next.js (Web)
- NestJS (API)
- Expo (Mobile)
- tRPC (End-to-end type-safe API calls)
- PostgreSQL or MongoDB (Database - your choice!)
- Prisma or Mongoose (ORM/ODM - based on your DB choice)
- Better Auth (Authentication with OAuth, Email OTP)
- SonarQube (Code quality)
- Rollbar (Error tracking)
- Turborepo (Build orchestration)
This repository is structured for scalability, developer experience, and seamless cross-platform sharing of logic and types.
Make sure the following are installed before setup:
| Tool | Description | Version |
|---|---|---|
| Git | Source control | Latest |
| Node.js | Runtime | >= v18 |
| pnpm | Fast package manager | npm i -g pnpm |
| Docker | For database container | Latest |
| Java + Android SDK (for mobile) | Required to run Expo Android app | Optional |
Before proceeding with the setup, ensure you have all the required prerequisites installed. Missing any of these may cause the setup to fail or not work as expected.
git clone https://github.com/BinaryExploits/be-full-stack-boilerplate.git
cd be-full-stack-boilerplateOnce the repository is cloned, you can run an automated setup script from the root to prepare dependencies and the project:
npm run setupor
node setup.jsThis script will automatically perform all the steps mentioned below.
Alternatively, you can follow the steps mentioned below manually to set up the project.
At the root of the repository:
pnpm installThis installs all dependencies across all workspaces.
Create .env files for each of the following:
apps/api/.env
apps/web/.env
apps/app/.env
packages/prisma-db/.env
packages/sonarqube/.env
Important environment variables for apps/api/.env:
# Database Configuration
DB_PROVIDER=postgresql # or 'mongodb'
DATABASE_URL_MONGODB=mongodb://localhost:27017/your-db-name # if using MongoDB
DATABASE_URL=postgresql://user:password@localhost:5432/db # if using PostgreSQL
# Better Auth
BETTER_AUTH_SECRET=your-secret-key
BETTER_AUTH_TRUSTED_ORIGINS=http://localhost:3000,http://localhost:8081
GOOGLE_CLIENT_ID=your-google-client-id
GOOGLE_CLIENT_SECRET=your-google-client-secret
# Email service, Rollbar, etc.Each .env file should contain the necessary variables (e.g. database URLs, API base URLs, etc.).
Navigate to the API app and start the database via Docker:
cd apps/api
docker-compose up -dThis starts both PostgreSQL and MongoDB containers.
Setup Prisma:
cd packages/prisma-db
pnpm prisma migrate deploy
pnpm prisma generateNo additional setup needed - Mongoose handles schema creation automatically.
From the root directory:
pnpm devThis command runs all apps (API, Web, and Mobile) concurrently using Turborepo.
.
├── ...
├── apps/
│ ├── api/ # NestJS API
│ ├── web/ # Next.js Web App
│ └── app/ # Expo Mobile App
│
├── packages/
│ ├── prisma-db/ # Prisma schema + migrations
│ ├── trpc/ # Shared tRPC router + types
│ ├── eslint-config/ # Linter Config
│ ├── sonarqube/
│ ├── ...
│ └── typescript-config/ # TS Config
│
├── turbo.json # Turborepo configuration
└── pnpm-workspace.yaml # Workspace Structure
└── ...
| Command | Description |
|---|---|
pnpm dev |
Run all apps in development mode |
pnpm prisma migrate deploy |
Apply Prisma migrations |
pnpm prisma generate |
Generate Prisma client |
- ⚡ Turborepo – Monorepo management
- 💬 tRPC – End-to-end type-safe API communication
- 🧠 Zod – Runtime validation & schema definition
- 🗄️ Database Options – Choose between:
- PostgreSQL + Prisma – Relational database with type-safe ORM
- MongoDB + Mongoose – NoSQL database with ODM
- 🔐 Better Auth – Modern authentication framework with:
- Email OTP authentication
- Google OAuth
- Expo mobile support
- Email verification
- 💻 Next.js – Web frontend
- 📱 Expo (React Native) – Mobile app
- 🧱 NestJS – Backend API
- 🧩 Shared Packages – Centralized types & logic
- Keep Docker running while developing backend/API.
- Use
pnpmconsistently — do not use npm or yarn. - Better Auth requires proper environment variables for OAuth providers.