Skip to content
VarshuDevPublic

Latest commit

 

History

55 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TapBot Autonomous On-Device Telegram Bot Runner Header

Decentralized On-Device Telegram Bot Runner, Hardware Commander & Edge Bot Store.

Android 10+ Kotlin 2.0 Compose M3 Cloudflare Edge Apache 2.0

Why TapBot?  •  Architecture  •  Commander Bot  •  Security  •  Edge Store  •  Benchmarks  •  Quickstart


Why TapBot?

Traditional Telegram bot hosting forces developers and power users into recurring compromises: costly cloud VPS subscriptions (AWS, DigitalOcean, Heroku), complex serverless webhook configurations, and centralized credential exposure on third-party cloud infrastructure.

TapBot flips the hosting paradigm by turning any modern Android device into an autonomous 24/7 Telegram bot server:

  1. Zero Cloud Infrastructure Costs: Run multiple production bots entirely on physical Android hardware or spare smartphones with $0/month in cloud server bills.
  2. True Data Sovereignty: Bot tokens, private chat histories, and sensitive user data remain strictly localized inside your device's encrypted storage sandbox.
  3. NAT & Firewall Piercing: Uses outbound HTTPS long-polling (getUpdates) on port 443. No public IP address, static DNS, port forwarding, or domain certificates required.
  4. Negligible Resource Overhead: Native Android ART coroutine execution requires only 8 MB – 12 MB RAM per bot instance with < 0.1% CPU utilization during idle polling.
  5. Survives OS Power Management: Engineered with a hardened Android Foreground Service and wake-lock management that persists across Doze Mode, screen-off cycles, and network handovers.

Architecture & Pipeline

TapBot coordinates a hybrid decentralized architecture linking local Android execution with serverless edge catalog distribution:

TapBot System Architecture Diagram

  • Telegram Bot API Link: High-efficiency HTTP client maintaining persistent TLS 1.3 connections to Telegram edge clusters.
  • Android ART Runtime: Coroutine-based engine dispatching bot updates concurrently with zero subprocess overhead.
  • Hardware Security Layer: Hardware-backed Android Keystore (AES-256-GCM) via StrongBox / TEE.
  • Cloudflare Edge Store: Decentralized .botpkg repository powered by Cloudflare Workers, Cloudflare D1 (SQLite), and Cloudflare R2 object storage.

Flagship Commander Bot & Device Actions

TapBot includes the pre-installed Commander Bot, turning your Android phone into an interactive, remotely controlled hardware node managed entirely via Telegram chat:

Telegram Command Hardware / System Action Execution Boundary
/status Returns live diagnostics: battery %, charging state, CPU thermal status, RAM consumption, and network connection type DeviceTelemetryProvider
/torch on|off Toggles the physical device camera LED flashlight remotely via Android CameraManager DeviceActionController
/vibrate [ms] Triggers haptic vibration sequences on the target hardware via Android Vibrator DeviceActionController
/notify [msg] Posts custom high-priority notification banners to the Android system notification tray NotificationHelper
/apk Streams the latest signed TapBot APK binary directly into the Telegram chat for instant field distribution ApkDeliveryService
/fleet Lists all active, idle, and stopped bots hosted on the device with one-tap start/stop controls FleetCommandRouter

Autonomous Watchdog Coroutine

The on-device DeviceWatchdog operates in the background:

  • Continuously polls battery thresholds and thermal sensor states.
  • Auto-restarts stalled or unresponsive bot coroutines.
  • Pushes real-time Telegram alerts to the device owner if battery drops below 15% or hardware temperatures exceed thermal limits.

Hardware-Backed Security

TapBot applies strict defense-in-depth principles across the native Android operating system:

  • Hardware Keystore Master Keys: Encryption keys are generated inside device hardware security modules (TEE / StrongBox) using AES-256-GCM with 128-bit authentication tags. Master keys are non-exportable from hardware.
  • Zero-Leak Secret Redaction: All internal logs, stack traces, and debug streams pass through an active SecretRedactor pipeline that scrubs Telegram bot tokens (1234****:[REDACTED_TELEGRAM_TOKEN]) before writing to disk or displaying in UI.
  • Android W^X & SELinux Hardening: Operates 100% within native Android ART memory space without spawning arbitrary shell binaries or executing dynamically generated native machine code.
  • Zero Third-Party Telemetry: Contains zero tracking SDKs, advertising libraries, or cloud telemetry hooks. Your bot tokens never transit any server other than official Telegram API endpoints.

