# dx4 architecture

<p align='right'>dengi</p>

# fundamental types

## classes

#### db table

| name              | meaning                                         |
| ----------------- | ----------------------------------------------- |
| **classid**       | **unique** class id _(uppercase, min 3 max 10)_ |
| **userclassname** | use friendly name                               |
| **caching**       | `0 \| 1` toggles caching                        |

#### example

| classid     | userclassname | caching |
| ----------- | ------------- | ------- |
| `9BPLETNEV` | 9б            | `1`     |

## admins

#### db table

| name           | meaning                            |
| -------------- | ---------------------------------- |
| **adminId**    | unique admin id, **it's secret**   |
| **adminName**  | user friendly admin name           |
| **adminClass** | `classid`, that admin belongs to   |
| **adminPerms** | admin permisions, look table below |

#### permissions

| val  | meaning                                          |
| ---- | ------------------------------------------------ |
| `-1` | **unlimited, full access**                       |
| `0`  | _**preserved for users**_                        |
| `1`  | allowed to make change for _changes in schedule_ |
| `2`  | _bells and permament schedule_                   |
| `3`  | _change class profile, and notes_                |
| `4`  | _create and manage admins_                       |

#### > Requests

You can **request** a change, if your level is lower, also you can **accept** those changes if your admin level can do this

#### example

| adminId        | adminName      | adminClass  | adminPerms |
| -------------- | -------------- | ----------- | ---------- |
| `ivanpletnev4` | _Ivan Pletnev_ | `9bpletnev` | `-1`       |

## schedule _(permanent)_

#### db table

| name          | meaning                                                |
| ------------- | ------------------------------------------------------ |
| **classId**   | class belongs to                                       |
| **raspId**    | version id, _num_, increments, unique to **dayOfWeek** |
| **dayOfWeek** | day of week, _num_ **(**`0` **- monday)**              |
| **content**   | json **list** content, look table below                |

#### json content

| key         | meaning                                 |
| ----------- | --------------------------------------- |
| **num**     | n of lesson in schedule, start with `1` |
| **subject** | lesson subject                          |
| **cabinet** | lesson cabinet                          |

#### example

| **classId** | **raspId** | **dayOfWeek** | **content**                                             |
| ----------- | ---------- | ------------- | ------------------------------------------------------- |
| `9BPLETNEV` | `3`        | `0`           | `[{"num":1, "subject":'физека🤬', "cabinet", 209},...]` |

## changes in schedule _(zameni)_

#### db table

| name          | meaning                                                      |
| ------------- | ------------------------------------------------------------ |
| **classId**   | class belongs to                                             |
| **forDay**    | day date `DD-MM-YY` _(i hope there wouldn't be y3k problem)_ |
| **forRaspId** | _(this wont break on rasp change)_                           |
| **content**   | json list content, look table below                          |

#### json list content

| key         | meaning                                              |
| ----------- | ---------------------------------------------------- |
| **num**     | n of lesson in schedule, start with `1`              |
| **subject** | lesson subject, or `$function`, **look table below** |
| **cabinet** | lesson cabinet, if unused type `0`                   |

#### changes function

##### important

| function      | meaning                                                          |
| ------------- | ---------------------------------------------------------------- |
| **`$rm-bef`** | remove all lessons **before**, _including this_, eq. to old `-3` |
| **`$rm-aft`** | remove all lessons **after**, _including this_, eq. to old `-2`  |
