A Telegram Mini App game on the TON blockchain. Earn $CUBE through daily claims and referrals, then have admins mint a generative pixel-art NFT for top holders. Includes a CUBE โ SATOSHI jetton swap and an idle-clicker mining mode.
- ๐ฎ Mini App game โ Vue 3 frontend served straight inside Telegram, with TonConnect wallet integration.
- ๐ช Daily claims + referrals โ daily streak bonuses with premium-user multipliers, referral chain rewards.
- ๐จ AI-generated NFTs โ Stability AI image-to-image + ChatGPT descriptions, pinned to IPFS, minted as TON cNFTs from an admin-curated queue.
- โ๏ธ On-chain transaction monitoring โ Fastify worker polls TON for incoming payments and credits points automatically.
- ๐งช Heavily tested backend โ 422 tests on the Node.js built-in test runner.
โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโ
โ Telegram Bot โ โ Fastify Server โ โ Vue 3 App โ
โ (Grammy) โโโโโโถโ (API + Static) โโโโโโโ (Vite, TMA) โ
โ src/bot/ โ โ src/server.ts โ โ src/frontend/ โ
โโโโโโโโโโฌโโโโโโโโโ โโโโโโโโโโฌโโโโโโโโโโ โโโโโโโโโโโโโโโโโโ
โ โ
โ โโโโโโโโโโดโโโโโโโโโโ
โโโโโโโโโโโโโโโถโ MongoDB โ
โ (Typegoose) โ
โโโโโโโโโโฌโโโโโโโโโโ
โ
โโโโโโโโโโดโโโโโโโโโโ
โ TON Blockchain โ
โ (subscription) โ
โโโโโโโโโโโโโโโโโโโโ
See ARCHITECTURE.md for the full system overview and runtime flows.
| Layer | Stack |
|---|---|
| Bot | Grammy + plugins (auto-retry, hydrate, parse-mode, i18n) |
| HTTP API | Fastify + @fastify/middie, @fastify/static |
| Frontend | Vue 3 + Vite + Pinia + TonConnect |
| Database | MongoDB via Typegoose (Mongoose decorators) |
| Blockchain | @ton/ton for transactions, NFT minting, jetton operations |
| AI | Stability AI (images) + OpenAI (NFT descriptions) |
| Storage | Pinata IPFS for NFT metadata + artwork |
| Quality | @antfu/eslint-config, Prettier, tsc, Husky |
Prerequisites: Node 18+, MongoDB, a Telegram bot token, optional TON wallet for production.
# 1. Configure
cp .env.example .env
# edit .env โ BOT_TOKEN, MONGO_URL, etc.
# 2. Install (root + frontend each have their own package.json)
npm install
npm --prefix src/frontend install
# 3. Run in watch mode
npm run dev # backend (tsx watch)
npm --prefix src/frontend run dev # frontend (Vite, port 5173)| Command | Purpose |
|---|---|
npm run dev |
Backend watch mode (tsx). |
npm run build:all |
Compile backend (tsc) + frontend (vite build). |
npm run lint |
Lint with @antfu/eslint-config. |
npm run format |
Prettier write across .ts/.js/.vue/.json/.css/.scss/.md. |
npm run typecheck |
tsc --noEmit strict. |
npm run test:backend |
Backend unit/integration suite (Node test runner). |
npm run test:coverage |
Coverage report via Node's --experimental-test-coverage. |
npm run start |
One-shot build + run (production-like). |
The backend uses Node.js's built-in test runner (node --test) โ no Jest/Vitest. Handlers are written with dependency injection so tests can swap in mocks without spinning up Mongo, TON, or the bot. See src/backend/auth-handler.test.ts for the canonical pattern.
npm run test:backend # ~5s, 422 tests across 53 files
npm run test:coverage # full per-file coverage reportAreas at or near full coverage: every backend route handler, all callback-data packers, every keyboard, every middleware, plus most pure helpers (points, markdown, text, time, votes, leaderboard-rows, โฆ). Files that still have gaps are mostly Typegoose model classes and config bootstrap โ code that only meaningfully executes against a real database or environment. Run npm run test:coverage for the latest per-file numbers.
src/
main.ts # entrypoint โ MongoDB โ bot โ server โ subscription โ start
server.ts # Fastify, registers /api/* handlers
config.ts # znv + Zod, lazy proxy singleton
subscription.ts # TON transaction poller (composer wiring)
subscription-core.ts # AccountSubscription polling class
subscription-start.ts # DI-friendly startup builder
bot/
index.ts # middleware chain (ORDER MATTERS) + feature registration
context.ts # Grammy Context + SessionData types
features/*.ts # commands: start, help, line, stats, whales, unhandled,
# removed-commands, admin/{queue,collection,
# parameters,transaction,user}
filters/is-admin.ts # auth filter for admin-only commands
handlers/ # error boundary + sync-commands runner
middlewares/*.ts # attach-user, reaction, update-logger
keyboards/*.ts # inline keyboards (photo, queue-menu)
callback-data/*.ts # typed callback-data packers
backend/ # Fastify handlers (auth, claim, leaderboard, nft, balances, captcha)
common/
models/ # Typegoose: User, Balance, Claim, CNFT, Transaction, Vote
helpers/ # ton, ipfs, generation, files, telegram, random, satoshi, โฆ
frontend/ # Vue 3 + Vite (separate package.json)
captcha/ # standalone DOOM captcha (HTML/JS, not Vue; currently unused)
locales/ # Fluent (.ftl) translations
docs/ # research snapshots, coverage badge, future development
The dice game (
/dice), NFT-mint command (/mint), and story game (/play) were removed;removed-commands.tscatches those slash commands and points users to the Mini App. The HMAC captcha endpoint andUser.suspicionDicesfield remain as orphaned scaffolding from the dice flow.
- ARCHITECTURE.md โ system shape, startup flow, runtime flows, security model
- AGENTS.md โ orientation for AI coding agents working on this repo
- CODEX.md โ quick reference for ChatGPT Codex / Cursor-style tools
- CLAUDE.md โ compact context for Claude Code
- docs/FUTURE_DEVELOPMENT.md โ prioritized improvements and feature ideas
- Fork and create a branch.
- Run the full gate before opening a PR:
npm run lint && npm run typecheck && npm run test:backend && npm --prefix src/frontend run build
- Follow the existing DI handler pattern for any new route or bot command โ it makes the handler testable without booting infrastructure.
MIT โ see package.json.