Initial commit - QR Master application

This commit is contained in:
Timo Knuth
2025-10-13 20:19:18 +02:00
commit 5262f9e78f
96 changed files with 18902 additions and 0 deletions

137
scripts/setup.ps1 Normal file
View File

@@ -0,0 +1,137 @@
# QR Master - Quick Setup Script (PowerShell for Windows)
# This script automates the initial setup process
Write-Host "🚀 QR Master - Quick Setup" -ForegroundColor Cyan
Write-Host "================================" -ForegroundColor Cyan
Write-Host ""
# Check if Docker is installed
try {
docker --version | Out-Null
Write-Host "✓ Docker is installed" -ForegroundColor Green
} catch {
Write-Host "❌ Docker is not installed. Please install Docker Desktop first." -ForegroundColor Red
exit 1
}
# Check if Docker Compose is installed
try {
docker-compose --version | Out-Null
Write-Host "✓ Docker Compose is installed" -ForegroundColor Green
} catch {
Write-Host "❌ Docker Compose is not installed. Please install Docker Desktop first." -ForegroundColor Red
exit 1
}
Write-Host ""
# Check if .env exists
if (-Not (Test-Path .env)) {
Write-Host "📝 Creating .env file from template..." -ForegroundColor Yellow
Copy-Item env.example .env
# Generate secrets
$NEXTAUTH_SECRET = [Convert]::ToBase64String((1..32 | ForEach-Object { Get-Random -Maximum 256 }))
$IP_SALT = [Convert]::ToBase64String((1..32 | ForEach-Object { Get-Random -Maximum 256 }))
# Update .env with generated secrets
(Get-Content .env) -replace 'NEXTAUTH_SECRET=.*', "NEXTAUTH_SECRET=$NEXTAUTH_SECRET" | Set-Content .env
(Get-Content .env) -replace 'IP_SALT=.*', "IP_SALT=$IP_SALT" | Set-Content .env
Write-Host "✓ Generated secure secrets" -ForegroundColor Green
} else {
Write-Host "✓ .env file already exists" -ForegroundColor Green
}
Write-Host ""
# Ask user what mode they want
Write-Host "Choose setup mode:"
Write-Host "1) Development (database only in Docker, app on host)"
Write-Host "2) Production (full stack in Docker)"
$choice = Read-Host "Enter choice [1-2]"
Write-Host ""
switch ($choice) {
"1" {
Write-Host "🔧 Setting up development environment..." -ForegroundColor Cyan
Write-Host ""
# Start database services
Write-Host "Starting PostgreSQL and Redis..."
docker-compose -f docker-compose.dev.yml up -d
# Wait for database to be ready
Write-Host "Waiting for database to be ready..."
Start-Sleep -Seconds 5
# Install dependencies
Write-Host "Installing dependencies..."
npm install
# Run migrations
Write-Host "Running database migrations..."
npm run db:migrate
# Seed database
Write-Host "Seeding database with demo data..."
npm run db:seed
Write-Host ""
Write-Host "✅ Development environment ready!" -ForegroundColor Green
Write-Host ""
Write-Host "To start the application:"
Write-Host " npm run dev"
Write-Host ""
Write-Host "Access points:"
Write-Host " - App: http://localhost:3050"
Write-Host " - Database UI: http://localhost:8080"
Write-Host " - Database: localhost:5432"
Write-Host " - Redis: localhost:6379"
}
"2" {
Write-Host "🚀 Setting up production environment..." -ForegroundColor Cyan
Write-Host ""
# Build and start all services
Write-Host "Building and starting all services..."
docker-compose up -d --build
# Wait for services to be ready
Write-Host "Waiting for services to be ready..."
Start-Sleep -Seconds 10
# Run migrations
Write-Host "Running database migrations..."
docker-compose exec web npx prisma migrate deploy
# Seed database
Write-Host "Seeding database with demo data..."
docker-compose exec web npm run db:seed
Write-Host ""
Write-Host "✅ Production environment ready!" -ForegroundColor Green
Write-Host ""
Write-Host "Access points:"
Write-Host " - App: http://localhost:3050"
Write-Host " - Database: localhost:5432"
Write-Host " - Redis: localhost:6379"
Write-Host ""
Write-Host "To view logs:"
Write-Host " docker-compose logs -f"
}
default {
Write-Host "❌ Invalid choice. Exiting." -ForegroundColor Red
exit 1
}
}
Write-Host ""
Write-Host "📚 Documentation:"
Write-Host " - Quick start: README.md"
Write-Host " - Docker guide: DOCKER_SETUP.md"
Write-Host " - Migration guide: MIGRATION_FROM_SUPABASE.md"
Write-Host ""
Write-Host "🎉 Setup complete! Happy coding!" -ForegroundColor Green

