Skip to main content

Prerequisites

Before you begin, ensure you have the following installed:

Node.js

Version 18 or higher required
node --version

pnpm

Recommended package manager
npm install -g pnpm

Git

Version control system
git --version

Code Editor

VS Code recommended with TypeScript support

Installation Steps

1

Clone the Repository

Clone the repository to your local machine:
git clone <repository-url>
cd your-bible
Or if you’ve forked it:
git clone https://github.com/YOUR_USERNAME/your-bible.git
cd your-bible
2

Install Dependencies

Install all project dependencies using pnpm:
pnpm install
First installation may take a few minutes as it downloads all packages and dependencies.
Alternative package managers:
npm install
3

Environment Configuration

Copy the example environment file:
cp .env.example .env
Now you’ll need to configure each environment variable. See the detailed Environment Variables guide for complete information.

Service Configuration

1. API.Bible Setup

1

Get API Key

  1. Visit API.Bible
  2. Sign up for a free account
  3. Navigate to “API Keys” section
  4. Create a new API key
2

Configure Environment

Add to your .env file:
API_BASE_URL=https://api.scripture.api.bible/v1
API_KEY=your_api_bible_key_here

2. Convex Backend Setup

Convex provides real-time database and backend functionality for collections, notes, and stories.
1

Create Convex Account

  1. Visit Convex.dev
  2. Sign up with GitHub or email
  3. Create a new project
2

Install Convex CLI

pnpm add -g convex
3

Initialize Convex

Run the Convex development server:
npx convex dev
This will:
  • Log you in (if first time)
  • Create/link a project
  • Deploy your schema
  • Generate environment variables
4

Configure Environment

Convex will automatically add these to your .env:
CONVEX_DEPLOYMENT=your_deployment_name
VITE_CONVEX_URL=https://your-project.convex.cloud

3. PostgreSQL Database Setup

4. Better Auth Configuration

1

Generate Auth Secret

Generate a secure random string for your auth secret:
openssl rand -base64 32
2

Configure Environment

BETTER_AUTH_SECRET=your_generated_secret_here
BETTER_AUTH_URL=http://localhost:5173
3

Optional: GitHub OAuth

If you want to enable GitHub authentication:
  1. Go to GitHub Settings > Developer settings > OAuth Apps
  2. Create a new OAuth App
  3. Set authorization callback URL: http://localhost:5173/api/auth/callback/github
  4. Add to .env:
GITHUB_CLIENT_ID=your_github_client_id
GITHUB_CLIENT_SECRET=your_github_client_secret

5. Google Gemini AI Setup

1

Get Gemini API Key

  1. Visit Google AI Studio
  2. Sign in with your Google account
  3. Click “Get API Key”
  4. Create a new API key
2

Configure Environment

GEMINI_MODEL=gemini-1.5-flash
GEMINI_API_KEY=your_gemini_api_key_here
gemini-1.5-flash is recommended for its balance of speed and quality. You can also use gemini-1.5-pro for better quality at higher cost.

6. Redis/Upstash Setup

Redis is used for rate limiting story generation to manage API costs (5 stories per day per user).
1

Create Upstash Account

  1. Visit Upstash
  2. Sign up for a free account
  3. Create a new Redis database
2

Get Connection Details

From your Upstash dashboard:
  1. Click on your database
  2. Go to “REST API” section
  3. Copy the connection details
3

Configure Environment

REDIS_URL=your_redis_url_here
KV_URL=your_kv_url_here
KV_REST_API_URL=your_kv_rest_api_url_here
KV_REST_API_TOKEN=your_kv_rest_api_token_here
KV_REST_API_READ_ONLY_TOKEN=your_kv_rest_api_read_only_token_here

7. Optional: UploadThing (Future Feature)

If you plan to implement file upload features:
  1. Visit UploadThing
  2. Create an account and project
  3. Get your token from the dashboard
  4. Add to .env:
UPLOADTHING_TOKEN=your_uploadthing_token_here

Running the Development Server

1

Start Convex

In one terminal, run Convex in development mode:
npx convex dev
Keep this terminal running. It will:
  • Watch for schema changes
  • Hot reload functions
  • Provide real-time sync
2

Start Development Server

