Decentralized On-Device Telegram Bot Runner, Hardware Commander & Edge Bot Store.
Why TapBot? •
Architecture •
Commander Bot •
Security •
Edge Store •
Benchmarks •
Quickstart
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:
- Zero Cloud Infrastructure Costs: Run multiple production bots entirely on physical Android hardware or spare smartphones with $0/month in cloud server bills.
- True Data Sovereignty: Bot tokens, private chat histories, and sensitive user data remain strictly localized inside your device's encrypted storage sandbox.
- NAT & Firewall Piercing: Uses outbound HTTPS long-polling (
getUpdates) on port 443. No public IP address, static DNS, port forwarding, or domain certificates required. - 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.
- 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.
TapBot coordinates a hybrid decentralized architecture linking local Android execution with serverless edge catalog distribution:
- 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
.botpkgrepository powered by Cloudflare Workers, Cloudflare D1 (SQLite), and Cloudflare R2 object storage.
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 |
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.
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-GCMwith 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
SecretRedactorpipeline 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.
TapBot packages are distributed as cryptographically signed .botpkg archives containing bytecode definitions, assets, and strict dependency declarations.
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.
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
.botpkgbinary distributions. - Dark Ops Admin HUD (
/admin): Single-Page App administrative console for developers to publish packages, inspect audit logs, and toggle release visibility.
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 |
- 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)
# Clone the repository
git clone https://github.com/VarshuDev/tapbot.git
# Enter the project directory
cd tapbotOpen the project in Android Studio and let Gradle sync.
# Run unit and coroutine test suites
./gradlew test
# Compile release APK
./gradlew assembleReleaseGenerated APKs will be output to app/build/outputs/apk/release/.
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 deployTapBot includes out-of-the-box runtimes for immediate deployment:
CommanderBotRuntime: Flagship device control, hardware sensors, and/apkbinary 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.
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.