# bipinkrish/link-bypasser-bot architecture

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

- Interactive diagram: https://gitdiagram.com/bipinkrish/link-bypasser-bot
- Repository: https://github.com/bipinkrish/link-bypasser-bot

## Overview

##### Project type and purpose
- This is a hybrid full-stack Python application combining:
– A Telegram Bot interface (uses Bot API to receive commands and send messages)
– A lightweight Web UI (Flask or similar serving an HTML template)
– A “bypass engine” that fetches/decodes ad-protected URLs and paywalls
– A public cache layer (hosted on DBHub) for storing/resolving bypassed results

##### File structure
Top-level artifacts:
- app.py / main.py – entrypoints (start Web server and Bot handlers)
- bypasser.py, freewall.py – core bypassing logic modules for different sites
- db.py, ddl.py – database layer / schema creation for caching in DBHub
- config.json + environment variables – secrets for Telegram API, external cookies, DBHub API
- templates/index.html – Web UI template
- texts.py – static definitions (supported sites, help text)
- Dockerfile, Procfile, runtime.txt, app.json – deployment descriptors (Heroku, Docker)

##### README insights
- Dual-mode operation: Telegram Bot commands (/start, /help) and a minimal web page
- Public caching on DBHub: first check DBHub for an existing result → if absent, run bypass logic → store result back to DBHub
- Supports many 3rd-party hosts via per-site “crypt” tokens, cookies, or API creds

a. Main components
1. User Interfaces
– Telegram Client ←→ Telegram Bot API ←→ Bot Handler (app.py/main.py)
– Web Browser ←→ HTTP(S) ←→ Web Server Handler (app.py/main.py)
2. Application Core (monolithic process)
– Request Router (distinguishes Bot vs Web)
– Bypass Engine (bypasser.py, freewall.py, texts.py)
– Cache Layer (db.py ↔ DBHub REST API)
– Configuration Module (config.json + env vars)
3. External Services
– DBHub.io (public database via HTTP REST)
– External Link-Shortening/Paywall Hosts (various HTTP clients)
– Telegram Bot API Endpoint
4. Deployment
– Docker Container / Heroku Dyno (Procfile, Dockerfile)
– Requirements.txt / runtime.txt define Python runtime and dependencies

b. Relationships & data flows
- User sends a link to the Telegram Bot or Web Form → Request Router
- Router checks Cache Layer (db.py calls DBHub API “GET /bipinkrish/link_bypass.db?link=…”)
– If hit → return cached direct link
– If miss → route to Bypass Engine
- Bypass Engine loads the correct module (bypasser.py, freewall.py, etc.), supplies crypt/token, makes HTTP calls to the target site, parses the direct link
- On success → push result to Cache Layer (db.py calls DBHub API “PUT /…”), then return result to user via Bot API or render HTML
- Errors / unsupported sites produce help text from texts.py

c. Architectural patterns & design principles
– Monolithic modular design: each bypasser in its own module
– Single responsibility:
- db.py & ddl.py handle cache interactions and schema
- bypasser modules handle scraping/parsing logic
- app.py/main.py coordinate interfaces and routing
– Configuration‐by‐environment: credentials and site tokens loaded from config.json or env vars
– CI/CD / Deployment descriptors decoupled from code

