# kushdoshi07/result-finder-telegram-bot architecture

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

- Interactive diagram: https://gitdiagram.com/kushdoshi07/result-finder-telegram-bot
- Repository: https://github.com/kushdoshi07/result-finder-telegram-bot

## Overview

##### Project type and purpose
- This is a small, single-service Telegram bot written in Python.
- Purpose: accept a student’s seat number via Telegram, fetch exam results from a university website, parse the HTML, and return structured data (SGPA, CGPA, backlogs, pass/fail).

##### File structure
- Top level only:
- README.md – project description, use cases
- bot.py – the entire application logic lives here
- No DB or cache directory, no separate modules; everything is in one Python script.

##### Extract insights from the README
- Features:
- Result Lookup command
- Inline button interface to choose which metric to display
- Customizable to other university systems
- Underlying libraries likely used (not shown in file tree) include:
- python-telegram-bot (or similar) for Telegram API
- requests or aiohttp for HTTP fetch
- BeautifulSoup or lxml for HTML parsing

##### Main components
a. Telegram User (mobile or desktop app)
b. Telegram Bot API (cloud-hosted Telegram service)
c. Bot Application (bot.py)
– Update Handler / Dispatcher
– Command Handlers (/start, /result, etc.)
– Inline Button Handler
– Result Fetcher Module
- HTTP Client
- HTML Parser
- Data Extractor
– Response Formatter
d. University Website (external HTTP endpoint)

##### Relationships / data flow
1. User ► sends message/command ► Telegram API
2. Telegram API ► forwards update ► Bot Application
3. Bot Application ► issues HTTP GET/POST ► University Website
4. University Website ► returns HTML ► Bot Application
5. Bot Application ► parses & formats ► Telegram API
6. Telegram API ► delivers message ► User

##### Architectural patterns & design principles
- Single-process microservice
- Event-driven command handler pattern
- Separation of concerns inside bot.py:
- API layer (Telegram)
- Service layer (fetch & parse)
- Presentation layer (format response)
- Dependency on two external services: Telegram API and university result site

##### Relevant technologies/frameworks
- Python 3.x
- python-telegram-bot (or Telethon/aiogram)
- requests or aiohttp
- BeautifulSoup4 or lxml

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Entities
    User["Telegram User"]:::external
    API["Telegram API"]:::external
    UNI["University Website"]:::external
    README["Project Documentation\n(README.md)"]:::doc

    %% Bot Service Container
    subgraph "Bot Service"
        UH["Update Handler"]:::internal
        CH["Command Handlers"]:::internal
        IB["Inline Button Handler"]:::internal
        subgraph "Result Fetcher"
            HC["HTTP Client"]:::internal
            HP["HTML Parser"]:::internal
            DE["Data Extractor"]:::internal
        end
        RF["Response Formatter"]:::internal
    end

    %% Data Flows
    User -->|"User Command"| API
    API -->|"Update"| UH
    UH -->|"Dispatch"| CH
    CH -->|"fetch result"| HC
    IB -->|"fetch result"| HC
    HC -->|"HTML Response"| HP
    HP -->|"Parsed DOM"| DE
    DE -->|"Structured Data"| RF
    RF -->|"Telegram Message"| API
    API -->|"Deliver Message"| User

    %% Click Events
    click README "https://github.com/kushdoshi07/result-finder-telegram-bot/blob/main/README.md"
    click UH "https://github.com/kushdoshi07/result-finder-telegram-bot/blob/main/bot.py"
    click CH "https://github.com/kushdoshi07/result-finder-telegram-bot/blob/main/bot.py"
    click IB "https://github.com/kushdoshi07/result-finder-telegram-bot/blob/main/bot.py"
    click HC "https://github.com/kushdoshi07/result-finder-telegram-bot/blob/main/bot.py"
    click HP "https://github.com/kushdoshi07/result-finder-telegram-bot/blob/main/bot.py"
    click DE "https://github.com/kushdoshi07/result-finder-telegram-bot/blob/main/bot.py"
    click RF "https://github.com/kushdoshi07/result-finder-telegram-bot/blob/main/bot.py"

    %% Styles
    classDef external fill:#ccffcc,stroke:#2d702d,stroke-width:1px
    classDef internal fill:#cce0ff,stroke:#1f4e79,stroke-width:1px
    classDef doc fill:#fff2cc,stroke:#7a4300,stroke-width:1px
```
