Deploy PDR AI on your own infrastructure with complete control and customization
git clone https://github.com/Deodat-Lawson/pdr_ai_v2.git
cd pdr_ai_v2pnpm installCreate a .env file in the root directory with all required variables:
# Database Configuration
# Format: postgresql://[user]:[password]@[host]:[port]/[database]
DATABASE_URL="postgresql://postgres:password@localhost:5432/pdr_ai_v2"
# Clerk Authentication (get from https://clerk.com/)
# Required for user authentication and authorization
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=your_clerk_publishable_key
CLERK_SECRET_KEY=your_clerk_secret_key
# Clerk Force Redirect URLs (Optional - for custom redirect after authentication)
# These URLs control where users are redirected after sign in/up/sign out
# If not set, Clerk will use default redirect behavior
NEXT_PUBLIC_CLERK_SIGN_IN_FORCE_REDIRECT_URL=https://your-domain.com/employer/home
NEXT_PUBLIC_CLERK_SIGN_UP_FORCE_REDIRECT_URL=https://your-domain.com/signup
NEXT_PUBLIC_CLERK_SIGN_OUT_FORCE_REDIRECT_URL=https://your-domain.com/
# OpenAI API (get from https://platform.openai.com/)
# Required for AI features: document analysis, embeddings, chat
OPENAI_API_KEY=your_openai_api_key
# LangChain (get from https://smith.langchain.com/)
# Optional: Required for LangSmith tracing and monitoring
# LangSmith provides observability and debugging for LangChain operations
LANGCHAIN_TRACING_V2=true
LANGCHAIN_API_KEY=your_langchain_api_key
# Tavily Search API (get from https://tavily.com/)
# Optional: Required for enhanced web search capabilities
# Used for finding related documents and external resources
TAVILY_API_KEY=your_tavily_api_key
# UploadThing (get from https://uploadthing.com/)
# Required for file uploads (PDF documents)
UPLOADTHING_SECRET=your_uploadthing_secret
UPLOADTHING_APP_ID=your_uploadthing_app_id
# Environment Configuration
# Options: development, test, production
NODE_ENV=development
# Optional: Skip environment validation (useful for Docker builds)
# SKIP_ENV_VALIDATION=false# Start PostgreSQL with Docker
chmod +x start-database.sh
./start-database.sh
# Run migrations
pnpm db:pushpnpm devYour application will be available at http://localhost:3000
.env fileNEXT_PUBLIC_CLERK_SIGN_IN_FORCE_REDIRECT_URL - Redirect after sign inNEXT_PUBLIC_CLERK_SIGN_UP_FORCE_REDIRECT_URL - Redirect after sign upNEXT_PUBLIC_CLERK_SIGN_OUT_FORCE_REDIRECT_URL - Redirect after sign out.env fileLANGCHAIN_TRACING_V2=true in your .env fileLANGCHAIN_API_KEY to your .env fileTAVILY_API_KEY to your .env file.env fileVercel is the recommended platform for Next.js applications with automatic deployments and scaling.
git push origin mainOption A: Using Vercel Postgres (Recommended)
DATABASE_URL environment variableCREATE EXTENSION IF NOT EXISTS vector;Option B: Using Neon Database (Recommended for pgvector support)
DATABASE_URL environment variable from NeonPOSTGRES_URL, POSTGRES_PRISMA_URL, etc.CREATE EXTENSION IF NOT EXISTS vector;Option C: Using External Database (Manual Setup)
DATABASE_URLNEXT_PUBLIC_CLERK_PUBLISHABLE_KEYCLERK_SECRET_KEYOPENAI_API_KEYUPLOADTHING_SECRETUPLOADTHING_APP_IDNODE_ENV=productionLANGCHAIN_TRACING_V2=true (optional, for LangSmith tracing)LANGCHAIN_API_KEY (optional, required if tracing enabled)TAVILY_API_KEY (optional, for enhanced web search)NEXT_PUBLIC_CLERK_SIGN_IN_FORCE_REDIRECT_URL (optional)NEXT_PUBLIC_CLERK_SIGN_UP_FORCE_REDIRECT_URL (optional)NEXT_PUBLIC_CLERK_SIGN_OUT_FORCE_REDIRECT_URL (optional)pnpm build.next (default)pnpm installCREATE EXTENSION IF NOT EXISTS vector;# Option 1: Using Vercel CLI locally
vercel env pull .env.local
pnpm db:migrate
# Option 2: Using direct connection
DATABASE_URL="your_production_db_url" pnpm db:migrateDeploy on your own VPS with full control over the infrastructure.
git clone <your-repo-url>
cd pdr_ai_v2-2
pnpm installnano .env # Add all production environment variablespnpm buildnpm install -g pm2
pm2 start pnpm --name "pdr-ai" -- start
pm2 save
pm2 startupserver {
listen 80;
server_name your-domain.com;
location / {
proxy_pass http://localhost:3000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
}
}sudo apt-get install certbot python3-certbot-nginx
sudo certbot --nginx -d your-domain.compnpm db:migrateImportant: Your production database must have the pgvector extension enabled:
CREATE EXTENSION IF NOT EXISTS vector;Recommended Database Providers:
# Open Drizzle Studio (Database GUI)
pnpm db:studio
# Generate new migrations
pnpm db:generate
# Apply migrations
pnpm db:migrate
# Push schema changes directly (dev)
pnpm db:pushdocker psdocker restart pdr_ai_v2-postgres.env filerm -rf .nextrm -rf node_modules && pnpm installpnpm typecheck= in .env file.envComplete access to all application code with no restrictions
AI-powered missing document detection and recommendations
Interactive Q&A system for document analysis
Complete employee and employer authentication system
Upload, categorize, and manage documents
Insights and statistics for document usage