Atomic Version Management & .botpkg Format

TapBot packages are distributed as cryptographically signed .botpkg archives containing bytecode definitions, assets, and strict dependency declarations.

State-Machine Update Pipeline

Package updates execute through an atomic state machine guaranteeing zero downtime or corrupted installations:

[ CHECKING ] ───► [ DOWNLOADING ] ───► [ VERIFYING ] ───► [ INSTALLING ] ───► [ STARTING ] ───► [ SUCCESS ]
                                                                                   │
                                                                           (Startup Failure)
                                                                                   │
                                                                                   ▼
                                                                           [ ROLLING_BACK ] ───► [ RESTORED ]
  • SHA-256 Checksum Verification: Every package payload is verified against tamper-evident cryptographic digests before unpacking.
  • Anti-Downgrade Defense: Rejects malicious or accidental downgrade payloads attempting to replace secure versions with older builds.
  • Isolated State Retention: Runtime configurations, owner tokens, and persistent databases remain untouched during updates and rollbacks.

Edge Bot Store & Cloudflare Backend

The ecosystem is backed by an edge-native catalog server built on Cloudflare Workers:

  • Serverless REST API: Global sub-50ms catalog resolution via Cloudflare Workers (/api/v1/bots).
  • Cloudflare D1 Relational Catalog: Serverless SQLite database managing bot metadata, author signatures, release channels, and installation counts.
  • Cloudflare R2 Object Storage: High-durability zero-egress bucket storage for .botpkg binary distributions.
  • Dark Ops Admin HUD (/admin): Single-Page App administrative console for developers to publish packages, inspect audit logs, and toggle release visibility.

Performance Benchmarks

Empirical performance measurements comparing TapBot on native Android ART against standard server hosting alternatives:

Metric TapBot (On-Device ART) Python 3.12 (VPS) Node.js 20 (VPS) Docker Container
RAM Footprint (per bot) 8 MB – 12 MB 60 MB – 85 MB 90 MB – 140 MB 180 MB+
Cold Startup Latency < 50 ms ~450 ms ~680 ms ~1,800 ms
Idle CPU Utilization < 0.1% 0.8% – 1.5% 1.2% – 2.4% 2.5%+
Network Architecture HTTPS Long-Poll (Outbound) Webhook / Polling Webhook / Polling Webhook Relay
Firewall / Port Forwarding None Required Public IP / Port 443 Public IP / Port 443 Reverse Proxy
Monthly Infrastructure Cost $0.00 / month $5.00 – $20.00 / mo $5.00 – $20.00 / mo $10.00+ / mo

Quickstart

Prerequisites

  • Android Studio Jellyfish / Koala (or IntelliJ IDEA with Android plugin)
  • JDK 17 or higher
  • Android physical device or emulator running Android 10+ (API 29 – 35)

1. Clone & Open

# Clone the repository
git clone https://github.com/VarshuDev/tapbot.git

# Enter the project directory
cd tapbot

Open the project in Android Studio and let Gradle sync.

2. Build via Command Line

# Run unit and coroutine test suites
./gradlew test

# Compile release APK
./gradlew assembleRelease

Generated APKs will be output to app/build/outputs/apk/release/.

3. Deploy Cloudflare Edge Backend (Optional)

cd backend

# Install dependencies
npm install

# Initialize local D1 SQLite database
npx wrangler d1 execute tapbot-db --local --file=schema.sql

# Deploy to Cloudflare Edge
npx wrangler deploy

Pre-Built Bot Runtime Library

TapBot includes out-of-the-box runtimes for immediate deployment:

  • CommanderBotRuntime: Flagship device control, hardware sensors, and /apk binary delivery.
  • AIBotRuntime: Conversational intelligence powered by lightweight API endpoints.
  • ExonBotRuntime: Advanced Telegram supergroup management, anti-flood, and role moderation.
  • MusicBotRuntime: Audio stream search, metadata lookup, and playback control.
  • PingPongBotRuntime: Minimalist low-latency heartbeat responder.

Author & Credits

Architected, engineered, and maintained by VarshuDev.

If you find TapBot useful for running autonomous bots or managing Android hardware nodes, consider starring the repository!

Distributed under the Apache 2.0 License.

Releases

Packages

Contributors

Languages