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