Prerequisites
Before you begin, ensure you have the following installed on your development machine:Node.js (LTS recommended)
Node.js (LTS recommended)
Git
Git
Code Editor
Code Editor
Recommended: Visual Studio Code or Cursor with the following extensions:
- ESLint
- Prettier
- Tailwind CSS IntelliSense
- TypeScript and JavaScript Language Features
Installation
1. Clone the Repository
2. Install Dependencies
This project uses npm and has apackage-lock.json file for consistent dependency versions.
3. Environment Configuration
Create a.env file in the project root with the following variables:
Environment Variables Explained
Environment Variables Explained
| Variable | Purpose | Required |
|---|---|---|
DATABASE_URL | Neon PostgreSQL connection string | ✅ Yes |
NEXT_PUBLIC_APP_URL | Public site URL (used by auth client) | ✅ Yes |
BETTER_AUTH_URL | Auth origin fallback | ⚠️ Optional |
SITE_URL | For health checks and cache tooling | ⚠️ Optional |
ALLOWED_ORIGIN | Production browser origin for API CORS | ✅ Yes (Production) |
RESEND_API_KEY | Resend API key for sending emails | ✅ Yes |
RESEND_FROM | Default “from” email address | ⚠️ Optional |
BETTER_AUTH_SECRET | Secret for Better Auth (min 32 chars) | ✅ Yes |
CRON_SECRET | Bearer token for cron endpoints | ✅ Yes (Production) |
REVALIDATION_SECRET | Bearer token for cache-clear APIs | ⚠️ Optional |
4. Database Setup
Generate and Apply Migrations
The repository includes pre-generated migrations in thedrizzle/ directory. Apply them to your database:
Alternative: Push Schema Directly (Development Only)
For rapid local iteration, you can push the schema directly without migrations:Generate New Migrations (After Schema Changes)
If you modifydb/schema.ts or db/auth-schema.ts:
Development Server
Start the development server:Default Routes
- Login:
/login - Dashboard:
/home - Forgot Password:
/forgot-password - Reset Password:
/reset-password
The dashboard (
/home/*) uses client-side protection via ProtectedRoute component and authenticated API routes.Project Structure Overview
Available Scripts
| Command | Description |
|---|---|
npm run dev | Start development server |
npm run build | Build for production |
npm run start | Start production server |
npm run lint | Run ESLint |
npm test | Run Jest tests |
npm run test:watch | Run tests in watch mode |
Verifying Your Setup
1. Check Database Connection
The application should connect to your Neon database on startup. Check the terminal for any connection errors.2. Access the Login Page
Navigate tohttp://localhost:3000/login and ensure the page loads correctly.
3. Run Tests
Next Steps
Architecture
Understand the system design
Database schema
Learn about the data models
Authentication
Explore auth implementation
REST API reference
Review available endpoints
Dashboard overview
Understand the app areas under
/home/*Testing
Verify setup, auth, and API behavior
Troubleshooting
Database Connection Errors
Database Connection Errors
- Verify your
DATABASE_URLis correct - Ensure your Neon database is active and accessible
- Check that SSL mode is properly configured in the connection string
- Confirm firewall settings allow database connections
Module Not Found Errors
Module Not Found Errors
- Delete
node_modules/andpackage-lock.json - Run
npm installagain - Ensure you’re using a compatible Node.js version (LTS recommended)
Port already in use
Port already in use
If port 3000 is already in use:
Better Auth Errors
Better Auth Errors
- Ensure
BETTER_AUTH_SECRETis at least 32 characters - Verify
NEXT_PUBLIC_APP_URLmatches your actual URL - Check that auth tables were created in the database
If something still fails, check the terminal and browser Network tab for the exact status code and response body. That message usually points to the root cause (missing env, bad URL, or schema mismatch).
