> For the complete documentation index, see [llms.txt](https://atiysus-organization.gitbook.io/aty-scripts/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://atiysus-organization.gitbook.io/aty-scripts/restaurant-creator/developer/architecture.md).

# Architecture

#### Stack

| Layer                 | Tech                                                                    |
| --------------------- | ----------------------------------------------------------------------- |
| Server / Client logic | Lua (CfxLua)                                                            |
| Bridge                | **aty\_lib** — framework, inventory, target, skin, database abstraction |
| Database              | oxmysql (MySQL)                                                         |
| NUI                   | **Vue 3** (Composition API) + Vite + Pinia, built to `web/dist`         |
| 3D screens            | `cr3d` DUI engine (texture-replace + panel rendering)                   |

#### State & sync model

* **Server-side cache** — restaurants are loaded from the DB into a server cache on start and after edits.
* **GlobalState replication** — the cache and live sub-states are published via `GlobalState` (e.g. `ATY_Restaurants`, `ATY_Freezers`, `ATY_PrepStock`, `ATY_PrepBoards`, `ATY_RestaurantPollutions`, `ATY_Dispensers`, `ATY_PizzaBoxes`, `ATY_EspressoMachines`). Clients read these and react via state-bag change handlers / polling loops.
* **Cooking states** — grill/fryer tickets sync via a dedicated `SyncCookingStates` client event; timers are computed client-side to stay clock-skew-proof.

#### Folder layout

```
aty_restaurant/
├── client/            # main, open, builder, dui, cr3d/, biometrics, npc,
│                      # microwave_prop, espresso_prop, pizza, courier, ...
├── server/            # main, kitchen, employees, dashboard, supply, admin,
│                      # microwave, biometrics, tenders, sabotage, npc, ...
├── shared/            # config.lua, config_items, config_recipes,
│                      # config_stations, locales, utils   (escrow_ignore'd)
├── web/               # Vue 3 NUI source (src) + built output (dist)
├── items/             # ready-to-paste ox / qb item lists
├── data/install.sql   # database schema
└── fxmanifest.lua
```

#### NUI build

The NUI is a standard Vite app:

```bash
cd web
npm install
npm run build      # outputs to web/dist (shipped)
```

`web/dist` is what the game loads (`ui_page 'web/dist/index.html'`). Only rebuild if you change files under `web/src`. Locale text and most config are read at runtime and do **not** require a rebuild.

#### Editable vs escrow

`shared/*` (config, items, recipes, stations, locales, utils) is `escrow_ignore`'d and fully open. Core logic may be protected depending on your distribution.
