# System Patterns - Dead Man Switch 2.0 ## Mimari ``` ┌─────────────────────────────────────────────────┐ │ Next.js App │ ├─────────────────┬───────────────────────────────┤ │ Frontend │ API Routes │ │ (React + RSC) │ (Auth, CRUD, Cron) │ └────────┬────────┴───────────────┬───────────────┘ │ │ │ Web Crypto API │ Prisma │ (encrypt/decrypt) │ │ ▼ │ ┌─────────────────┐ │ │ PostgreSQL │ │ └─────────────────┘ │ │ ▼ ▼ ┌─────────────────┐ ┌─────────────────┐ │ Cloudflare R2 │ │ Nodemailer │ │ (encrypted │ │ (SMTP) │ │ files) │ └─────────────────┘ └─────────────────┘ ``` ## Veritabanı Şeması (Draft) - **User**: id, email, password, role, createdAt - **Message**: id, userId, title, encryptedContent, isEncrypted, checkInInterval, lastCheckIn, nextDeadline, status - **Recipient**: id, messageId, email, name - **Attachment**: id, messageId, r2Key, encryptedName, size ## Güvenlik Patterns - Şifreleme client-side (AES-256-GCM) - Şifre hash'i sunucuya gönderilmez - Derived key PBKDF2 ile üretilir - Salt her mesaj için unique ## API Patterns - REST endpoints under `/api/*` - NextAuth session-based auth - Zod validation