Installation

Install Dependencies

Using pnpm:

pnpm install

Or using npm:

npm install

Or using Yarn:

yarn install

Environment Variables

Create a .env.local file in the root directory by copying the example:

cp .env.dist .env.local

Generate Auth Secret

  1. Generate the AUTH_SECRET variable using the following command:
npx auth secret

It should automatically add the secret to your .env.local file:

AUTH_SECRET=your_generated_auth_secret

Generate Encryption Key for Passwords

  1. Run the following command to generate an encryption key:
openssl rand -base64 32
  1. Add the generated key to your .env file:
ENCRYPTION_KEY=your_generated_key

Configure Password Salt Rounds

  1. Choose a Salt Rounds Value: Decide on the number of salt rounds for hashing passwords. A minimum of 10 is recommended for security.

  2. Add to Environment File: Add the chosen number of salt rounds to your .env.local file:

PASSWORD_SALT_ROUNDS=your_chosen_number

Database Setup

  1. Configure Database URL

Ensure your .env.local file has the correct DATABASE_URL. For example:

DATABASE_URL="postgresql://user:password@localhost:5432/mydb?schema=public"
  1. Run Migrations

Apply database migrations in development:

pnpm migrate:dev
  1. Run Seeds (Optional)

After running migrations, you can optionally run seeds to populate your database with initial data:

pnpm db:seed
  1. Update Prisma Client

Whenever you make changes to schema.prisma, regenerate the Prisma Client with:

npx prisma generate

What It Does:

  1. Reads Your Prisma Schema: The command looks at your schema.prisma file.
  2. Generates Prisma Client: Based on the schema, it generates the Prisma Client code.
  3. Type-Safety and Autocompletion: The generated client is fully typed based on your schema.

Running the Project

Start the development server:

pnpm dev

Or using npm:

npm run dev

Or using Yarn:

yarn dev

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