d. Key technologies & frameworks
– Python 3.x
– Flask (or similar) for Web UI
– python-telegram-bot or Pyrogram for Telegram integration
– requests / httpx for external HTTP calls
– DBHub public REST API for caching
– Docker, Heroku (Procfile), Replit (app.json)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User Interfaces
    subgraph "User Interfaces"
        TelegramClient["Telegram Client"]:::ui
        WebBrowser["Web Browser"]:::ui
        TelegramClient -->|Telegram API| RequestRouter
        WebBrowser -->|HTTPS| RequestRouter
    end

    %% Application Core
    subgraph "Application Core"
        RequestRouter["App Server\n(app.py / main.py)"]:::core
        ConfigModule["Config Module\n(config.json + env vars)"]:::config
        BypassEngine["Bypass Engine\n(bypasser.py)"]:::core
        SiteModules["Site Modules\n(freewall.py, etc.)"]:::core
        DBInterface["db.py"]:::cache
        SchemaDef["ddl.py"]:::cache
        Texts["Static Texts\n(texts.py)"]:::core
        WebTemplate["Web UI Template\n(templates/index.html)"]:::ui

        RequestRouter -->|uses| ConfigModule
        RequestRouter -->|routes to| BypassEngine
        RequestRouter -->|renders| WebTemplate
        RequestRouter -->|fetches help| Texts
        BypassEngine -->|loads modules| SiteModules
        BypassEngine -->|reads config| ConfigModule
        BypassEngine -->|fetches help| Texts
        RequestRouter -->|checks cache| DBInterface
        DBInterface -->|uses schema| SchemaDef
    end

    %% External Services
    subgraph "External Services"
        TelegramAPI["Telegram Bot API"]:::external
        PaywallHosts["Paywall/Host Sites"]:::external
        DBHub["DBHub.io\nPublic Cache"]:::external

        TelegramClient -->|API calls| TelegramAPI
        RequestRouter -->|Bot messages| TelegramAPI
        BypassEngine -->|HTTPS| PaywallHosts
        DBInterface -->|REST GET/PUT| DBHub
    end

    %% Deployment
    subgraph "Deployment"
        Container["Docker Container\n/ Heroku Dyno"]:::deployment
        DockerFile["Dockerfile"]:::deployment
        ProcfileNode["Procfile"]:::deployment
        AppSpec["app.json"]:::deployment
        RuntimeSpec["runtime.txt"]:::deployment
        Requirements["requirements.txt"]:::deployment

        Container --> RequestRouter
        Container --> BypassEngine
        Container --> DBInterface
        Container --> DockerFile
        Container --> ProcfileNode
        Container --> AppSpec
        Container --> RuntimeSpec
        Container --> Requirements
    end

    %% Click Events
    click RequestRouter "https://github.com/bipinkrish/link-bypasser-bot/blob/main/app.py"
    click RequestRouter "https://github.com/bipinkrish/link-bypasser-bot/blob/main/main.py"
    click BypassEngine "https://github.com/bipinkrish/link-bypasser-bot/blob/main/bypasser.py"
    click SiteModules "https://github.com/bipinkrish/link-bypasser-bot/blob/main/freewall.py"
    click DBInterface "https://github.com/bipinkrish/link-bypasser-bot/blob/main/db.py"
    click SchemaDef "https://github.com/bipinkrish/link-bypasser-bot/blob/main/ddl.py"
    click ConfigModule "https://github.com/bipinkrish/link-bypasser-bot/blob/main/config.json"
    click Texts "https://github.com/bipinkrish/link-bypasser-bot/blob/main/texts.py"
    click WebTemplate "https://github.com/bipinkrish/link-bypasser-bot/blob/main/templates/index.html"
    click DockerFile "https://github.com/bipinkrish/link-bypasser-bot/tree/main/Dockerfile"
    click ProcfileNode "https://github.com/bipinkrish/link-bypasser-bot/tree/main/Procfile"
    click AppSpec "https://github.com/bipinkrish/link-bypasser-bot/blob/main/app.json"
    click RuntimeSpec "https://github.com/bipinkrish/link-bypasser-bot/blob/main/runtime.txt"
    click Requirements "https://github.com/bipinkrish/link-bypasser-bot/blob/main/requirements.txt"

    %% Styles
    classDef ui fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef core fill:#90EE90,stroke:#333,stroke-width:1px
    classDef cache fill:#FFA500,stroke:#333,stroke-width:1px
    classDef external fill:#D3D3D3,stroke:#333,stroke-width:1px
    classDef config fill:#FFFF99,stroke:#333,stroke-width:1px
    classDef deployment fill:#D8BFD8,stroke:#333,stroke-width:1px
```
