# miiloudz/aliexpress-affiliate-telegram-bot architecture

> Architecture diagram of the GitHub repository miiloudz/aliexpress-affiliate-telegram-bot, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-08-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/miiloudz/aliexpress-affiliate-telegram-bot
- Repository: https://github.com/miiloudz/aliexpress-affiliate-telegram-bot

## Overview

##### Project type and purpose
- This is a small‐scale Telegram chatbot (“AliExpress Affiliate Telegram BOT”) written in Python.
- Its primary function is to receive commands from end users over Telegram, call the AliExpress Affiliate API to fetch product links and details, and send the results back to the user.

##### File structure
- Top level:
- .github/workflows/fly-deploy.yml → CI/CD pipeline for deploying the bot (presumably to Fly.io or a similar host)
- bot.py → Main bot logic: initializes the Telegram client, listens for commands, calls the API wrapper, formats responses.
- keep_alive.py → A minimal web server or ping responder to prevent idling on certain hosting platforms.
- requirements.txt → Dependencies: telebot, python-aliexpress-api, etc.
- No database or persistent storage directories—this is a stateless bot relying solely on external APIs and Telegram.

##### README for additional insights
- It lists out the bot’s features (get_affiliate_links, get_promotion_products, etc.).
- It requires environment variables or config for: Telegram Bot Token, AliExpress API key, and an optional tracking ID.
- Installation plus deployment hints (CI workflow, keep_alive for uptime).

##### Final recommendation
- Every file’s runtime role: “bot.py” for commands, “keep_alive.py” for uptime, “fly-deploy.yml” for CI/CD.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Entities
    User["User"]:::external
    Telegram["Telegram Platform"]:::external
    AliExpress["AliExpress Affiliate API"]:::external
    Hosting["Hosting Platform"]:::external

    %% Bot Server Subgraph
    subgraph "Bot Server"
        direction TB
        BotClient["Telegram Bot Client & Command Handlers"]:::internal
        Wrapper["AliExpress API Wrapper"]:::internal
        KeepAlive["Keep Alive HTTP Endpoint"]:::internal
    end

    %% CI/CD Subgraph
    subgraph "CI/CD Pipeline"
        direction TB
        Actions["GitHub Actions"]:::ci
        Fly["Fly.io Deployment"]:::ci
    end

    %% Documentation Subgraph
    subgraph "Project Artifacts"
        direction TB
        Requirements["requirements.txt"]:::docs
        Readme["README.md"]:::docs
    end

    %% Main Interaction Flow
    User -->|"sends command"| Telegram
    Telegram -->|"forwards update"| BotClient
    BotClient -->|"calls Alias Wrapper"| Wrapper
    Wrapper -->|"HTTPS request"| AliExpress
    AliExpress -->|"returns data"| Wrapper
    Wrapper -->|"formatted response"| BotClient
    BotClient -->|"sendMessage/sendPhoto"| Telegram
    Telegram -->|"delivers message"| User

    %% Keep Alive Uptime Flow
    Hosting -->|"ping"| KeepAlive

    %% CI/CD Flow
    Actions -->|"deploy on push"| Fly
    Fly -->|"hosts Bot Server"| BotClient
    Fly -->|"hosts Bot Server"| KeepAlive

    %% Click Events
    click BotClient "https://github.com/miiloudz/aliexpress-affiliate-telegram-bot/blob/main/bot.py"
    click Wrapper "https://github.com/miiloudz/aliexpress-affiliate-telegram-bot/blob/main/bot.py"
    click KeepAlive "https://github.com/miiloudz/aliexpress-affiliate-telegram-bot/blob/main/keep_alive.py"
    click Actions "https://github.com/miiloudz/aliexpress-affiliate-telegram-bot/blob/main/.github/workflows/fly-deploy.yml"
    click Requirements "https://github.com/miiloudz/aliexpress-affiliate-telegram-bot/blob/main/requirements.txt"
    click Readme "https://github.com/miiloudz/aliexpress-affiliate-telegram-bot/blob/main/README.md"

    %% Styles
    classDef external fill:#AEDFF7,stroke:#0288D1,color:#000
    classDef internal fill:#C8E6C9,stroke:#2E7D32,color:#000
    classDef ci fill:#FFF9C4,stroke:#F9A825,color:#000
    classDef docs fill:#E0E0E0,stroke:#616161,color:#000
```
