A lightweight web application for managing Friday prayer registrations with multi-language support, QR code generation, and real-time capacity management.
- Multi-language Support: English, German, French, Arabic (with RTL support)
- Real-time Registration: Automatic registration windows from Saturday 00:00 to prayer time
- QR Code Generation: Offline-capable QR codes for attendance verification
- Admin Dashboard: Prayer management, capacity monitoring, CSV exports
- Device-based Registration: One registration per device per prayer
- Companion Management: Add up to 4 companions per registration
- Responsive Design: Works on desktop and mobile devices
- Frontend: Next.js 15, React, TypeScript
- Backend: Next.js API Routes, Server Actions
- Database: PostgreSQL with Prisma ORM
- Authentication: JWT-based admin authentication
- Styling: Custom CSS
- Internationalization: next-intl
- QR Generation: qrcode library
- Node.js 18+
- PostgreSQL 12+
- Git
# Clone the repository
git clone <repository-url>
cd dmk
# Run automated setup script
chmod +x setup-dev.sh
./setup-dev.sh
# Start development server
npm run devnpm install# Install PostgreSQL (Ubuntu/Debian)
sudo apt update
sudo apt install postgresql postgresql-contrib
# Start PostgreSQL service
sudo systemctl start postgresql
sudo systemctl enable postgresql
# Create database and user
sudo -u postgres psql
CREATE DATABASE dmk;
CREATE USER dmk WITH PASSWORD 'dmk';
GRANT ALL PRIVILEGES ON DATABASE dmk TO dmk;
\q# Copy environment template
cp .env.example .env
# Edit .env with your configuration
nano .envnpm run db:generate # Generate Prisma client
npm run db:push # Create database schema
npm run db:seed # Add test datanpm run devAccess at http://localhost:3001
- Admin Panel:
http://localhost:3001/admin - Use credentials configured during database seeding
- Ubuntu 20.04+ server with root access
- Domain name pointed to your server
- At least 1GB RAM and 10GB storage
# On your Ubuntu server, create application user
sudo adduser dmk
sudo usermod -aG sudo dmk
sudo su - dmk
# Clone repository
git clone <repository-url>
cd dmk
# Run automated deployment script
chmod +x deploy.sh
./deploy.shThe script will automatically:
- Install Node.js, PM2, Nginx, and PostgreSQL
- Set up the database
- Build and start the application
- Configure reverse proxy
- Set up automated backups
- Configure firewall
# Update system
sudo apt update && sudo apt upgrade -y
# Install Node.js 18
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
sudo apt-get install -y nodejs
# Install PM2 for process management
sudo npm install -g pm2
# Install Nginx
sudo apt install nginx
# Install PostgreSQL
sudo apt install postgresql postgresql-contrib# Create dedicated user
sudo adduser dmk
sudo usermod -aG sudo dmk
sudo su - dmk# Clone repository
git clone <repository-url>
cd dmk
# Install dependencies
npm ci --only=production
# Build application
npm run build# Create production database
sudo -u postgres psql
CREATE DATABASE dmk_prod;
CREATE USER dmk_prod WITH PASSWORD 'SECURE_PASSWORD_HERE';
GRANT ALL PRIVILEGES ON DATABASE dmk_prod TO dmk_prod;
\qCreate production .env:
# Database
DATABASE_URL="postgresql://dmk_prod:SECURE_PASSWORD_HERE@localhost:5432/dmk_prod"
# Authentication
NEXTAUTH_SECRET="super-strong-secret-64-chars-long-change-this-in-production"
NEXTAUTH_URL="https://yourdomain.com"
# Environment
NODE_ENV="production"
PORT=3001# Setup database
npm run db:push
npm run db:seed# Start application with PM2
pm2 start ecosystem.config.js
# Save PM2 configuration
pm2 save
# Setup PM2 to start on boot
pm2 startup
# Follow the instructions shown# Create Nginx configuration
sudo nano /etc/nginx/sites-available/friday-prayerAdd this configuration (replace yourdomain.com):
server {
listen 80;
server_name yourdomain.com www.yourdomain.com;
return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl http2;
server_name yourdomain.com www.yourdomain.com;
# SSL Configuration (will be updated after getting certificates)
ssl_certificate /etc/letsencrypt/live/yourdomain.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/yourdomain.com/privkey.pem;
# Security headers
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-XSS-Protection "1; mode=block" always;
add_header X-Content-Type-Options "nosniff" always;
add_header Referrer-Policy "no-referrer-when-downgrade" always;
# Gzip compression
gzip on;
gzip_vary on;
gzip_min_length 1024;
gzip_types text/plain text/css application/javascript application/json;
location / {
proxy_pass http://127.0.0.1:3001;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_cache_bypass $http_upgrade;
}
# Static files caching
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg)$ {
expires 1y;
add_header Cache-Control "public, immutable";
proxy_pass http://127.0.0.1:3001;
}
}# Enable site
sudo ln -s /etc/nginx/sites-available/friday-prayer /etc/nginx/sites-enabled/
# Test configuration
sudo nginx -t
# Start Nginx
sudo systemctl enable nginx
sudo systemctl start nginx# Install Certbot
sudo apt install certbot python3-certbot-nginx
# Get SSL certificate (replace with your domain)
sudo certbot --nginx -d yourdomain.com -d www.yourdomain.com
# Test auto-renewal
sudo certbot renew --dry-run# Configure firewall
sudo ufw allow ssh
sudo ufw allow 'Nginx Full'
sudo ufw --force enableThe deployment script creates a backup script at /home/dmk/backup-db.sh that runs daily at 2 AM via cron job.
Manual backup:
# Create backup
pg_dump -U dmk_prod -h localhost dmk_prod > backup_$(date +%Y%m%d).sql
# Restore from backup
psql -U dmk_prod -h localhost dmk_prod < backup_20241201.sqlpm2 list # List all processes
pm2 logs friday-prayer-app # View logs
pm2 restart friday-prayer-app # Restart application
pm2 stop friday-prayer-app # Stop application
pm2 monit # Monitor resourcescd /home/dmk/dmk
git pull
npm ci --only=production
npm run build
pm2 restart friday-prayer-appnpm run db:push # Update schema
npm run db:seed # Reseed dataGET /api/prayers- List upcoming prayersPOST /api/registrations- Create registrationPATCH /api/registrations/[id]- Update registrationDELETE /api/registrations/[id]- Cancel registration
POST /api/auth/login- Admin loginGET /api/admin/prayers- List prayers with statsPOST /api/admin/prayers- Create prayerPATCH /api/admin/prayers/[id]- Update prayerDELETE /api/admin/prayers/[id]- Delete prayerGET /api/admin/prayers/[id]/registrations- List registrationsPOST /api/admin/prayers/[id]/export- Export CSV
| Variable | Description | Default |
|---|---|---|
DATABASE_URL |
PostgreSQL connection string | Required |
NEXTAUTH_SECRET |
JWT signing secret | Required |
NEXTAUTH_URL |
Application base URL | http://localhost:3001 |
NODE_ENV |
Environment mode | development |
PORT |
Server port | 3001 |
- Registration Window: Saturday 00:00 (Europe/Berlin) to prayer start time
- Capacity: Hard limit enforced with database transactions
- Device Limit: One active registration per device per prayer
- Companions: Maximum 4 companions per registration
- Auto-activation: Prayers activate automatically during registration window
- Manual Override: Admin can manually activate/deactivate prayers
# Check application status
curl http://localhost:3001/api/prayers
# Check PM2 status
pm2 list
# Check Nginx status
sudo systemctl status nginx
# Check PostgreSQL status
sudo systemctl status postgresql- Application:
pm2 logs friday-prayer-app - Nginx Access:
/var/log/nginx/access.log - Nginx Error:
/var/log/nginx/error.log - PostgreSQL:
/var/log/postgresql/postgresql-*.log
# Monitor system resources
htop
# Monitor application performance
pm2 monit
# Check disk usage
df -h
# Check memory usage
free -hApplication Won't Start
# Check logs
pm2 logs friday-prayer-app
# Check environment variables
cat .env
# Verify database connection
npm run db:pushDatabase Connection Issues
# Check PostgreSQL status
sudo systemctl status postgresql
# Test connection
psql -U dmk_prod -d dmk_prod -h localhost
# Restart PostgreSQL
sudo systemctl restart postgresqlNginx Issues
# Test configuration
sudo nginx -t
# Check error logs
sudo tail -f /var/log/nginx/error.log
# Restart Nginx
sudo systemctl restart nginxSSL Certificate Problems
# Renew certificate
sudo certbot renew
# Check certificate status
sudo certbot certificates- Change Default Passwords: Update admin password immediately
- Secure Database: Use strong database passwords
- Environment Variables: Never commit
.envfiles - SSL Certificate: Always use HTTPS in production
- Firewall: Only open necessary ports
- Updates: Keep system and dependencies updated
- Backups: Automated daily database backups
- Monitoring: Set up uptime monitoring
npm run dev # Start development server
npm run build # Build for production
npm run start # Start production server
npm run lint # Run ESLint
npm run db:generate # Generate Prisma client
npm run db:push # Push schema to database
npm run db:seed # Seed database with test data- Check this documentation
- Review application logs:
pm2 logs friday-prayer-app - Check system logs:
journalctl -u nginxorjournalctl -u postgresql - Verify configuration files
- Contact system administrator
Built with ❤️ for the community