# i7mada249/ipynb-creator-bot architecture

> Architecture diagram of the GitHub repository i7mada249/ipynb-creator-bot, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/i7mada249/ipynb-creator-bot
- Repository: https://github.com/i7mada249/ipynb-creator-bot

## Overview

##### Project type and purpose
- This is a single-service Telegram Bot written in Python.
- Purpose: receive text messages, parse them into Jupyter notebook cells, generate both a `.ipynb` file and a PDF, then send them back to the user.

##### File structure
- Top level:
- bot.py – the sole entry point and main logic
- requirements.txt – lists all Python dependencies (telegram API, nbformat, nbconvert, FPDF, Pillow, arabic-reshaper, python-bidi)
- Dockerfile – containerization config
- README.md, LICENSE, .gitattributes
- No frontend, database, or multiple microservices—everything lives in one process.

##### Extract architectural insights from the README
- External dependency: Telegram Bot API (python-telegram-bot)
- Core functionality layers:
- Message handling & dispatch
- Text-to-cell parsing (delimiter-based)
- Notebook assembly (nbformat)
- PDF export (nbconvert / FPDF / Pillow)
- RTL language support (arabic-reshaper, python-bidi)
- Deployment: environment variable for BOT_TOKEN, optional Docker container.

## Diagram (Mermaid)

```mermaid
flowchart TD
    User["Telegram User"]:::external
    TelegramAPI["Telegram Cloud/API"]:::external

    subgraph BotServiceContainer["Bot Service (Container)"]
        direction TB
        MsgReceiver["Message Receiver"]:::internal
        Parser["Parser Module"]:::internal
        RTL["RTL Support Layer"]:::internal
        NotebookGen["Notebook Generator"]:::internal
        PDFConv["PDF Converter"]:::internal
        Config["Config (BOT_TOKEN)"]:::config
        Requirements["requirements.txt"]:::config
        DockerfileNode["Dockerfile"]:::config
        README["README.md"]:::config
    end

    User -->|"send message"| TelegramAPI
    TelegramAPI -->|"webhook/getUpdates"| MsgReceiver
    MsgReceiver -->|"text payload"| Parser
    Parser -->|"processed text"| RTL
    RTL -->|"reshaped cells"| NotebookGen
    NotebookGen -->|"notebook object"| PDFConv
    PDFConv -->|".ipynb + PDF"| TelegramAPI
    TelegramAPI -->|"deliver files"| User

    click MsgReceiver "https://github.com/i7mada249/ipynb-creator-bot/blob/main/bot.py"
    click Parser "https://github.com/i7mada249/ipynb-creator-bot/blob/main/bot.py"
    click RTL "https://github.com/i7mada249/ipynb-creator-bot/blob/main/bot.py"
    click NotebookGen "https://github.com/i7mada249/ipynb-creator-bot/blob/main/bot.py"
    click PDFConv "https://github.com/i7mada249/ipynb-creator-bot/blob/main/bot.py"
    click DockerfileNode "https://github.com/i7mada249/ipynb-creator-bot/tree/main/Dockerfile"
    click Requirements "https://github.com/i7mada249/ipynb-creator-bot/blob/main/requirements.txt"
    click README "https://github.com/i7mada249/ipynb-creator-bot/blob/main/README.md"

    classDef external fill:#1f77b4,stroke:#000,color:#fff;
    classDef internal fill:#2ca02c,stroke:#000,color:#fff;
    classDef config fill:#ff7f0e,stroke:#000,color:#fff;
```
