# abedjoulany/aliexpress-deals architecture

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

- Interactive diagram: https://gitdiagram.com/abedjoulany/aliexpress-deals
- Repository: https://github.com/abedjoulany/aliexpress-deals

## Overview

This repository is an AliExpress affiliate-link Telegram bot. A user sends a product URL; the bot detects and resolves it, obtains product details, generates offer-specific affiliate links, formats a response, and sends it back through Telegram. The graph separates message handling, URL and offer processing, product/API work, and shared runtime support. Relationships for unsampled modules are limited to those supported by the README or SOURCE INDEX; the graph does not assume unshown internal calls.

Main entry points: [`telegram_bot.py`](https://github.com/abedjoulany/aliexpress-deals/blob/main/telegram_bot.py) (Message handlers), [`main.py`](https://github.com/abedjoulany/aliexpress-deals/blob/main/main.py) (Application setup), [`aliexpress_client.py`](https://github.com/abedjoulany/aliexpress-deals/blob/main/aliexpress_client.py) (AliExpress client), [`product_service.py`](https://github.com/abedjoulany/aliexpress-deals/blob/main/product_service.py) (Product service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_telegram["Telegram interaction"]
  node_bot["Message handlers<br/>[telegram_bot.py]"]
  node_formatter["Response formatting"]
end

subgraph group_urls["URL and offers"]
  node_url_processor["URL processing<br/>[url_processor.py]"]
  node_offer_strategies["Offer strategies<br/>[offers.py]"]
  node_offer_config["Offer configuration<br/>[constants.py]"]
end

subgraph group_products["Product and API"]
  node_product_service["Product service<br/>[product_service.py]"]
  node_api_client["AliExpress client"]
  node_api_errors["API error types"]
  node_product_utils["Product utilities"]
  node_iop_sdk["IOP SDK transport<br/>[base.py]"]
end

subgraph group_runtime["Runtime support"]
  node_main["Application setup<br/>[main.py]"]
  node_cache[("Expiring caches<br/>[cache_manager.py]")]
  node_keep_alive["Keep-alive server<br/>[keep_alive.py]"]
end

node_user(("Chat user"))
node_telegram_platform["Telegram platform"]
node_aliexpress_api["AliExpress Affiliate API"]

node_user -->|"sends message"| node_bot
node_bot -->|"resolves links"| node_url_processor
node_bot -->|"requests product"| node_product_service
node_bot -->|"formats response"| node_formatter
node_bot -->|"sends response"| node_telegram_platform
node_main -->|"starts bot"| node_bot
node_main -->|"constructs service"| node_product_service
node_main -->|"constructs processor"| node_url_processor
node_main -->|"constructs client"| node_api_client
node_main -->|"constructs manager"| node_cache
node_main -->|"starts server"| node_keep_alive
node_url_processor -->|"reads and writes"| node_cache
node_url_processor -->|"wraps offer URLs"| node_offer_strategies
node_offer_config -->|"defines offers"| node_offer_strategies
node_product_service -->|"fetches product"| node_api_client
node_product_service -->|"scrapes fallback"| node_product_utils
node_product_service -->|"selects offers"| node_offer_config
node_api_client -->|"uses link cache"| node_cache
node_api_client -->|"classifies failures"| node_api_errors
node_api_client -->|"executes requests"| node_iop_sdk
node_iop_sdk -.->|"sends API request"| node_aliexpress_api
node_api_client -->|"requests product and links"| node_aliexpress_api
node_bot -->|"schedules cleanup"| node_cache

click node_main "https://github.com/abedjoulany/aliexpress-deals/blob/main/main.py"
click node_bot "https://github.com/abedjoulany/aliexpress-deals/blob/main/telegram_bot.py"
click node_formatter "https://github.com/abedjoulany/aliexpress-deals/blob/main/message_formatter.py"
click node_url_processor "https://github.com/abedjoulany/aliexpress-deals/blob/main/url_processor.py"
click node_offer_strategies "https://github.com/abedjoulany/aliexpress-deals/blob/main/offers.py"
click node_offer_config "https://github.com/abedjoulany/aliexpress-deals/blob/main/constants.py"
click node_product_service "https://github.com/abedjoulany/aliexpress-deals/blob/main/product_service.py"
click node_api_client "https://github.com/abedjoulany/aliexpress-deals/blob/main/aliexpress_client.py"
click node_api_errors "https://github.com/abedjoulany/aliexpress-deals/blob/main/aliexpress_errors.py"
click node_product_utils "https://github.com/abedjoulany/aliexpress-deals/blob/main/aliexpress_utils.py"
click node_iop_sdk "https://github.com/abedjoulany/aliexpress-deals/blob/main/iop/base.py"
click node_cache "https://github.com/abedjoulany/aliexpress-deals/blob/main/cache_manager.py"
click node_keep_alive "https://github.com/abedjoulany/aliexpress-deals/blob/main/keep_alive.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_bot,node_formatter,node_user toneBlue
class node_url_processor,node_offer_strategies,node_offer_config toneAmber
class node_product_service,node_api_client,node_api_errors,node_product_utils,node_iop_sdk,node_aliexpress_api toneMint
class node_main,node_cache,node_keep_alive toneRose
class node_telegram_platform toneIndigo
```

## Components

### Telegram interaction

- [Message handlers](https://github.com/abedjoulany/aliexpress-deals/blob/main/telegram_bot.py): `telegram_bot.py`
- [Response formatting](https://github.com/abedjoulany/aliexpress-deals/blob/main/message_formatter.py): `message_formatter.py`

### URL and offers

- [URL processing](https://github.com/abedjoulany/aliexpress-deals/blob/main/url_processor.py): `url_processor.py`
- [Offer strategies](https://github.com/abedjoulany/aliexpress-deals/blob/main/offers.py): `offers.py`
- [Offer configuration](https://github.com/abedjoulany/aliexpress-deals/blob/main/constants.py): `constants.py`

### Product and API

- [Product service](https://github.com/abedjoulany/aliexpress-deals/blob/main/product_service.py): `product_service.py`
- [AliExpress client](https://github.com/abedjoulany/aliexpress-deals/blob/main/aliexpress_client.py): `aliexpress_client.py`
- [API error types](https://github.com/abedjoulany/aliexpress-deals/blob/main/aliexpress_errors.py): `aliexpress_errors.py`
- [Product utilities](https://github.com/abedjoulany/aliexpress-deals/blob/main/aliexpress_utils.py): `aliexpress_utils.py`
- [IOP SDK transport](https://github.com/abedjoulany/aliexpress-deals/blob/main/iop/base.py): `iop/base.py`

### Runtime support

- [Application setup](https://github.com/abedjoulany/aliexpress-deals/blob/main/main.py): `main.py`
- [Expiring caches](https://github.com/abedjoulany/aliexpress-deals/blob/main/cache_manager.py): `cache_manager.py`
- [Keep-alive server](https://github.com/abedjoulany/aliexpress-deals/blob/main/keep_alive.py): `keep_alive.py`

### Other components

- **Chat user**
- **Telegram platform**
- **AliExpress Affiliate API**

## Connections

- Chat user → Message handlers: sends message (evidence: `README.md`)
- Message handlers → URL processing: resolves links (evidence: `telegram_bot.py`)
- Message handlers → Product service: requests product (evidence: `telegram_bot.py`)
- Message handlers → Response formatting: formats response (evidence: `telegram_bot.py`)
- Message handlers → Telegram platform: sends response (evidence: `telegram_bot.py`)
- Application setup → Message handlers: starts bot (evidence: `main.py`)
- Application setup → Product service: constructs service (evidence: `main.py`)
- Application setup → URL processing: constructs processor (evidence: `main.py`)
- Application setup → AliExpress client: constructs client (evidence: `main.py`)
- Application setup → Expiring caches: constructs manager (evidence: `main.py`)
- Application setup → Keep-alive server: starts server (evidence: `main.py`)
- URL processing → Expiring caches: reads and writes (evidence: `url_processor.py`)
- URL processing → Offer strategies: wraps offer URLs (evidence: `url_processor.py`)
- Offer configuration → Offer strategies: defines offers (evidence: `constants.py`)
- Product service → AliExpress client: fetches product (evidence: `product_service.py`)
- Product service → Product utilities: scrapes fallback (evidence: `product_service.py`)
- Product service → Offer configuration: selects offers (evidence: `product_service.py`)
- AliExpress client → Expiring caches: uses link cache (evidence: `aliexpress_client.py`)
- AliExpress client → API error types: classifies failures (evidence: `aliexpress_client.py`)
- AliExpress client → IOP SDK transport: executes requests
- IOP SDK transport → AliExpress Affiliate API: sends API request
- AliExpress client → AliExpress Affiliate API: requests product and links (evidence: `README.md`)
- Message handlers → Expiring caches: schedules cleanup (evidence: `telegram_bot.py`)
