First Steps
Configure environment variables and run your project for the first time
First Steps
Let's get your build-elevate project running. This guide will walk you through configuration and your first successful run.
Overview
Before starting the development servers, you need to:
- Configure environment variables for all apps
- Set up the PostgreSQL database
- Run database migrations
- Start the development servers
This process takes about 5-10 minutes the first time. After that, starting
your project is just one command: pnpm dev
Step 1: Configure Environment Variables
build-elevate uses environment variables to configure database connections, authentication secrets, and API keys. You need to set up three .env files.
For detailed explanations of all environment variables, see the Environment Variables Guide.
Database Configuration
Navigate to the database package:
cd packages/dbCreate the environment file:
cp .env.example .envEdit packages/db/.env with your database connection string:
DATABASE_URL="postgresql://[username]:[password]@[host]:[port]/[database]?schema=public"See the Environment Variables Guide for detailed DATABASE_URL format and setup instructions.
Important
Replace [username], [password], [host], [port], and [database] with
your actual PostgreSQL credentials.
Backend API Configuration
Navigate to the API directory:
cd ../../apps/apiCreate the environment file:
cp .env.example .env.localEdit apps/api/.env.local. You'll need to set:
DATABASE_URL(same as packages/db/.env)BETTER_AUTH_SECRET- See Environment Variables Guide for generation instructionsBETTER_AUTH_URL=http://localhost:4000ALLOWED_ORIGINS=http://localhost:3000- Other optional variables for email and rate limiting (see Environment Variables Guide for details)
Quick Start
For local development, set the required variables shown above. Additional configuration is optional.
Frontend Web Configuration
Navigate to the web app:
cd ../webCreate the environment file:
cp .env.example .env.localEdit apps/web/.env.local. You'll need to set:
DATABASE_URL(same as packages/db/.env)BETTER_AUTH_SECRET- Must be identical toapps/api/.env.local(see Environment Variables Guide)BETTER_AUTH_URL=http://localhost:3000GOOGLE_CLIENT_IDandGOOGLE_CLIENT_SECRET(OAuth credentials)- Other optional variables for email and rate limiting (see Environment Variables Guide for details)
For complete setup instructions and all available variables, see the Environment Variables Guide.
Step 2: Set Up the Database
Now that environment variables are configured, let's set up the database.
Create the Database
We recommend Supabase for a managed PostgreSQL database. Set up a free project and get the connection string.
If you're using Docker, the database will be created automatically on first run.
Run Migrations
Navigate back to the root directory and run migrations:
cd ../.. # Back to project root
# Run Prisma migrations
npm run db:migrateThis command will:
- Apply all database migrations
- Generate Prisma Client
- Create all necessary tables
You should see output like:
✔ Generated Prisma Client
✔ Applied 1 migration(s)Your database is now ready! Tables for users, sessions, accounts, and more have been created.
Step 3: Start Development Servers
Now for the exciting part - let's start your project!
Start All Applications
From the root directory, run:
pnpm devThis single command starts:
- Web App (Next.js) on
http://localhost:3000 - API Server (Express) on
http://localhost:4000 - Email Preview (React Email) on
http://localhost:3002 - Prisma Studio (Database UI) on
http://localhost:5555
First Startup
The first startup might take 30-60 seconds as Next.js compiles pages and Turbopack builds the app. Subsequent starts will be much faster!
Verify Everything Works
Open your browser and check each application. For the complete list of URLs and ports, see Application Ports.
Quick checks:
- Frontend: http://localhost:3000 - You should see the homepage
- API Health: http://localhost:4000/health - Should return:
{"status":"ok","timestamp":"..."} - Email Preview: http://localhost:3002 - View all email templates
- Prisma Studio: http://localhost:5555 - Browse your database tables
Step 4: Test Authentication
Let's test the authentication system:
-
Navigate to the sign-up page:
http://localhost:3000/sign-up -
Create an account:
- Enter your email
- Choose a password (min 8 characters)
- Click "Sign Up"
-
Check your email:
- An email will be sent to the address you provided
- Click the verification link in the email
-
Sign in: You'll be redirected to the dashboard
-
Check the database: Open Prisma Studio to see your user
🎉 Congratulations! Your new project is fully set up and running.
Development Workflow
Now that everything is running, here are the essential commands you'll use daily:
Common Commands
npm run devIndividual Applications
If you want to run apps individually:
# Web app only
pnpm dev --filter=web
# API only
pnpm dev --filter=api
# Email preview only
pnpm dev --filter=email
# Multiple specific apps
pnpm dev --filter=web --filter=apiCustom Ports
By default, applications run on specific ports (see Application Ports). To run an application on a different port:
# Web app on custom port
PORT=3010 pnpm dev --filter=web
# API on custom port
PORT=4010 pnpm dev --filter=apiThis is useful when a default port is already in use. See Troubleshooting: Port Already in Use for more solutions.