148
scripts/setup.sh Normal file
View File

@@ -0,0 +1,148 @@
#!/bin/bash
# QR Master - Quick Setup Script
# This script automates the initial setup process
set -e
echo "🚀 QR Master - Quick Setup"
echo "================================"
echo ""
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
# Check if Docker is installed
if ! command -v docker &> /dev/null; then
echo -e "${RED}❌ Docker is not installed. Please install Docker first.${NC}"
exit 1
fi
# Check if Docker Compose is installed
if ! command -v docker-compose &> /dev/null; then
echo -e "${RED}❌ Docker Compose is not installed. Please install Docker Compose first.${NC}"
exit 1
fi
echo -e "${GREEN}${NC} Docker is installed"
echo -e "${GREEN}${NC} Docker Compose is installed"
echo ""
# Check if .env exists
if [ ! -f .env ]; then
echo "📝 Creating .env file from template..."
cp env.example .env
# Generate secrets
if command -v openssl &> /dev/null; then
NEXTAUTH_SECRET=$(openssl rand -base64 32)
IP_SALT=$(openssl rand -base64 32)
# Update .env with generated secrets
sed -i.bak "s|NEXTAUTH_SECRET=.*|NEXTAUTH_SECRET=$NEXTAUTH_SECRET|" .env
sed -i.bak "s|IP_SALT=.*|IP_SALT=$IP_SALT|" .env
rm .env.bak 2>/dev/null || true
echo -e "${GREEN}${NC} Generated secure secrets"
else
echo -e "${YELLOW}${NC} OpenSSL not found. Please manually update NEXTAUTH_SECRET and IP_SALT in .env"
fi
else
echo -e "${GREEN}${NC} .env file already exists"
fi
echo ""
# Ask user what mode they want
echo "Choose setup mode:"
echo "1) Development (database only in Docker, app on host)"
echo "2) Production (full stack in Docker)"
read -p "Enter choice [1-2]: " choice
echo ""
case $choice in
1)
echo "🔧 Setting up development environment..."
echo ""
# Start database services
echo "Starting PostgreSQL and Redis..."
docker-compose -f docker-compose.dev.yml up -d
# Wait for database to be ready
echo "Waiting for database to be ready..."
sleep 5
# Install dependencies
echo "Installing dependencies..."
npm install
# Run migrations
echo "Running database migrations..."
npm run db:migrate
# Seed database
echo "Seeding database with demo data..."
npm run db:seed
echo ""
echo -e "${GREEN}✅ Development environment ready!${NC}"
echo ""
echo "To start the application:"
echo " npm run dev"
echo ""
echo "Access points:"
echo " - App: http://localhost:3050"
echo " - Database UI: http://localhost:8080"
echo " - Database: localhost:5432"
echo " - Redis: localhost:6379"
;;
2)
echo "🚀 Setting up production environment..."
echo ""
# Build and start all services
echo "Building and starting all services..."
docker-compose up -d --build
# Wait for services to be ready
echo "Waiting for services to be ready..."
sleep 10
# Run migrations
echo "Running database migrations..."
docker-compose exec web npx prisma migrate deploy
# Seed database
echo "Seeding database with demo data..."
docker-compose exec web npm run db:seed
echo ""
echo -e "${GREEN}✅ Production environment ready!${NC}"
echo ""
echo "Access points:"
echo " - App: http://localhost:3050"
echo " - Database: localhost:5432"
echo " - Redis: localhost:6379"
echo ""
echo "To view logs:"
echo " docker-compose logs -f"
;;
*)
echo -e "${RED}Invalid choice. Exiting.${NC}"
exit 1
;;
esac
echo ""
echo "📚 Documentation:"
echo " - Quick start: README.md"
echo " - Docker guide: DOCKER_SETUP.md"
echo " - Migration guide: MIGRATION_FROM_SUPABASE.md"
echo ""
echo "🎉 Setup complete! Happy coding!"