Prerequisites
Before you begin, ensure you have the following installed:- Node.js 18.x or higher
- npm 9.x or higher
- PostgreSQL 14+ (or access to a cloud PostgreSQL instance)
- Git for version control
Initial Setup
Install Dependencies
Install all project dependencies using npm:This will install dependencies for the entire monorepo, including:
- React 18 and Vite for the frontend
- Express.js for the backend
- Drizzle ORM for database operations
- TypeScript and all type definitions
Configure Environment Variables
Copy the example environment file and configure your local settings:
For local development, use
.env.local.example as your template. The .env.example file is for Replit deployments.Required Environment Variables
Edit your.env file with the following required variables:Optional Environment Variables
Set Up Local Database
Create a local PostgreSQL database for development:
Alternatively, you can use a cloud PostgreSQL instance like Neon or Supabase for development. Update the
DATABASE_URL accordingly.Run Database Migrations
Apply the database schema using Drizzle ORM:This command will:
- Create all required tables from
shared/schema.ts - Set up foreign key constraints and indexes
- Initialize the database for local development
Start Development Server
Start the development server with hot module reloading:The application will start on port 5000:
The Express server runs on port 5000 and serves the API. Vite runs on port 5173 for hot reloading. Vite proxies API requests to the Express server automatically.
Verify Setup
Open your browser and navigate to
http://localhost:5000. You should see the JOIP landing page.To verify the setup is working:- Authentication: Local development uses a simplified auth strategy (no Replit OIDC)
- Database: Check the server logs for successful database connection
- Storage: Verify Supabase storage buckets are accessible
Development Workflow
Running Type Checks
Run TypeScript type checking across the entire codebase:Building for Production
Create an optimized production build:- Generate logo assets via
scripts/generate-logos.mjs - Bundle the React client with Vite →
dist/public/ - Compile the Express server with esbuild →
dist/index.js
Starting Production Server
Run the production build locally:dist/public on port 5000.
Authentication in Development
Local development uses a simplified authentication strategy that differs from production:Local Auth Features
- No OIDC required: Simple email/password authentication
- Auto-registration: New users are created automatically
- Session persistence: Uses PostgreSQL session store
- User profiles: Full profile management available
Supabase Storage Setup
Creating Storage Buckets
The application requires two Supabase storage buckets:- user-media: For user-uploaded content (manual sessions, thumbnails)
- general: For community-shared content
Create Buckets in Supabase
In your Supabase dashboard:
- Navigate to Storage
- Click New bucket
- Create bucket named
user-media(Public) - Create bucket named
general(Public)
Common Setup Issues
Database Connection Errors
Issue:Error: connect ECONNREFUSED ::1:5432
Solution:
- Verify PostgreSQL is running:
pg_isready - Check
DATABASE_URLformat:postgresql://user:pass@host:port/db - Ensure database exists:
psql -l
Port Already in Use
Issue:Error: listen EADDRINUSE: address already in use :::5000
Solution:
Missing API Keys
Issue: AI caption generation fails Solution:- Verify
OPENROUTER_API_KEYorOPENAI_API_KEYis set - Test API key validity with a simple request
- Check server logs for detailed error messages
Supabase Storage Errors
Issue:STORAGE_UNREACHABLE when uploading media
Solution:
- Verify Supabase project is not paused
- Check
SUPABASE_URL,SUPABASE_ANON_KEY, andSUPABASE_SERVICE_KEY - Ensure buckets exist with correct permissions
- Run
GET /api/storage/statusfor diagnostics
Hot Reloading
Frontend (Client)
Vite provides instant hot module reloading for:- React components
- CSS/Tailwind changes
- TypeScript files
Backend (Server)
The server usestsx with watch mode:
- Automatic restart on file changes
- Preserves database connections
- Maintains session state
If hot reloading isn’t working, try restarting the dev server with
npm run dev.Next Steps
Once your local environment is set up:- Explore the Project Structure to understand the codebase organization
- Learn about Database Migrations for schema changes
- Review Testing Guidelines before contributing
Development Tools
Recommended VS Code Extensions
- ESLint: Code linting and formatting
- Prettier: Code formatting
- Tailwind CSS IntelliSense: Tailwind class autocompletion
- TypeScript Vue Plugin (Volar): Enhanced TypeScript support
- PostgreSQL: Database management