FreeByte is a Python-based Telegram platform for selling and managing VPN services and virtual phone numbers, with wallet payments, referrals, admin tooling, and webhook-powered automations.
It combines three runtime components:
- Telegram Bot (main user/admin interface)
- FastAPI WebApp (payment callbacks and service webhooks)
- Celery Worker (background payment processing and notifications)
- Multi-service Telegram bot built on
python-telegram-bot - VPN purchase, upgrade, revoke, and usage/statistics flows
- Virtual number purchase + SMS retrieval workflow
- Wallet and payment integrations (ZarinPal + Cryptomus)
- Admin operations panel flows and ticket/support handling
- SQLAlchemy data layer over PostgreSQL
- Scheduled tasks for notifications and maintenance
- Language: Python
- Bot framework:
python-telegram-bot - API framework: FastAPI + Jinja templates
- Task queue: Celery
- ORM: SQLAlchemy
- Database: PostgreSQL
- Integrations: Telegram Bot API, ZarinPal, Cryptomus, OnlineSim
FreeByte/
├── main.py # Telegram bot entry point
├── WebAppFastApi.py # FastAPI app (payment + webhook endpoints)
├── tasks.py # Celery tasks
├── database_sqlalchemy.py # Engine/session/base setup
├── models_sqlalchemy.py # Database models
├── requirements.txt # Python dependencies
├── templates/ # Payment result HTML pages
├── admin/ # Admin handlers and utilities
├── vpn_service/ # VPN domain logic
├── virtual_number/ # Virtual number domain logic
├── dialogues/ # Localized bot texts
├── crud/ # Data access layer
└── WebApp/ # WebApp utilities and dialogues
- Python 3.10+ (recommended)
- PostgreSQL
- A running message broker for Celery (as configured in
CELERY_BROKER_URL) - Telegram bot token
- Merchant/API credentials for payment providers you enable
- Clone the repository:
git clone https://github.com/AmirHBuilds/FreeByte
cd FreeByte- Create and activate a virtual environment:
python -m venv .venv
source .venv/bin/activate # Linux/macOS
# .venv\Scripts\activate # Windows- Install dependencies:
pip install -r requirements.txtNote: If
requirements.txtencoding causes install issues in your environment, convert it to UTF-8 first, then rerun installation.
This project expects a setting.py module in the repository root (same level as main.py).
At minimum, configure values such as:
telegram_bot_tokenpostgres_urlCELERY_BROKER_URLADMIN_CHAT_IDs- Thread IDs used for admin reporting (e.g.
error_thread_id,info_thread_id, etc.) webapp_url,webapp_private_tokenzarinpal_merchant_id,zarinpal_url_callbackcryptomus_api_key,cryptomus_merchant_id,cryptomus_url_callback- Service pricing/behavior settings (e.g.
PRICE_PER_GB,PRICE_PER_DAY, warning thresholds) onlinesim_api
Use secure secret management for production (environment variables, vaults, or deployment secrets), and avoid committing real credentials.
python main.pyuvicorn WebAppFastApi:app --host 0.0.0.0 --port 8000 --reloadcelery -A tasks.celery_app worker --loglevel=infoFor production, run each component under a process manager (systemd, supervisord, Docker, Kubernetes, etc.).
- User onboarding:
/startwith language selection and optional referral handling - Wallet: credit purchase + transaction tracking
- VPN services: buy, view details, revoke/remove, and scheduled notifications
- Virtual numbers: buy numbers and receive verification SMS updates
- Payments: callback verification through FastAPI endpoints
- Background jobs: asynchronous payment handling and notification/report tasks via Celery
GET /— health checkGET /zarinpal_receive_payment_result/— ZarinPal callback handlerPOST /cryptomus_receive_payment_result/— Cryptomus callback handlerPOST /send_telegram_notification/— Telegram message relay endpointGET /onlinesim— OnlineSim SMS callback receiver
Ensure your provider callback URLs target this service correctly and are reachable from the internet (or via secure tunneling/reverse proxy).
- Logging writes to both console and
freebyte.log. - Database tables are created at bot startup (
Base.metadata.create_all(bind=engine)). - Keep long-running services isolated and monitored.
- Add migrations (Alembic) for production-grade schema evolution if not already in your deployment workflow.
- Never commit
setting.pywith real secrets. - Restrict webhook endpoints by IP, signature, token, or reverse-proxy access controls.
- Use HTTPS everywhere (especially payment callbacks).
- Rotate API keys and bot tokens periodically.
- Implement structured error tracking/alerting in production.
- Bot won’t start: verify
setting.pyexists andtelegram_bot_tokenis valid. - DB errors: check
postgres_url, DB reachability, and credentials. - Celery tasks not running: verify broker availability and
CELERY_BROKER_URL. - Payment callbacks failing: confirm public callback URL, provider credentials, and server logs.
- Missing messages/notifications: check admin thread IDs and Telegram permissions.
- Create a feature branch.
- Keep changes focused and documented.
- Test impacted flows (bot, API, and worker where applicable).
- Open a pull request with clear context and validation steps.
No explicit license file is currently included in this repository.
If you plan to distribute or open-source this project, add a LICENSE file with the desired terms.