a28d91ac050ccac5f69285f087fa594059b83a25
[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 status     |      |         DB         |
89 ---------- |------+--------------------+
90 unknown    |
91            V
92          brisk   ->      mail-table
93 MAILED     |                 |
94            V                 |
95           user               |
96            |                 |
97            V                 |
98         mailbox              |
99            |                 |
100            V                 |
101         procmail             |
102            |                 |
103            V                 |
104   check with mail-table      |
105      and update DB      <----+
106   (needs ad-hoc page)
107 TOBECHK    |
108            V
109        authorize
110 normal     |
111            V
112