Setup

Installation

Complete guide to setting up LearnHub on your local machine.

Prerequisites

Make sure you have the following installed on your machine.

Node.js 18+JavaScript runtime
Required
npm or yarnPackage manager
Required
PostgreSQLDatabase (or use Neon)
Required
GitVersion control
Required

Local Setup

1. Clone the Repository

git clone https://github.com/alfredang/ai-lms.git
cd ai-lms

2. Install Dependencies

npm install

This installs all required packages including Next.js, Prisma, NextAuth, and UI components.

3. Configure Environment

cp .env.example .env

Copy the example environment file and update it with your credentials.

4. Set Up Database

# Push schema to database
npm run db:push

# Seed with demo data
npm run db:seed

This creates all database tables and populates them with sample data.

5. Start Development Server

npm run dev

Open http://localhost:3000 to view the application.

Environment Variables

Configure these variables in your .env file.

VariableDescriptionRequired
DATABASE_URLPostgreSQL connection string
Yes
AUTH_SECRETNextAuth secret (32+ chars)
Yes
AUTH_URLApp URL (http://localhost:3000)
Yes
AUTH_GOOGLE_IDGoogle OAuth client ID
Optional
AUTH_GOOGLE_SECRETGoogle OAuth secret
Optional
AUTH_GITHUB_IDGitHub OAuth client ID
Optional
AUTH_GITHUB_SECRETGitHub OAuth secret
Optional
OPENAI_API_KEYOpenAI API key for AI features
Optional

Security Note

Never commit your .env file. It's already in .gitignore.

Available Scripts

CommandDescription
npm run devStart development server
npm run buildBuild for production
npm run startStart production server
npm run db:pushPush schema to database
npm run db:seedSeed database with demo data
npm run db:studioOpen Prisma Studio GUI