# ssheralievichd/online-printer-bot architecture

> Architecture diagram of the GitHub repository ssheralievichd/online-printer-bot, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ssheralievichd/online-printer-bot
- Repository: https://github.com/ssheralievichd/online-printer-bot

## Overview

Online Printer Bot accepts WhatsApp document and image orders, calculates pricing, collects a manually verified Dushanbe City transfer, and prints approved jobs through CUPS. The main workflow is coordinated by the message handler, which manages order state and invokes file, payment, and printer services; the bot connects that handler to WhatsApp. The README documents the manual payment and admin-approval stages. The graph reflects sampled source and README evidence; it does not assume an automated payment-provider integration.

Main entry points: [`src/handlers/message.js`](https://github.com/ssheralievichd/online-printer-bot/blob/main/src/handlers/message.js) (Message and commands), [`src/services/printer.js`](https://github.com/ssheralievichd/online-printer-bot/blob/main/src/services/printer.js) (Print and status service), [`src/bot.js`](https://github.com/ssheralievichd/online-printer-bot/blob/main/src/bot.js) (Bot connection), [`src/utils/file.js`](https://github.com/ssheralievichd/online-printer-bot/blob/main/src/utils/file.js) (File validation and storage)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_conversation["WhatsApp interaction"]
  node_whatsapp["WhatsApp"]
  node_bot["Bot connection<br/>[bot.js]"]
  node_handler["Message and commands<br/>[message.js]"]
end

subgraph group_orders["Order processing"]
  node_session[("Order session state<br/>[manager.js]")]
  node_file["File validation and storage<br/>[file.js]"]
  node_pricing["Order pricing<br/>[message.js]"]
end

subgraph group_operations["Payment and printing"]
  node_payment["Payment code and details<br/>[payment.js]"]
  node_transfer["Manual card transfer"]
  node_printer["Print and status service<br/>[printer.js]"]
  node_cups["CUPS printer"]
end

subgraph group_runtime["Runtime configuration"]
  node_config["Application settings<br/>[config.js]"]
  node_entry["Application entry<br/>[index.js]"]
end

node_customer(("Customer"))
node_admin(("Admin"))

node_customer -->|"sends messages"| node_whatsapp
node_whatsapp -->|"delivers events"| node_bot
node_entry -->|"starts"| node_bot
node_bot -->|"dispatches messages"| node_handler
node_handler -->|"sends replies"| node_whatsapp
node_handler -->|"reads and updates"| node_session
node_handler -->|"validates and saves"| node_file
node_handler -->|"calculates totals"| node_pricing
node_pricing -->|"counts pages"| node_file
node_handler -->|"gets payment details"| node_payment
node_customer -->|"transfers exact amount"| node_transfer
node_transfer -->|"appears in transaction history"| node_admin
node_admin -->|"confirms or rejects"| node_handler
node_handler -->|"checks and prints files"| node_printer
node_printer -->|"runs print commands"| node_cups
node_payment -->|"reads card settings"| node_config
node_printer -->|"reads printer settings"| node_config
node_file -->|"reads upload settings"| node_config

click node_bot "https://github.com/ssheralievichd/online-printer-bot/blob/main/src/bot.js"
click node_handler "https://github.com/ssheralievichd/online-printer-bot/blob/main/src/handlers/message.js"
click node_session "https://github.com/ssheralievichd/online-printer-bot/blob/main/src/sessions/manager.js"
click node_file "https://github.com/ssheralievichd/online-printer-bot/blob/main/src/utils/file.js"
click node_pricing "https://github.com/ssheralievichd/online-printer-bot/blob/main/src/handlers/message.js"
click node_payment "https://github.com/ssheralievichd/online-printer-bot/blob/main/src/services/payment.js"
click node_printer "https://github.com/ssheralievichd/online-printer-bot/blob/main/src/services/printer.js"
click node_config "https://github.com/ssheralievichd/online-printer-bot/blob/main/src/config.js"
click node_entry "https://github.com/ssheralievichd/online-printer-bot/blob/main/src/index.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_whatsapp,node_bot,node_handler toneBlue
class node_session,node_file,node_pricing toneAmber
class node_payment,node_transfer,node_printer,node_cups toneMint
class node_config,node_entry toneRose
class node_customer,node_admin toneIndigo
```

## Components

### WhatsApp interaction

- **WhatsApp**
- [Bot connection](https://github.com/ssheralievichd/online-printer-bot/blob/main/src/bot.js): `src/bot.js`
- [Message and commands](https://github.com/ssheralievichd/online-printer-bot/blob/main/src/handlers/message.js): `src/handlers/message.js`

### Order processing

- [Order session state](https://github.com/ssheralievichd/online-printer-bot/blob/main/src/sessions/manager.js): `src/sessions/manager.js`
- [File validation and storage](https://github.com/ssheralievichd/online-printer-bot/blob/main/src/utils/file.js): `src/utils/file.js`
- [Order pricing](https://github.com/ssheralievichd/online-printer-bot/blob/main/src/handlers/message.js): `src/handlers/message.js`

### Payment and printing

- [Payment code and details](https://github.com/ssheralievichd/online-printer-bot/blob/main/src/services/payment.js): `src/services/payment.js`
- **Manual card transfer**
- [Print and status service](https://github.com/ssheralievichd/online-printer-bot/blob/main/src/services/printer.js): `src/services/printer.js`
- **CUPS printer**

### Runtime configuration

- [Application settings](https://github.com/ssheralievichd/online-printer-bot/blob/main/src/config.js): `src/config.js`
- [Application entry](https://github.com/ssheralievichd/online-printer-bot/blob/main/src/index.js): `src/index.js`

### Other components

- **Customer**
- **Admin**

## Connections

- Customer → WhatsApp: sends messages (evidence: `README.md`)
- WhatsApp → Bot connection: delivers events (evidence: `src/bot.js`)
- Application entry → Bot connection: starts (evidence: `src/index.js`)
- Bot connection → Message and commands: dispatches messages (evidence: `src/bot.js`)
- Message and commands → WhatsApp: sends replies (evidence: `src/handlers/message.js`)
- Message and commands → Order session state: reads and updates (evidence: `src/handlers/message.js`)
- Message and commands → File validation and storage: validates and saves (evidence: `src/handlers/message.js`)
- Message and commands → Order pricing: calculates totals (evidence: `src/handlers/message.js`)
- Order pricing → File validation and storage: counts pages (evidence: `src/handlers/message.js`)
- Message and commands → Payment code and details: gets payment details (evidence: `src/handlers/message.js`)
- Customer → Manual card transfer: transfers exact amount (evidence: `README.md`)
- Manual card transfer → Admin: appears in transaction history (evidence: `README.md`)
- Admin → Message and commands: confirms or rejects (evidence: `README.md`)
- Message and commands → Print and status service: checks and prints files (evidence: `src/handlers/message.js`)
- Print and status service → CUPS printer: runs print commands (evidence: `src/services/printer.js`)
- Payment code and details → Application settings: reads card settings (evidence: `src/services/payment.js`)
- Print and status service → Application settings: reads printer settings (evidence: `src/services/printer.js`)
- File validation and storage → Application settings: reads upload settings (evidence: `src/utils/file.js`)