In another terminal, start the Vite development server:
pnpm dev
The application will be available at:
http://localhost:5173
The development server includes:
  • Hot Module Replacement (HMR)
  • Fast refresh for React components
  • TypeScript checking
  • Automatic route generation

Verification Steps

Open http://localhost:5173 and verify:
  • Page loads without errors
  • No console errors in browser DevTools
  • Navigation works
  • Select a Bible translation from dropdown
  • Navigate to Genesis chapter 1
  • Verify verses load correctly
  • Click “Sign In”
  • Create a new account with email
  • Verify successful sign-in
  • Check that protected routes are now accessible
  • Create a new collection
  • Add a verse to the collection
  • Verify data persists after page refresh
  • Navigate to Stories section
  • Create a new story
  • Fill in all required fields
  • Generate a story
  • Verify story appears correctly

Common Issues and Troubleshooting

If port 5173 is already in use:
# Find and kill the process using port 5173
lsof -ti:5173 | xargs kill -9

# Or specify a different port
pnpm dev --port 3000
If Convex fails to connect:
  1. Verify VITE_CONVEX_URL is set correctly
  2. Check Convex dashboard for deployment status
  3. Try restarting npx convex dev
  4. Clear browser cache and reload
If Bible content fails to load:
  1. Verify API_KEY is valid
  2. Check API key hasn’t expired
  3. Verify API_BASE_URL is correct: https://api.scripture.api.bible/v1
  4. Check browser console for specific error messages
  5. Verify API key has necessary permissions
If you see database connection errors:
# Verify PostgreSQL is running
pg_isready

# Check connection string format
echo $DATABASE_URL

# Test connection with psql
psql $DATABASE_URL

# Retry migrations
pnpm drizzle-kit push
If sign-in/sign-up fails:
  1. Verify BETTER_AUTH_SECRET is set
  2. Check BETTER_AUTH_URL matches your dev server URL
  3. Verify database migrations ran successfully
  4. Clear cookies and try again
  5. Check browser console for errors
If AI story generation fails:
  1. Verify GEMINI_API_KEY is valid
  2. Check API key has necessary permissions
  3. Verify Redis is connected (for rate limiting)
  4. Check browser console and server logs
  5. Ensure you haven’t exceeded rate limit (5 stories/day)
If rate limiting isn’t working:
  1. Verify all Redis environment variables are set
  2. Test Redis connection in Upstash dashboard
  3. Check KV_REST_API_TOKEN is valid
  4. Restart development server
If you see TypeScript errors:
# Restart TypeScript server in VS Code
# Command Palette: TypeScript: Restart TS Server

# Clear TypeScript cache
rm -rf node_modules/.vite

# Reinstall dependencies
rm -rf node_modules pnpm-lock.yaml
pnpm install
If you see “Cannot find module” errors:
  1. Verify all dependencies are installed: pnpm install
  2. Check tsconfig.json paths are configured
  3. Restart development server
  4. Clear Vite cache: rm -rf node_modules/.vite

Development Tools

  • ES7+ React/Redux/React-Native snippets: React snippets
  • Tailwind CSS IntelliSense: Tailwind autocompletion
  • TypeScript: Built-in, ensure it’s enabled
  • ESLint: Code linting
  • Prettier: Code formatting
  • Error Lens: Inline error display

Browser DevTools

  • React Developer Tools: Inspect React component tree
  • TanStack Query Devtools: Built into the app (bottom left corner in dev mode)
  • Network Tab: Monitor API requests
  • Console: Check for errors and warnings

Build and Production Testing

Building for Production

pnpm build
This creates an optimized production build in the dist directory.

Testing Production Build Locally

# Build the application
pnpm build

# Preview the production build
pnpm preview
The production preview will be available at http://localhost:4173

Production Checklist

  • All tests pass
  • No console errors or warnings
  • Build completes without errors
  • Environment variables are properly configured for production
  • API keys are valid and have proper rate limits
  • Database migrations are up to date
  • Authentication works correctly
  • All features tested on production build
  • Mobile responsiveness verified
  • Performance is acceptable (check Lighthouse scores)

Next Steps

Now that your local environment is set up:
  1. Read the Project Structure guide to understand the codebase
  2. Review the Database Schema documentation
  3. Explore the Integrations to understand external services
  4. Check the Contributing Guide before making changes

Ready to Contribute?

Learn how to contribute code, documentation, and improvements to Your Bible.