this repo has no description
1use serde::{Deserialize, Serialize};
2use sqlx::FromRow;
3
4// ---------------------------------------------------------------------------
5// Database models
6// ---------------------------------------------------------------------------
7
8#[derive(Debug, FromRow)]
9#[allow(dead_code)]
10pub struct User {
11 pub id: String,
12 pub username: String,
13 pub email: String,
14 pub password_hash: String,
15 pub created_at: String,
16}
17
18#[derive(Debug, FromRow)]
19#[allow(dead_code)]
20pub struct Progress {
21 pub user_id: String,
22 pub topic_id: String,
23 pub lesson_id: String,
24 pub completed: i32,
25 pub best_score: i32,
26 pub completed_at: Option<String>,
27}
28
29#[derive(Debug, FromRow)]
30#[allow(dead_code)]
31pub struct UserStats {
32 pub user_id: String,
33 pub xp: i32,
34 pub streak_days: i32,
35 pub last_active_date: Option<String>,
36 pub hearts: i32,
37}
38
39#[derive(Debug, FromRow)]
40#[allow(dead_code)]
41pub struct LessonState {
42 pub user_id: String,
43 pub topic_id: String,
44 pub lesson_id: String,
45 pub current_index: i32,
46 pub hearts: i32,
47 pub correct_count: i32,
48 pub updated_at: String,
49}
50
51// ---------------------------------------------------------------------------
52// Request DTOs
53// ---------------------------------------------------------------------------
54
55#[derive(Debug, Deserialize)]
56pub struct RegisterRequest {
57 pub username: String,
58 pub email: String,
59 pub password: String,
60}
61
62#[derive(Debug, Deserialize)]
63pub struct LoginRequest {
64 pub email: String,
65 pub password: String,
66}
67
68#[derive(Debug, Deserialize)]
69pub struct ProgressUpdateRequest {
70 pub topic_id: String,
71 pub lesson_id: String,
72 pub score: i32,
73 pub xp_earned: i32,
74}
75
76#[derive(Debug, Deserialize)]
77pub struct LessonStateSaveRequest {
78 pub topic_id: String,
79 pub lesson_id: String,
80 pub current_index: i32,
81 pub hearts: i32,
82 pub correct_count: i32,
83}
84
85// ---------------------------------------------------------------------------
86// Response DTOs
87// ---------------------------------------------------------------------------
88
89#[derive(Debug, Serialize)]
90pub struct AuthResponse {
91 pub token: String,
92 pub user: UserResponse,
93}
94
95#[derive(Debug, Serialize)]
96pub struct UserResponse {
97 pub id: String,
98 pub username: String,
99 pub email: String,
100}
101
102#[derive(Debug, Serialize)]
103pub struct MeResponse {
104 pub user: UserResponse,
105 pub stats: StatsResponse,
106}
107
108#[derive(Debug, Serialize, Clone)]
109pub struct StatsResponse {
110 pub xp: i32,
111 pub streak_days: i32,
112 pub hearts: i32,
113}
114
115#[derive(Debug, Serialize)]
116pub struct ProgressResponse {
117 pub lessons: Vec<LessonProgress>,
118 pub stats: StatsResponse,
119}
120
121#[derive(Debug, Serialize)]
122pub struct LessonProgress {
123 pub topic_id: String,
124 pub lesson_id: String,
125 pub completed: bool,
126 pub best_score: i32,
127 pub completed_at: Option<String>,
128}
129
130#[derive(Debug, Serialize)]
131pub struct LessonStateResponse {
132 pub topic_id: String,
133 pub lesson_id: String,
134 pub current_index: i32,
135 pub hearts: i32,
136 pub correct_count: i32,
137}