# 🚀 Setup Instructions - Polres Wonosobo Digital Services

## 📋 Login Default Setelah Publish

### 🔑 **Login Admin Panel**

**URL Login:** `http://your-domain.com/admin/login`

#### **Superadmin Account (Full Access)**
```
Email: admin@wonosobo.polri.go.id
Password: admin123
```

#### **Admin Account (Basic Access)**
```
Email: fathurz1507@gmail.com  
Password: [Password yang sudah di-set]
```

---

## ⚠️ **INSTRUKSI PENTING SETELAH PUBLISH**

### 1. **GANTI PASSWORD DEFAULT**
Langkah pertama setelah login:
1. Login dengan akun superadmin
2. Buka menu **Pengaturan** → **Kelola Pengguna**
3. Edit user `admin@wonosobo.polri.go.id`
4. Ganti password default dengan password yang aman
5. Hapus atau non-aktifkan user yang tidak diperlukan

### 2. **UPDATE SYSTEM SETTINGS**
Buka **Pengaturan** → **System Settings** dan update:
- Site Name: Polres Wonosobo
- Contact Information
- Working Hours
- Email & Phone numbers

### 3. **VERIFIKASI LAYANAN**
Pastikan semua layanan aktif:
- **Pengaturan** → **Kelola Layanan**
- Pastikan SKCK, SPKT, dan Lalu Lintas status = ACTIVE

---

## 🛠️ **Setup Production**

### **Step 1: Environment Variables**
Buat file `.env` di root directory:

```env
# Database
DATABASE_URL="file:./dev.db"

# JWT Secret (Generate dengan openssl rand -base64 32)
JWT_SECRET="your-super-secret-jwt-key-here"
NEXTAUTH_SECRET="your-nextauth-secret-here"
NEXTAUTH_URL="http://your-domain.com"

# Email Configuration (Optional)
EMAIL_HOST="smtp.gmail.com"
EMAIL_PORT=587
EMAIL_USER="your-email@gmail.com"
EMAIL_PASS="your-app-password"

# File Upload
MAX_FILE_SIZE=5
UPLOAD_DIR="./uploads"
```

### **Step 2: Build & Deploy**
```bash
# Install dependencies
npm install

# Setup database
npm run db:push

# Build application
npm run build

# Start production server
npm start
```

### **Step 3: Create Admin Account (Jika belum ada)**
```bash
# Jalankan script create admin
npx tsx scripts/create-admin.ts
```

---

## 📁 **Struktur Folder Penting**

```
├── uploads/           # File uploads (signature, photo)
├── prisma/           # Database schema & migrations
├── public/           # Static files (images, hero-bg.jpg)
└── logs/             # Application logs
```

---

## 🔐 **Security Checklist**

### **Sebelum Production:**
- [ ] Ganti password default superadmin
- [ ] Set JWT secret yang kuat
- [ ] Enable HTTPS
- [ ] Configure firewall
- [ ] Set up backup database
- [ ] Monitor error logs

### **User Management:**
- [ ] Hapus user testing yang tidak perlu
- [ ] Set role permissions dengan benar
- [ ] Enable 2FA jika diperlukan
- [ ] Regular password rotation

---

## 🚨 **Troubleshooting**

### **Login Issues:**
1. Cek database connection: `npm run db:push`
2. Verify admin exists: `npx tsx check-admins.ts`
3. Clear browser cache
4. Check console errors

### **Database Issues:**
```bash
# Reset database (HATI-HATI - HILANGKAN SEMUA DATA)
npm run db:reset

# Push schema changes
npm run db:push
```

### **File Upload Issues:**
1. Check folder permissions: `chmod 755 uploads/`
2. Verify max file size settings
3. Check disk space

---

## 📞 **Support**

### **Contact Information:**
- **Developer:** [Your Contact Info]
- **Documentation:** README.md
- **Issues:** Check console logs & error messages

### **Useful Commands:**
```bash
# Check admin users
npx tsx check-admins.ts

# Create new admin
npx tsx scripts/create-admin.ts

# Database operations
npm run db:push
npm run db:generate

# Development
npm run dev
npm run build
npm start
```

---

## 🎯 **Quick Start Summary**

1. **Login:** `http://your-domain.com/admin/login`
2. **Default:** `admin@wonosobo.polri.go.id` / `admin123`
3. **FIRST:** Ganti password immediately!
4. **Configure:** System settings & services
5. **Test:** All user workflows
6. **Monitor:** Logs & performance

**🔒 SECURITY FIRST: Selalu ganti password default di production!**