/nest-next-prisma-boilerplate

Fullstack boilerplate with NestJS, NextJS, tRPC, Prisma

Primary LanguageTypeScript

🎏 NestJS - NextJS - tRPC - Prisma stack app

🍰 Tech stack

  • DB: PostgreSQL (dockerized)
  • ORM: Prisma
  • Node.js framework: NestJS
  • End-to-end type-safe APIs: tRPC
  • Frontend: NextJS
  • Style: Tailwind + daisyUI
  • Node.js package manager: pnpm
  • Monorepo: pnpm workspace
  • Containerization: Docker

🥕 Getting Started

Update pnpm:

pnpm i -g pnpm

Develop:

# create local environment variables
cp ./apps/web/.env.local.example ./apps/web/.env.local

# Optionally, modify the conf.ini file to change database settings

# Start the Docker containers
docker compose up --build

Following this, you can open:

  • http://localhost:3000 in your browser for the NextJS app
  • http://localhost:4000 for the NestJS server
  • http://localhost:5555 for Prisma Studio

To stop and remove the containers, networks, and volumes defined in the docker-compose.yml file, run:

docker compose down

Note: This will not remove the persistent volume for the PostgreSQL data. If you want to remove all data and start fresh, use:

docker compose down -v

If you want to install the @nestjs/config package. In the root of your directory, you can run:

pnpm add @nestjs/config --filter=server

Docker Configuration

  • docker-compose.yml and StandaloneDockerfile are used for local development and testing.
  • The Dockerfile in the root directory is specifically configured for deployment on railway.app.(This platform does not support docker-compose yml)

Deployment

This repo has been tested to run with railway. You can fork and open railway to establish: deploy on railway

Database Backup and Restore

To backup the PostgreSQL database:

docker run --rm -v postgres_data:/dbdata -v $(pwd):/backup alpine tar cvf /backup/backup.tar /dbdata

To restore the PostgreSQL database:

docker run --rm -v postgres_data:/dbdata -v $(pwd):/backup alpine sh -c "cd /dbdata && tar xvf /backup/backup.tar --strip 1"

🧚‍♀️ Reference

More docs in this repo

server/Readme

web/Readme

Configuration

The project uses a conf.ini file in the root directory to set variables for Docker building. You can modify this file to change database settings and other environment variables.