# arun017s/autodelete architecture

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

- Interactive diagram: https://gitdiagram.com/arun017s/autodelete
- Repository: https://github.com/arun017s/autodelete

## Overview

AutoDelete is a Telegram bot that queues eligible chat messages for deletion after a configured delay. Its main process filters messages and records their expiry; a separately launched worker polls due records, deletes the Telegram messages, and removes processed records. Configuration supplies the chat, timing, and user-list settings, while a small Flask route provides a health page. The README also documents user-account and bot-only variants; the sampled code shows the user-account mode. Connections reflect the shown calls and launches.

Main entry points: [`main.py`](https://github.com/arun017s/autodelete/blob/main/main.py) (Message listener), [`utils/delete.py`](https://github.com/arun017s/autodelete/blob/main/utils/delete.py) (Expiry worker), [`utils/database.py`](https://github.com/arun017s/autodelete/blob/main/utils/database.py) (Message repository), [`utils/info.py`](https://github.com/arun017s/autodelete/blob/main/utils/info.py) (Runtime settings)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingestion["Message intake"]
  node_main["Message listener<br/>[main.py]"]
end

subgraph group_state["Configuration and state"]
  node_settings["Runtime settings<br/>[info.py]"]
  node_database["Message repository<br/>[database.py]"]
end

subgraph group_deletion["Expiry processing"]
  node_worker["Expiry worker<br/>[delete.py]"]
end

subgraph group_health["Health endpoint"]
  node_health_server["Health route<br/>[server.py]"]
end

node_telegram_users(("Telegram users"))
node_telegram_api(("Telegram API"))
node_mongo[("MongoDB")]
node_health_client(("HTTP client"))

node_telegram_users -->|"send messages"| node_main
node_main -->|"reads settings"| node_settings
node_main -->|"saves expiry"| node_database
node_database -->|"writes records"| node_mongo
node_main -->|"launches worker"| node_worker
node_worker -->|"reads settings"| node_settings
node_worker -->|"queries and clears"| node_database
node_database -->|"reads and deletes"| node_mongo
node_worker -->|"deletes messages"| node_telegram_api
node_telegram_api -.->|"deletion takes effect"| node_telegram_users
node_main -->|"launches server"| node_health_server
node_health_client -.->|"requests page"| node_health_server

click node_main "https://github.com/arun017s/autodelete/blob/main/main.py"
click node_settings "https://github.com/arun017s/autodelete/blob/main/utils/info.py"
click node_database "https://github.com/arun017s/autodelete/blob/main/utils/database.py"
click node_worker "https://github.com/arun017s/autodelete/blob/main/utils/delete.py"
click node_health_server "https://github.com/arun017s/autodelete/blob/main/utils/server.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_main,node_telegram_users,node_health_client toneBlue
class node_settings,node_database,node_mongo toneAmber
class node_worker,node_telegram_api toneMint
class node_health_server toneRose
```

## Components

### Message intake

- [Message listener](https://github.com/arun017s/autodelete/blob/main/main.py): `main.py`

### Configuration and state

- [Runtime settings](https://github.com/arun017s/autodelete/blob/main/utils/info.py): `utils/info.py`
- [Message repository](https://github.com/arun017s/autodelete/blob/main/utils/database.py): `utils/database.py`

### Expiry processing

- [Expiry worker](https://github.com/arun017s/autodelete/blob/main/utils/delete.py): `utils/delete.py`

### Health endpoint

- [Health route](https://github.com/arun017s/autodelete/blob/main/utils/server.py): `utils/server.py`

### Other components

- **Telegram users**
- **Telegram API**
- **MongoDB**
- **HTTP client**

## Connections

- Telegram users → Message listener: send messages (evidence: `main.py`)
- Message listener → Runtime settings: reads settings (evidence: `main.py`)
- Message listener → Message repository: saves expiry (evidence: `main.py`)
- Message repository → MongoDB: writes records (evidence: `utils/database.py`)
- Message listener → Expiry worker: launches worker (evidence: `main.py`)
- Expiry worker → Runtime settings: reads settings (evidence: `utils/delete.py`)
- Expiry worker → Message repository: queries and clears (evidence: `utils/delete.py`)
- Message repository → MongoDB: reads and deletes (evidence: `utils/database.py`)
- Expiry worker → Telegram API: deletes messages (evidence: `utils/delete.py`)
- Telegram API → Telegram users: deletion takes effect
- Message listener → Health route: launches server (evidence: `main.py`)
- HTTP client → Health route: requests page
