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-lms2. Install Dependencies
npm installThis installs all required packages including Next.js, Prisma, NextAuth, and UI components.
3. Configure Environment
cp .env.example .envCopy 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:seedThis creates all database tables and populates them with sample data.
5. Start Development Server
npm run devOpen http://localhost:3000 to view the application.
Environment Variables
Configure these variables in your .env file.
| Variable | Description | Required |
|---|---|---|
| DATABASE_URL | PostgreSQL connection string | Yes |
| AUTH_SECRET | NextAuth secret (32+ chars) | Yes |
| AUTH_URL | App URL (http://localhost:3000) | Yes |
| AUTH_GOOGLE_ID | Google OAuth client ID | Optional |
| AUTH_GOOGLE_SECRET | Google OAuth secret | Optional |
| AUTH_GITHUB_ID | GitHub OAuth client ID | Optional |
| AUTH_GITHUB_SECRET | GitHub OAuth secret | Optional |
| OPENAI_API_KEY | OpenAI API key for AI features | Optional |
Security Note
Never commit your .env file. It's already in .gitignore.
Available Scripts
| Command | Description |
|---|---|
| npm run dev | Start development server |
| npm run build | Build for production |
| npm run start | Start production server |
| npm run db:push | Push schema to database |
| npm run db:seed | Seed database with demo data |
| npm run db:studio | Open Prisma Studio GUI |