Use PythonAnywhere (you already have subix.pythonanywhere.com).
# On PythonAnywhere Bash:
cd /home/subix/mybot
git pull origin main
source ~/.virtualenvs/subix/bin/activate
/home/subix/.virtualenvs/subix/bin/pip install -r backend/requirements.txtWeb tab settings:
| Setting | Value |
|---|---|
| Source / Working dir | /home/subix/mybot/backend |
| Python | 3.10 |
| Virtualenv | /home/subix/.virtualenvs/subix |
.env at /home/subix/mybot/backend/.env:
BOT_TOKEN=...
SECRET_KEY=...
TURSO_URL=https://subixdb-lumaticgroup.aws-eu-west-1.turso.io
TURSO_AUTH_TOKEN=...
FRONTEND_URL=https://abbasiandev.github.io/Subix
ENABLE_WEBHOOK=false
DEBUG=falseWSGI file /var/www/subix_pythonanywhere_com_wsgi.py — copy from backend/deploy/pythonanywhere_wsgi.py
Click Reload → test: https://subix.pythonanywhere.com/health
Seed products once from your PC: cd backend && python -m scripts.seed
- GitHub Secrets →
API_URL=https://subix.pythonanywhere.com - Actions → Deploy Frontend → GitHub Pages → Run workflow
- Site:
https://abbasiandev.github.io/Subix/
BotFather (manual):
- Menu Button → URL:
https://abbasiandev.github.io/Subix/ - Menu Button text:
🛒 فروشگاه سابیکس
/start message and inline buttons come from the backend (backend/app/telegram/handlers.py). They only work if the webhook is enabled.
On PythonAnywhere, in /home/subix/mybot/backend/.env:
ENABLE_WEBHOOK=true
WEBHOOK_URL=https://subix.pythonanywhere.com/webhookReload the web app, then register the webhook once:
cd /home/subix/mybot/backend
source ~/.virtualenvs/subix/bin/activate
python -m scripts.setup_webhookIf you get httpx.ProxyError on PythonAnywhere, set the webhook from your Mac (replace TOKEN):
curl -sS "https://api.telegram.org/botTOKEN/setWebhook" \
-d "url=https://subix.pythonanywhere.com/webhook" \
-d "drop_pending_updates=true"You should see "ok":true. Then send /start in Telegram.
| Layer | Tool | Host |
|---|---|---|
| Frontend | Next.js 14 (static export) | GitHub Pages |
| Backend | FastAPI + httpx | PythonAnywhere (free) |
| Database | Turso (libSQL) | Turso Cloud |
Telegram User
│
▼
aiogram v3 (bot webhook)
│
▼
FastAPI (REST API)
│
├── /api/v1/auth ← Telegram login widget / initData
├── /api/v1/products ← list, detail
├── /api/v1/orders ← create, list, detail
├── /api/v1/wallet ← balance, topup
└── /api/v1/users ← profile
│
▼
Turso (libSQL — SQLite edge DB)
- User opens Mini App via bot button
Telegram.WebApp.initDatasent to/api/v1/auth/telegram- Backend verifies HMAC signature (no password, no OTP)
- User auto-created on first login using
telegram_id+phone_number - JWT returned → stored in memory (no localStorage)
cd backend
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
cp .env.example .env # fill in your values
uvicorn app.main:app --reloadcd frontend
npm install
cp .env.local.example .env.local
npm run devOpen http://localhost:3000 while developing. The frontend is a Next.js static export; GitHub Pages publishes the generated frontend/out directory under /Subix/.
The homepage hero is split into three layers:
- A semantic text layer that renders immediately and remains usable without JavaScript or WebGL.
- A CSS grid and gradient fallback that supplies the visual atmosphere on unsupported or low-power devices.
- A lazily initialized Three.js scene with a fresnel/noise shader shell, orbital geometry, and a pointer-reactive particle field.
The scene caps device pixel ratio at 2, pauses when the tab is hidden or the hero is off screen, follows scroll and pointer position, and disposes its geometries and materials on teardown. Reduced-motion preferences slow the scene and remove CSS motion effects.
To intentionally use the static fallback during local development:
cd frontend
NEXT_PUBLIC_DISABLE_WEBGL=1 npm run devThe same flag can be supplied to the production build when a deployment should omit the WebGL renderer:
NEXT_PUBLIC_DISABLE_WEBGL=1 npm run buildsubix/
├── backend/
│ ├── app/
│ │ ├── main.py ← FastAPI app entry
│ │ ├── core/
│ │ │ ├── config.py ← settings (pydantic-settings)
│ │ │ ├── security.py ← JWT + Telegram HMAC verify
│ │ │ └── deps.py ← FastAPI dependencies
│ │ ├── db/
│ │ │ ├── client.py ← Turso libSQL client
│ │ │ └── migrations.py ← table creation
│ │ ├── models/ ← SQLAlchemy-style dataclasses
│ │ ├── schemas/ ← Pydantic v2 schemas
│ │ ├── services/ ← business logic
│ │ ├── api/v1/
│ │ │ └── endpoints/ ← route handlers
│ │ └── bot/
│ │ ├── main.py ← aiogram app
│ │ ├── handlers/ ← message/callback handlers
│ │ ├── keyboards/ ← inline + reply keyboards
│ │ └── middlewares/ ← auth, throttle
│ ├── tests/
│ ├── requirements.txt
│ └── .env.example
└── frontend/
├── pages/
│ ├── index.tsx ← store (فروشگاه)
│ ├── profile.tsx ← profile (پروفایل)
│ ├── dashboard.tsx ← dashboard (داشبورد)
│ └── contact.tsx ← contact (تماس با ما)
├── components/
├── styles/
├── next.config.js
└── package.json