# vtjvlad/dzshop architecture

> Architecture diagram of the GitHub repository vtjvlad/dzshop, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/vtjvlad/dzshop
- Repository: https://github.com/vtjvlad/dzshop

## Overview

dzshop is a web shop with standard and Telegram-based authentication, product browsing, carts, checkout, and an order-change notification utility. The main documented runtime flow is browser authentication and shopping through Express routes, which read and write MongoDB-backed models; checkout reads the cart and creates an order. Separate scripts transform product data and provide an interactive GPT-to-Telegram path. Source excerpts show only part of the server and frontend, so unverified client-to-API and data-tool relationships are omitted.

Main entry points: [`server.js`](https://github.com/vtjvlad/dzshop/blob/main/server.js) (Express routes), [`public/auth2.js`](https://github.com/vtjvlad/dzshop/blob/main/public/auth2.js) (Authentication UI), [`sendTg.js`](https://github.com/vtjvlad/dzshop/blob/main/sendTg.js) (Telegram sender), [`wachCange.js`](https://github.com/vtjvlad/dzshop/blob/main/wachCange.js) (Order change watcher)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Shop interface"]
  node_authui["Authentication UI<br/>[auth2.js]"]
  node_cartui["Cart interface<br/>[cart.js]"]
  node_shopui["Storefront scripts<br/>[script.js]"]
  node_stockui["Stock interface<br/>[stock.js]"]
end

subgraph group_api["Shop backend"]
  node_server["Express routes<br/>[server.js]"]
  node_users["User authentication<br/>[server.js]"]
  node_products["Product API<br/>[server.js]"]
  node_cart["Cart API<br/>[server.js]"]
  node_checkout["Checkout<br/>[server.js]"]
end

subgraph group_data["Product data tools"]
  node_csvjson["CSV to JSON<br/>[1csvjson.js]"]
  node_jsonmongo["JSON to MongoDB<br/>[2prod2mongo.js]"]
  node_mongjson["MongoDB to JSON<br/>[3mongo2json.js]"]
  node_jsonbuilder["JSON builder<br/>[make.js]"]
end

subgraph group_notify["Notifications"]
  node_orderwatch["Order change watcher<br/>[wachCange.js]"]
  node_gpt["GPT prompt client<br/>[gptTg.js]"]
  node_tgnotify["Telegram sender<br/>[sendTg.js]"]
end

node_shopper(("Shopper"))
node_mongo[("MongoDB")]
node_openai{{"OpenAI API"}}
node_telegram{{"Telegram"}}

node_shopper -->|"uses"| node_authui
node_authui -->|"posts auth"| node_server
node_server -->|"serves page"| node_authui
node_server -->|"reads and writes"| node_mongo
node_server -->|"routes auth"| node_users
node_server -->|"routes products"| node_products
node_server -->|"routes cart"| node_cart
node_server -->|"routes checkout"| node_checkout
node_checkout -->|"loads cart"| node_cart
node_checkout -->|"saves order"| node_mongo
node_jsonmongo -->|"inserts products"| node_mongo
node_orderwatch -->|"watches orders"| node_mongo
node_orderwatch -->|"sends alert"| node_tgnotify
node_gpt -->|"requests completion"| node_openai
node_gpt -->|"sends response"| node_tgnotify
node_tgnotify -->|"sends message"| node_telegram

click node_authui "https://github.com/vtjvlad/dzshop/blob/main/public/auth2.js"
click node_cartui "https://github.com/vtjvlad/dzshop/blob/main/public/cart.js"
click node_shopui "https://github.com/vtjvlad/dzshop/blob/main/public/script.js"
click node_stockui "https://github.com/vtjvlad/dzshop/blob/main/public/stock.js"
click node_server "https://github.com/vtjvlad/dzshop/blob/main/server.js"
click node_users "https://github.com/vtjvlad/dzshop/blob/main/server.js"
click node_products "https://github.com/vtjvlad/dzshop/blob/main/server.js"
click node_cart "https://github.com/vtjvlad/dzshop/blob/main/server.js"
click node_checkout "https://github.com/vtjvlad/dzshop/blob/main/server.js"
click node_csvjson "https://github.com/vtjvlad/dzshop/blob/main/1csvjson.js"
click node_jsonmongo "https://github.com/vtjvlad/dzshop/blob/main/2prod2mongo.js"
click node_mongjson "https://github.com/vtjvlad/dzshop/blob/main/3mongo2json.js"
click node_jsonbuilder "https://github.com/vtjvlad/dzshop/blob/main/make.js"
click node_orderwatch "https://github.com/vtjvlad/dzshop/blob/main/wachCange.js"
click node_gpt "https://github.com/vtjvlad/dzshop/blob/main/gptTg.js"
click node_tgnotify "https://github.com/vtjvlad/dzshop/blob/main/sendTg.js"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_authui,node_cartui,node_shopui,node_stockui toneBlue
class node_server,node_users,node_products,node_cart,node_checkout,node_mongo toneAmber
class node_csvjson,node_jsonmongo,node_mongjson,node_jsonbuilder,node_openai toneMint
class node_orderwatch,node_gpt,node_tgnotify toneRose
class node_shopper,node_telegram toneIndigo
```

## Components

### Shop interface

- [Authentication UI](https://github.com/vtjvlad/dzshop/blob/main/public/auth2.js): `public/auth2.js`
- [Cart interface](https://github.com/vtjvlad/dzshop/blob/main/public/cart.js): `public/cart.js`
- [Storefront scripts](https://github.com/vtjvlad/dzshop/blob/main/public/script.js): `public/script.js`
- [Stock interface](https://github.com/vtjvlad/dzshop/blob/main/public/stock.js): `public/stock.js`

### Shop backend

- [Express routes](https://github.com/vtjvlad/dzshop/blob/main/server.js): `server.js`
- [User authentication](https://github.com/vtjvlad/dzshop/blob/main/server.js): `server.js`
- [Product API](https://github.com/vtjvlad/dzshop/blob/main/server.js): `server.js`
- [Cart API](https://github.com/vtjvlad/dzshop/blob/main/server.js): `server.js`
- [Checkout](https://github.com/vtjvlad/dzshop/blob/main/server.js): `server.js`

### Product data tools

- [CSV to JSON](https://github.com/vtjvlad/dzshop/blob/main/1csvjson.js): `1csvjson.js`
- [JSON to MongoDB](https://github.com/vtjvlad/dzshop/blob/main/2prod2mongo.js): `2prod2mongo.js`
- [MongoDB to JSON](https://github.com/vtjvlad/dzshop/blob/main/3mongo2json.js): `3mongo2json.js`
- [JSON builder](https://github.com/vtjvlad/dzshop/blob/main/make.js): `make.js`

### Notifications

- [Order change watcher](https://github.com/vtjvlad/dzshop/blob/main/wachCange.js): `wachCange.js`
- [GPT prompt client](https://github.com/vtjvlad/dzshop/blob/main/gptTg.js): `gptTg.js`
- [Telegram sender](https://github.com/vtjvlad/dzshop/blob/main/sendTg.js): `sendTg.js`

### Other components

- **Shopper**
- **MongoDB**
- **OpenAI API**
- **Telegram**

## Connections

- Shopper → Authentication UI: uses
- Authentication UI → Express routes: posts auth (evidence: `public/auth2.js`)
- Express routes → Authentication UI: serves page (evidence: `server.js`)
- Express routes → MongoDB: reads and writes (evidence: `server.js`)
- Express routes → User authentication: routes auth (evidence: `server.js`)
- Express routes → Product API: routes products (evidence: `server.js`)
- Express routes → Cart API: routes cart (evidence: `server.js`)
- Express routes → Checkout: routes checkout (evidence: `server.js`)
- Checkout → Cart API: loads cart (evidence: `server.js`)
- Checkout → MongoDB: saves order (evidence: `server.js`)
- JSON to MongoDB → MongoDB: inserts products (evidence: `2prod2mongo.js`)
- Order change watcher → MongoDB: watches orders (evidence: `wachCange.js`)
- Order change watcher → Telegram sender: sends alert (evidence: `wachCange.js`)
- GPT prompt client → OpenAI API: requests completion (evidence: `gptTg.js`)
- GPT prompt client → Telegram sender: sends response (evidence: `gptTg.js`)
- Telegram sender → Telegram: sends message (evidence: `sendTg.js`)
