Prerequisites
Before you begin, ensure you have the following installed:Node.js
Version 18 or higher required
pnpm
Recommended package manager
Git
Version control system
Code Editor
VS Code recommended with TypeScript support
Installation Steps
Install Dependencies
Install all project dependencies using pnpm:Alternative package managers:
First installation may take a few minutes as it downloads all packages and dependencies.
Environment Configuration
Copy the example environment file:Now you’ll need to configure each environment variable. See the detailed Environment Variables guide for complete information.
Service Configuration
1. API.Bible Setup
Get API Key
- Visit API.Bible
- Sign up for a free account
- Navigate to “API Keys” section
- Create a new API key
2. Convex Backend Setup
Convex provides real-time database and backend functionality for collections, notes, and stories.
Create Convex Account
- Visit Convex.dev
- Sign up with GitHub or email
- Create a new project
Initialize Convex
Run the Convex development server:This will:
- Log you in (if first time)
- Create/link a project
- Deploy your schema
- Generate environment variables
3. PostgreSQL Database Setup
- Using Neon (Recommended)
- Using Local PostgreSQL
Create Neon Account
- Visit Neon.tech
- Sign up for a free account
- Create a new project
Get Connection String
- Go to your project dashboard
- Copy the connection string
- It should look like:
postgresql://user:password@host/database
4. Better Auth Configuration
5. Google Gemini AI Setup
Get Gemini API Key
- Visit Google AI Studio
- Sign in with your Google account
- Click “Get API Key”
- Create a new API key
6. Redis/Upstash Setup
Redis is used for rate limiting story generation to manage API costs (5 stories per day per user).
Create Upstash Account
- Visit Upstash
- Sign up for a free account
- Create a new Redis database
Get Connection Details
From your Upstash dashboard:
- Click on your database
- Go to “REST API” section
- Copy the connection details
7. Optional: UploadThing (Future Feature)
UploadThing Configuration
UploadThing Configuration
If you plan to implement file upload features:
- Visit UploadThing
- Create an account and project
- Get your token from the dashboard
- Add to
.env:
Running the Development Server
Start Convex
In one terminal, run Convex in development mode:Keep this terminal running. It will:
- Watch for schema changes
- Hot reload functions
- Provide real-time sync
The development server includes:
- Hot Module Replacement (HMR)
- Fast refresh for React components
- TypeScript checking
- Automatic route generation
Verification Steps
1. Check Application Loads
1. Check Application Loads
Open http://localhost:5173 and verify:
- Page loads without errors
- No console errors in browser DevTools
- Navigation works
2. Test API.Bible Connection
2. Test API.Bible Connection
- Select a Bible translation from dropdown
- Navigate to Genesis chapter 1
- Verify verses load correctly
3. Test Authentication
3. Test Authentication
- Click “Sign In”
- Create a new account with email
- Verify successful sign-in
- Check that protected routes are now accessible
4. Test Convex Integration
4. Test Convex Integration
- Create a new collection
- Add a verse to the collection
- Verify data persists after page refresh
5. Test AI Story Generation
5. Test AI Story Generation
- Navigate to Stories section
- Create a new story
- Fill in all required fields
- Generate a story
- Verify story appears correctly
Common Issues and Troubleshooting
Port Already in Use
Port Already in Use
If port 5173 is already in use:
Convex Connection Issues
Convex Connection Issues
If Convex fails to connect:
- Verify
VITE_CONVEX_URLis set correctly - Check Convex dashboard for deployment status
- Try restarting
npx convex dev - Clear browser cache and reload
API.Bible Not Loading
API.Bible Not Loading
If Bible content fails to load:
- Verify
API_KEYis valid - Check API key hasn’t expired
- Verify
API_BASE_URLis correct:https://api.scripture.api.bible/v1 - Check browser console for specific error messages
- Verify API key has necessary permissions
Database Connection Errors
Database Connection Errors
If you see database connection errors:
Authentication Not Working
Authentication Not Working
If sign-in/sign-up fails:
- Verify
BETTER_AUTH_SECRETis set - Check
BETTER_AUTH_URLmatches your dev server URL - Verify database migrations ran successfully
- Clear cookies and try again
- Check browser console for errors
Story Generation Failing
Story Generation Failing
If AI story generation fails:
- Verify
GEMINI_API_KEYis valid - Check API key has necessary permissions
- Verify Redis is connected (for rate limiting)
- Check browser console and server logs
- Ensure you haven’t exceeded rate limit (5 stories/day)
Rate Limiting Issues
Rate Limiting Issues
If rate limiting isn’t working:
- Verify all Redis environment variables are set
- Test Redis connection in Upstash dashboard
- Check
KV_REST_API_TOKENis valid - Restart development server
TypeScript Errors
TypeScript Errors
If you see TypeScript errors:
Module Not Found Errors
Module Not Found Errors
If you see “Cannot find module” errors:
- Verify all dependencies are installed:
pnpm install - Check
tsconfig.jsonpaths are configured - Restart development server
- Clear Vite cache:
rm -rf node_modules/.vite
Development Tools
Recommended VS Code Extensions
- 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
dist directory.
Testing Production Build Locally
Production Checklist
Before Deploying
Before Deploying
- 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:- Read the Project Structure guide to understand the codebase
- Review the Database Schema documentation
- Explore the Integrations to understand external services
- Check the Contributing Guide before making changes
Ready to Contribute?
Learn how to contribute code, documentation, and improvements to Your Bible.