Self-Deployment Guide

Deploy PDR AI on your own infrastructure with complete control and customization

Prerequisites

Node.js & Package Manager

  • Node.js v18.0 or higher
  • pnpm (recommended) or npm
  • Git for version control

Database

  • Docker (for local PostgreSQL)
  • Or existing PostgreSQL instance
  • PostgreSQL 14+ recommended

API Keys Required

  • OpenAI API key
  • Clerk authentication
  • UploadThing for file storage

Quick Start

1. Clone the Repository

git clone https://github.com/Deodat-Lawson/pdr_ai_v2.git
cd pdr_ai_v2

2. Install Dependencies

pnpm install

3. Configure Environment Variables

Create a .env file in the root directory:

# Database
DATABASE_URL="postgresql://postgres:password@localhost:5432/pdr_ai_v2"

# Clerk Authentication
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=your_clerk_publishable_key
CLERK_SECRET_KEY=your_clerk_secret_key

# OpenAI API
OPENAI_API_KEY=your_openai_api_key

# UploadThing
UPLOADTHING_SECRET=your_uploadthing_secret
UPLOADTHING_APP_ID=your_uploadthing_app_id

# Environment
NODE_ENV=development

4. Set Up Database

# Start PostgreSQL with Docker
chmod +x start-database.sh
./start-database.sh

# Run migrations
pnpm db:push

5. Start Development Server

pnpm dev

Your application will be available at http://localhost:3000

Setting Up API Keys

Clerk Authentication

  1. Create an account at Clerk.com
  2. Create a new application
  3. Copy the publishable and secret keys
  4. Add them to your .env file
  5. Configure sign-in/sign-up methods as needed

OpenAI API

  1. Create an account at OpenAI Platform
  2. Navigate to API keys section
  3. Generate a new API key
  4. Add the key to your .env file
  5. Set up billing for API usage

UploadThing

  1. Create an account at UploadThing.com
  2. Create a new app
  3. Copy the secret and app ID
  4. Add them to your .env file

Production Deployment

Vercel (Recommended)

  1. Push your code to GitHub
  2. Import your repository on Vercel
  3. Configure environment variables in Vercel dashboard
  4. Deploy automatically on every push
# Build command
pnpm build

# Start command
pnpm start

Docker Deployment

# Build Docker image
docker build -t pdr-ai .

# Run container
docker run -p 3000:3000 --env-file .env pdr-ai

Self-Hosted VPS

  1. Set up a VPS with Node.js and PostgreSQL
  2. Clone the repository
  3. Configure environment variables
  4. Build the application: pnpm build
  5. Use PM2 or similar for process management
  6. Configure nginx as reverse proxy
  7. Set up SSL with Let's Encrypt

Database Management

Useful Database Commands

# 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:push

Troubleshooting

Database Connection Issues

  • Ensure Docker is running: docker ps
  • Check database container status: docker restart pdr_ai_v2-postgres
  • Verify DATABASE_URL in .env file

Build Errors

  • Clear Next.js cache: rm -rf .next
  • Reinstall dependencies: rm -rf node_modules && pnpm install
  • Check TypeScript errors: pnpm typecheck

API Key Issues

  • Verify all required environment variables are set
  • Check for spaces around = in .env file
  • Ensure API keys are valid and have proper permissions
  • Restart the development server after changing .env

What You Get

Full Source Code

Complete access to all application code with no restrictions

Predictive Document Analysis

AI-powered missing document detection and recommendations

AI Chat Engine

Interactive Q&A system for document analysis

Employee Management

Complete employee and employer authentication system

Document Management

Upload, categorize, and manage documents

Analytics Dashboard

Insights and statistics for document usage

Need Help?

Having trouble with deployment? Our support team is here to help!