use serde::{Deserialize, Serialize}; use sqlx::FromRow; // --------------------------------------------------------------------------- // Database models // --------------------------------------------------------------------------- #[derive(Debug, FromRow)] #[allow(dead_code)] pub struct User { pub id: String, pub username: String, pub email: String, pub password_hash: String, pub created_at: String, } #[derive(Debug, FromRow)] #[allow(dead_code)] pub struct Progress { pub user_id: String, pub topic_id: String, pub lesson_id: String, pub completed: i32, pub best_score: i32, pub completed_at: Option, } #[derive(Debug, FromRow)] #[allow(dead_code)] pub struct UserStats { pub user_id: String, pub xp: i32, pub streak_days: i32, pub last_active_date: Option, pub hearts: i32, pub streak_freezes: i32, } #[derive(Debug, FromRow)] #[allow(dead_code)] pub struct LessonState { pub user_id: String, pub topic_id: String, pub lesson_id: String, pub current_index: i32, pub hearts: i32, pub correct_count: i32, pub updated_at: String, } // --------------------------------------------------------------------------- // Request DTOs // --------------------------------------------------------------------------- #[derive(Debug, Deserialize)] pub struct RegisterRequest { pub username: String, pub email: String, pub password: String, } #[derive(Debug, Deserialize)] pub struct LoginRequest { pub email: String, pub password: String, } #[derive(Debug, Deserialize)] pub struct ProgressUpdateRequest { pub topic_id: String, pub lesson_id: String, pub score: i32, pub xp_earned: i32, } #[derive(Debug, Deserialize)] pub struct LessonStateSaveRequest { pub topic_id: String, pub lesson_id: String, pub current_index: i32, pub hearts: i32, pub correct_count: i32, } // --------------------------------------------------------------------------- // Response DTOs // --------------------------------------------------------------------------- #[derive(Debug, Serialize)] pub struct AuthResponse { pub token: String, pub user: UserResponse, } #[derive(Debug, Serialize)] pub struct UserResponse { pub id: String, pub username: String, pub email: String, } #[derive(Debug, Serialize)] pub struct MeResponse { pub user: UserResponse, pub stats: StatsResponse, } #[derive(Debug, Serialize, Clone)] pub struct StatsResponse { pub xp: i32, pub streak_days: i32, pub hearts: i32, pub streak_freezes: i32, } #[derive(Debug, Serialize)] pub struct ProgressResponse { pub lessons: Vec, pub stats: StatsResponse, } #[derive(Debug, Serialize)] pub struct LessonProgress { pub topic_id: String, pub lesson_id: String, pub completed: bool, pub best_score: i32, pub completed_at: Option, } #[derive(Debug, Serialize)] pub struct LessonStateResponse { pub topic_id: String, pub lesson_id: String, pub current_index: i32, pub hearts: i32, pub correct_count: i32, } // --------------------------------------------------------------------------- // Push notification DTOs // --------------------------------------------------------------------------- #[derive(Debug, Deserialize)] pub struct PushSubscribeRequest { pub endpoint: String, pub p256dh: String, pub auth: String, } #[derive(Debug, Deserialize)] pub struct PushPreferencesRequest { pub reminder_enabled: bool, pub reminder_time: String, } #[derive(Debug, Serialize)] pub struct PushPreferencesResponse { pub reminder_enabled: bool, pub reminder_time: String, }