Database session
Cookie chỉ chứa session token. Khi nối Turso, server có thể revoke user ngay khi admin đổi trạng thái.
Deriv bot control plane
App này được scaffold theo hướng production: `Next.js App Router`, `NextAuth v5`, `Drizzle + Turso`, admin approval flow, API tạo OTP WebSocket URL và dashboard để start/stop bot, xem lịch sử trade.
Cookie chỉ chứa session token. Khi nối Turso, server có thể revoke user ngay khi admin đổi trạng thái.
Deriv access token được AES-256-GCM encrypt trước khi lưu. Client chỉ nhận OTP URL ngắn hạn.
User mới vào trạng thái pending. Middleware và server guard chặn dashboard cho đến khi admin approve.
`Google Login` → server tạo hoặc cập nhật user → session lưu ở database.
`/api/deriv/connect` mã hóa token trước khi ghi DB, không trả token về browser.
`/api/bot/start` giải mã token ở server, gọi Deriv để lấy OTP WebSocket URL rồi mới trả dữ liệu tối thiểu cho client.
Nếu chưa cấu hình Google hoặc Turso, app vẫn render được bằng demo data để bạn kiểm tra luồng UI. Khi thêm biến môi trường, app tự chuyển sang Google OAuth và database session.