Skip to content

Latest commit

 

History

History
175 lines (125 loc) · 4.89 KB

README.md

File metadata and controls

175 lines (125 loc) · 4.89 KB

Collab - Next.js & Prisma SaaS Starter

GitHub Banner

Next.js Prisma shadcn/ui TailwindCSS Better Auth TypeScript Docker

This project is a Next.js application initialized with create-next-app and using Prisma for database management. It also integrates shadcn for UI components and Better Auth for authentication.

Project Overview

This project aims to provide a SaaS platform with workspace creation, enabling a file manager system. Future features will include chat functionality and a calendar system to enhance collaboration within workspaces.

Prerequisites

Before starting, make sure you have the following tools installed on your machine:

Installation

Clone the repository and install dependencies:

pnpm install
# or
npm install
# or
yarn install

Configuration

Copy the .env.example file to .env and configure the environment variables:

DATABASE_URL="postgresql://USER:PASSWORD@HOST:PORT/DATABASE"
FOLDER_DATA=data
BETTER_AUTH_SECRET=..... # openssl rand -base64 32
GROQ_API_KEY=.......

Prisma

Generate the Prisma client and apply migrations:

npx prisma generate
npx prisma migrate dev --name init

Important: Run Database Seeding Before Starting the Project

Before running the development server, make sure to seed the database with initial data:

npx prisma db seed

If you need to reset the database and apply the seeders again:

npx prisma migrate reset
npx prisma db seed

Start the Development Server

npm run dev
# or
yarn dev
# or
pnpm dev
# or
bun dev

Open http://localhost:3000 in your browser to see the result.

Database Seeding

The project includes a seed script to populate the database with test data. Modify the src/lib/prisma/seeds/seed.ts file as needed.

Run the seed script:

npx prisma db seed

Docker Setup for Production

To run the project in a production environment using Docker, use the provided docker-compose.yml file.

Start the Containers

docker-compose up -d --build

Stop the Containers

docker-compose down

Docker Compose Configuration for Production

Below is the docker-compose.yml configuration used for running the application in production:

services:
  db:
    image: postgres:15.6
    container_name: collab-nextjs-db
    ports:
      - "5432:5432"
    environment:
      - POSTGRES_DB=collab
      - POSTGRES_USER=collab
      - POSTGRES_PASSWORD=collab
    volumes:
      - collab_nextjs_db:/var/lib/postgresql/data

  app:
    container_name: collab-nextjs
    build:
      context: .
      dockerfile: Dockerfile
      args:
        - FOLDER_DATA
    environment:
      - DATABASE_URL=postgresql://collab:collab@db:5432/collab?schema=public
    restart: unless-stopped
    ports:
      - "3000:3000"
    depends_on:
      - db
    volumes:
      - collab_nextjs_data:/app/${FOLDER_DATA}

volumes:
  collab_nextjs_db:
  collab_nextjs_data:

Note on Dockerfile

This project uses pnpm as the package manager in the Dockerfile. If you prefer to use npm or yarn, make sure to update the Dockerfile accordingly to replace pnpm commands with the package manager of your choice.

Documentation

Deployment

The easiest way to deploy your application is by using Vercel.

Check out the Next.js deployment documentation for more details.


Happy coding! 🚀