# madkulolo/template-zakaz-beta architecture

> Architecture diagram of the GitHub repository madkulolo/template-zakaz-beta, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-10-22). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/madkulolo/template-zakaz-beta
- Repository: https://github.com/madkulolo/template-zakaz-beta

## Overview

##### Project type and purpose
- This is a front-end-only, single-page web cashier application for a shawarma restaurant (“пупупу шаурма”).
- It runs entirely in the browser, uses vanilla JavaScript (ES5), HTML, CSS, and persists all data in browser localStorage.
- No server or remote API calls—everything is modules loaded by index.html.

##### File structure
- Top-level:
- index.html – host page
- css/styles.css – application styles
- js/ – four modules
– data.js (data layer, localStorage API)
– cart.js (cart business logic)
– ui.js (view/rendering layer)
– main.js (app orchestration, event wiring)
- .github/workflows – CI definitions (lint, static checks)
- No backend directory or API folder—pure client.

##### README insights
- Architecture described as modular JS, separation of concerns.
- Data persistence: localStorage only.
- UI: two tabs (“Новый заказ”, “История заказов”), adaptive design for mobile.
- Future extension could add a real database or server.

##### Main components
a. Presentation Layer (UI)
– index.html + css/styles.css
– js/ui.js
– Mobile-optimized, handles user events (click “+”, “–”, “Добавить”, “✅ Оформить заказ”)
b. Business-Logic Layer
– js/cart.js (cart operations, price calculations, toppings logic)
– js/main.js (event listeners, tab switching, application flow)
c. Data Layer
– js/data.js (CRUD to localStorage, order history)
– Browser localStorage (key-value store)
d. (Optional) Development & CI
– .github/workflows (static code checks)

##### Relationships and interactions
- On page load, index.html bootstraps main.js.
- main.js registers UI event handlers in ui.js.
- ui.js emits user actions (e.g., “add item”) to business logic (cart.js).
- cart.js updates the in-memory data model and calls data.js to persist to localStorage.
- data.js reads/writes localStorage and returns data to cart.js or main.js.
- main.js/ ui.js re-render views based on data changes.

##### Architectural patterns and principles
- MVC-style separation:
- Model = data.js + localStorage
- View = ui.js + HTML/CSS
- Controller = cart.js + main.js
- Modular JavaScript files—single responsibility per module.
- Event-driven communication between UI and logic.

##### Technologies, frameworks, libraries
- HTML5, CSS3 (flex, media queries for responsiveness)
- Vanilla JavaScript ES5 modules (no bundler)
- Browser localStorage API
- GitHub Actions for static checks

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Presentation Layer"
        IDX["index.html"]:::ui
        CSS["css/styles.css"]:::ui
        UI["js/ui.js"]:::ui
    end

    subgraph "Business Logic Layer"
        CART["js/cart.js"]:::logic
        MAIN["js/main.js"]:::logic
    end

    subgraph "Data Layer"
        DATA["js/data.js"]:::data
        LS["Browser localStorage"]:::data
    end

    CI[".github/workflows/"]:::ci

    IDX -->|"bootstraps"| MAIN
    MAIN -->|"registerUIHandlers()"| UI
    UI -->|"user events"| MAIN
    UI -->|"addItem()/removeItem()"| CART
    MAIN -->|"orchestrates flow"| CART
    CART -->|"persistOrder()/getOrders()"| DATA
    DATA -->|"read/write"| LS
    LS -->|"stored data"| DATA
    MAIN -->|"refreshView()"| UI

    CI -.->|"lint/static checks"| IDX
    CI -.->|"lint/static checks"| CSS
    CI -.->|"lint/static checks"| UI
    CI -.->|"lint/static checks"| CART
    CI -.->|"lint/static checks"| MAIN
    CI -.->|"lint/static checks"| DATA

    click IDX "https://github.com/madkulolo/template-zakaz-beta/blob/main/index.html"
    click CSS "https://github.com/madkulolo/template-zakaz-beta/blob/main/css/styles.css"
    click UI "https://github.com/madkulolo/template-zakaz-beta/blob/main/js/ui.js"
    click CART "https://github.com/madkulolo/template-zakaz-beta/blob/main/js/cart.js"
    click MAIN "https://github.com/madkulolo/template-zakaz-beta/blob/main/js/main.js"
    click DATA "https://github.com/madkulolo/template-zakaz-beta/blob/main/js/data.js"
    click CI "https://github.com/madkulolo/template-zakaz-beta/tree/main/.github/workflows/"

    classDef ui fill:#D0E6FF,stroke:#7BAFE1,color:#000
    classDef logic fill:#D0FFD6,stroke:#8FD18F,color:#000
    classDef data fill:#FFE8A1,stroke:#E2C46F,color:#000
    classDef ci fill:#E0E0E0,stroke:#A0A0A0,color:#000
```
