# acc-tax-reighteen/bot-ar-telegram architecture

> Architecture diagram of the GitHub repository acc-tax-reighteen/bot-ar-telegram, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-08). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/acc-tax-reighteen/bot-ar-telegram
- Repository: https://github.com/acc-tax-reighteen/bot-ar-telegram

## Overview

This is a Telegram accounts-receivable reporting bot. The principal workflow prepares AR and customer-name data from Excel, loads it into memory, authenticates a Telegram user, resolves a customer query, applies interactive product/due-date/FRAUD filters, then renders and sends a PNG report. The README documents additional capabilities such as multi-code queries, group keywords, periodic refresh, and photo-to-document fallback. Internal bot details are partly unsampled, so those links rely on README statements rather than inspected handler code.

Main entry points: [`Dapur/1_CopyData.py`](https://github.com/acc-tax-reighteen/bot-ar-telegram/blob/main/Dapur/1_CopyData.py) (Extract workbook data), [`Dapur/3_ARBotTelegram.py`](https://github.com/acc-tax-reighteen/bot-ar-telegram/blob/main/Dapur/3_ARBotTelegram.py) (Telegram bot runtime), [`Jalankan BOT.py`](https://github.com/acc-tax-reighteen/bot-ar-telegram/blob/main/Jalankan%20BOT.py) (Run workflow), [`Dapur/config.conf`](https://github.com/acc-tax-reighteen/bot-ar-telegram/blob/main/Dapur/config.conf) (Bot configuration)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_preparation["Data preparation"]
  node_launcher["Run workflow<br/>[Jalankan BOT.py]"]
  node_extract["Extract workbook data<br/>[1_CopyData.py]"]
  node_ar_cache[("AR data workbook")]
  node_customer_cache[("Customer-name workbook")]
  node_ml_cache[("ML mapping workbook")]
  node_date_format["Normalize dates<br/>[2_AdjDateFormat.py]"]
  node_config["Bot configuration<br/>[config.conf]"]
end

subgraph group_bot["Telegram reporting bot"]
  node_bot_runtime["Telegram bot runtime<br/>[3_ARBotTelegram.py]"]
  node_preload["RAM preload and refresh<br/>[3_ARBotTelegram.py]"]
end

subgraph group_resolution["Query and resolution"]
  node_query_resolution["Customer query resolution<br/>[3_ARBotTelegram.py]"]
  node_name_lookup["Name mapping and fuzzy match<br/>[3_ARBotTelegram.py]"]
end

subgraph group_reporting["Filtering and output"]
  node_interactive_filters["Interactive filters<br/>[3_ARBotTelegram.py]"]
  node_report_render["PNG report rendering<br/>[3_ARBotTelegram.py]"]
  node_report_delivery["Photo or document delivery<br/>[3_ARBotTelegram.py]"]
end

node_user(("Telegram user"))
node_source_excel[("ARVIEWER workbook")]
node_ml_source[("ML training workbook")]
node_telegram["Telegram Bot API"]

node_launcher -->|"runs first"| node_extract
node_launcher -->|"runs next"| node_date_format
node_launcher -->|"starts bot"| node_bot_runtime
node_source_excel -->|"provides sheets"| node_extract
node_ml_source -->|"provides mapping"| node_extract
node_extract -->|"writes AR data"| node_ar_cache
node_extract -->|"writes names"| node_customer_cache
node_extract -->|"copies ML data"| node_ml_cache
node_ar_cache -->|"reads and updates"| node_date_format
node_config -->|"sets source paths"| node_extract
node_config -->|"sets credentials"| node_bot_runtime
node_bot_runtime -->|"preloads and refreshes"| node_preload
node_ar_cache -->|"loads AR data"| node_preload
node_customer_cache -->|"supports name lookup"| node_name_lookup
node_ml_cache -->|"supports ML matching"| node_name_lookup
node_user -->|"sends query"| node_telegram
node_telegram -->|"delivers messages"| node_bot_runtime
node_bot_runtime -->|"requests authentication"| node_user
node_bot_runtime -->|"handles query"| node_query_resolution
node_query_resolution -->|"resolves names"| node_name_lookup
node_query_resolution -->|"offers filter steps"| node_interactive_filters
node_interactive_filters -->|"selects report data"| node_report_render
node_report_render -->|"produces PNG"| node_report_delivery
node_report_delivery -->|"sends report"| node_telegram

click node_launcher "https://github.com/acc-tax-reighteen/bot-ar-telegram/blob/main/Jalankan%20BOT.py"
click node_extract "https://github.com/acc-tax-reighteen/bot-ar-telegram/blob/main/Dapur/1_CopyData.py"
click node_date_format "https://github.com/acc-tax-reighteen/bot-ar-telegram/blob/main/Dapur/2_AdjDateFormat.py"
click node_config "https://github.com/acc-tax-reighteen/bot-ar-telegram/blob/main/Dapur/config.conf"
click node_bot_runtime "https://github.com/acc-tax-reighteen/bot-ar-telegram/blob/main/Dapur/3_ARBotTelegram.py"
click node_preload "https://github.com/acc-tax-reighteen/bot-ar-telegram/blob/main/Dapur/3_ARBotTelegram.py"
click node_query_resolution "https://github.com/acc-tax-reighteen/bot-ar-telegram/blob/main/Dapur/3_ARBotTelegram.py"
click node_name_lookup "https://github.com/acc-tax-reighteen/bot-ar-telegram/blob/main/Dapur/3_ARBotTelegram.py"
click node_interactive_filters "https://github.com/acc-tax-reighteen/bot-ar-telegram/blob/main/Dapur/3_ARBotTelegram.py"
click node_report_render "https://github.com/acc-tax-reighteen/bot-ar-telegram/blob/main/Dapur/3_ARBotTelegram.py"
click node_report_delivery "https://github.com/acc-tax-reighteen/bot-ar-telegram/blob/main/Dapur/3_ARBotTelegram.py"

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_launcher,node_extract,node_ar_cache,node_customer_cache,node_ml_cache,node_date_format,node_config,node_user toneBlue
class node_bot_runtime,node_preload,node_source_excel,node_ml_source toneAmber
class node_query_resolution,node_name_lookup,node_telegram toneMint
class node_interactive_filters,node_report_render,node_report_delivery toneRose
```

## Components

### Data preparation

- [Run workflow](https://github.com/acc-tax-reighteen/bot-ar-telegram/blob/main/Jalankan%20BOT.py): `Jalankan BOT.py`
- [Extract workbook data](https://github.com/acc-tax-reighteen/bot-ar-telegram/blob/main/Dapur/1_CopyData.py): `Dapur/1_CopyData.py`
- **AR data workbook**
- **Customer-name workbook**
- **ML mapping workbook**
- [Normalize dates](https://github.com/acc-tax-reighteen/bot-ar-telegram/blob/main/Dapur/2_AdjDateFormat.py): `Dapur/2_AdjDateFormat.py`
- [Bot configuration](https://github.com/acc-tax-reighteen/bot-ar-telegram/blob/main/Dapur/config.conf): `Dapur/config.conf`

### Telegram reporting bot

- [Telegram bot runtime](https://github.com/acc-tax-reighteen/bot-ar-telegram/blob/main/Dapur/3_ARBotTelegram.py): `Dapur/3_ARBotTelegram.py`
- [RAM preload and refresh](https://github.com/acc-tax-reighteen/bot-ar-telegram/blob/main/Dapur/3_ARBotTelegram.py): `Dapur/3_ARBotTelegram.py`

### Query and resolution

- [Customer query resolution](https://github.com/acc-tax-reighteen/bot-ar-telegram/blob/main/Dapur/3_ARBotTelegram.py): `Dapur/3_ARBotTelegram.py`
- [Name mapping and fuzzy match](https://github.com/acc-tax-reighteen/bot-ar-telegram/blob/main/Dapur/3_ARBotTelegram.py): `Dapur/3_ARBotTelegram.py`

### Filtering and output

- [Interactive filters](https://github.com/acc-tax-reighteen/bot-ar-telegram/blob/main/Dapur/3_ARBotTelegram.py): `Dapur/3_ARBotTelegram.py`
- [PNG report rendering](https://github.com/acc-tax-reighteen/bot-ar-telegram/blob/main/Dapur/3_ARBotTelegram.py): `Dapur/3_ARBotTelegram.py`
- [Photo or document delivery](https://github.com/acc-tax-reighteen/bot-ar-telegram/blob/main/Dapur/3_ARBotTelegram.py): `Dapur/3_ARBotTelegram.py`

### Other components

- **Telegram user**
- **ARVIEWER workbook**
- **ML training workbook**
- **Telegram Bot API**

## Connections

- Run workflow → Extract workbook data: runs first (evidence: `README.md`)
- Run workflow → Normalize dates: runs next (evidence: `README.md`)
- Run workflow → Telegram bot runtime: starts bot (evidence: `README.md`)
- ARVIEWER workbook → Extract workbook data: provides sheets (evidence: `Dapur/1_CopyData.py`)
- ML training workbook → Extract workbook data: provides mapping (evidence: `Dapur/1_CopyData.py`)
- Extract workbook data → AR data workbook: writes AR data (evidence: `Dapur/1_CopyData.py`)
- Extract workbook data → Customer-name workbook: writes names (evidence: `Dapur/1_CopyData.py`)
- Extract workbook data → ML mapping workbook: copies ML data (evidence: `Dapur/1_CopyData.py`)
- AR data workbook → Normalize dates: reads and updates (evidence: `Dapur/2_AdjDateFormat.py`)
- Bot configuration → Extract workbook data: sets source paths (evidence: `Dapur/1_CopyData.py`)
- Bot configuration → Telegram bot runtime: sets credentials (evidence: `README.md`)
- Telegram bot runtime → RAM preload and refresh: preloads and refreshes (evidence: `README.md`)
- AR data workbook → RAM preload and refresh: loads AR data (evidence: `README.md`)
- Customer-name workbook → Name mapping and fuzzy match: supports name lookup (evidence: `README.md`)
- ML mapping workbook → Name mapping and fuzzy match: supports ML matching (evidence: `README.md`)
- Telegram user → Telegram Bot API: sends query (evidence: `README.md`)
- Telegram Bot API → Telegram bot runtime: delivers messages (evidence: `README.md`)
- Telegram bot runtime → Telegram user: requests authentication (evidence: `README.md`)
- Telegram bot runtime → Customer query resolution: handles query (evidence: `README.md`)
- Customer query resolution → Name mapping and fuzzy match: resolves names (evidence: `README.md`)
- Customer query resolution → Interactive filters: offers filter steps (evidence: `README.md`)
- Interactive filters → PNG report rendering: selects report data (evidence: `README.md`)
- PNG report rendering → Photo or document delivery: produces PNG (evidence: `README.md`)
- Photo or document delivery → Telegram Bot API: sends report (evidence: `README.md`)
