Merge branch 'fflush_mgmt' into curls
[brisk.git] / doc / ARCHITECTURE.txt
1 Sparse documentation about Brisk.
2
3 ==== brisk/table/user relationships ====
4
5 === points management ===
6
7 read from db:
8   * continue a match
9   * calculate placings
10   * calculate explain
11
12 write to db:
13   * finish a game
14
15 === in the room ===
16
17 // when standup
18 bri->user[user_idx] = user
19 user->idx      = user_idx
20 user->idx_orig = user_idx
21
22 // when sitdown
23 table->player[player_idx] = user_idx
24 user->table_pos = player_idx
25
26 === in the game ===
27
28 bin5->user[user_idx] = user
29 table->player[player_idx] = user_idx
30 user->table_pos = player_idx
31
32
33 Many things aren't documented at all, but I start with authentication workflow.
34
35 ==== MODIFY USERS TABLE ====
36
37 === PHP CODE ===
38
39 web/Obj/dbase_base.phh
40   function LoginDBItem -> args & body
41   function LoginDBItemFromRecord -> args & body
42
43 === SQL CODE ===
44 sql/sql.d/nnn-name-patch.sql
45
46
47 AUTHENTICATION WORKFLOW
48
49 --- CLI ------------
50 index.php:
51   onsubmit="return j_login_manager(this);" ->
52             sync xhr(index_wr.php?mesg=getchallenge&cli_name=<username>)
53
54 --- SRV ------------
55   GET index_wr.php send the string: "1|<tokens>"
56
57 --- CLI ------------
58   POST index.php with passid_private field equal to calcMD5(tokens[1]+calcMD5(form.elements['passid'].value))
59   add_user -> validate_name, login_verify
60
61
62 ===== Game Lifecycle =====
63
64 -> bin5/index_wr.php + argz[0] == 'logout'
65    - bri->table_wakeup($user)
66      - set users subst to "shutdowner" and "shutdowned"
67      - save this: "gst.st_loc++; the_end=true; window.onbeforeunload = null; \
68                    window.onunload = null; document.location.assign("../index.php");" 
69        in user->comm var for client xhr
70      - set $bri->the_end = TRUE
71
72
73 -> index.php  (after verify session value: ~L250)
74   - garbage_manager(TRUE)
75     - align many status var with briskin5 user values
76     - room_join_wakeup()
77
78 ==== Chunk flow ====
79
80
81 $ret = $user->maincheck($old_stat, $old_subst, $old_step, $this->rd_stat, $this->rd_subst, $this->rd_step,
82                         $splashdate, $table_idx, $table_token))
83 $user->rd_transp->chunk($this->rd_scristp++, $ret);
84
85
86 ===== New users workflow =====
87
88          UserA                 UserB                      Admin
89 -------------------------------------------------------------------------
90       guarante UserB
91            |
92            v
93       Save on mail
94          table,
95       email to UserB
96     (Disabled, MAILED)
97 -------------------------------------------------------------------------
98                            Receive email
99                            to check address
100                                  |
101                                  v
102                            Click on link
103                                  |
104                                  v
105                            Check on mail
106                                table,
107                            update user status,
108                            delete mail rec
109                           (Disabled, TOBECHK)
110 -------------------------------------------------------------------------
111                                                        admin panel
112                                                        accept user
113                                                             |
114                                                             v
115                                                      send email with
116                                                      password,
117                                                      update user status
118                                                       (Normal, NONE)
119 -------------------------------------------------------------------------
120                            Receive email
121                            with password
122 -------------------------------------------------------------------------