GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - nmime/telegram-gift-auction: Multi-round auction backend for Telegram Gift Auctions. NestJS + React + MongoDB + Redis ↓ Demo ↓

BranchesTags
Open more actions menu

Latest commit

 

History

95 Commits
95 Commits

Folders and files

NameName
Last commit message
Last commit date
.github/workflows
.github/workflows
 
 
backend
backend
 
 
docs
docs
 
 
frontend
frontend
 
 
.dockerignore
.dockerignore
 
 
.env.example
.env.example
 
 
.gitignore
.gitignore
 
 
.nvmrc
.nvmrc
 
 
README.md
README.md
 
 
README.ru.md
README.ru.md
 
 
docker-compose.infra.yml
docker-compose.infra.yml
 
 
docker-compose.yml
docker-compose.yml
 
 
package.json
package.json
 
 
pnpm-lock.yaml
pnpm-lock.yaml
 
 
pnpm-workspace.yaml
pnpm-workspace.yaml
 
 

Repository files navigation

Telegram Gift Auction System

Production-grade multi-round auction platform for Telegram.

Live Demo Telegram Bot API Docs


Русская версия


· Architecture · API · Auction Mechanics · Concurrency · Testing · Deployment


Performance

┌─────────────────────────────────────────────────────────────────────┐
│  SINGLE-CORE                                                        │
│    HTTP:       2,779 req/sec peak, 197 req/s standard load          │
│    WebSocket:  200,018 emit/sec peak, 175,970/sec sustained         │
│    Latency:    1.5ms mean, 5ms p99                                  │
│                                                                     │
│  CLUSTER MODE (12 cores, sticky sessions)                           │
│    HTTP:       7,216 req/sec peak, 99.96% success (+160%)           │
│    WebSocket:  251,640 emit/sec peak, 12M emits, 80% success (+26%) │
│                                                                     │
│  Grade: A+ (production-ready)                                       │
└─────────────────────────────────────────────────────────────────────┘

Full benchmarks: BENCHMARK_REPORT.md · Live Reports


Key Features

Feature Description
Multi-round auctions Items distributed across rounds (e.g., 3+5+2), partial winners each round
5-layer concurrency Redlock → Redis cooldown → MongoDB transactions → optimistic locking → unique indexes
High-performance bidding Redis Lua script (~1.4ms mean), WebSocket real-time updates
Anti-sniping Configurable window with automatic round extensions
Financial integrity Frozen balances, atomic operations, complete audit trail
Telegram native Login Widget, Mini App auth, bot notifications (GrammyJS)
Horizontal scaling Cluster mode + Redis adapter for multi-server deployments

Tech Stack

Backend: NestJS 11 + Fastify · MongoDB 8 · Redis + Redlock · Socket.IO · JWT Frontend: React 19 + Vite · TypeScript · i18n (en/ru) Infra: Docker Compose · Node.js 22+


Quick Start

# Docker (recommended)
cp backend/.env.example backend/.env
docker compose up --build

# Local development
docker compose -f docker-compose.infra.yml up -d
npm install && npm run dev

Access: Frontend localhost:5173 · API localhost:4000/api · Docs localhost:4000/api/docs


How It Works

Auction Flow

PENDING → ACTIVE → COMPLETED
            ├── Round 1: Top 3 win
            ├── Round 2: Top 5 win
            └── Round 3: Top 2 win → Remaining refunded

Bid Flow (5-Layer Protection)

1. Redlock        → Acquire distributed lock (fail-fast)
2. Redis cooldown → 1s between bids per user
3. MongoDB tx     → Snapshot isolation + retry
4. Optimistic     → Version check on user/bid
5. Unique index   → No duplicate amounts

Financial Model

balance        = available for bidding
frozenBalance  = locked in active bids

Place bid:   balance -= X, frozenBalance += X
Win:         frozenBalance -= X (spent)
Refund:      frozenBalance -= X, balance += X

API Overview

REST Endpoints

Endpoint Description
POST /api/auth/telegram/webapp Mini App authentication
GET /api/auctions List auctions
POST /api/auctions/:id/bid Place bid (Redis high-performance)
GET /api/auctions/:id/leaderboard Current rankings
GET /api/users/balance Get balance

WebSocket Events

// Authenticate & join
socket.emit('auth', jwtToken);
socket.emit('join-auction', auctionId);

// Place bid (63K/sec possible)
socket.emit('place-bid', { auctionId, amount: 1000 });

// Receive updates
socket.on('new-bid', data => { /* ... */ });
socket.on('bid-response', ({ success, amount }) => { /* ... */ });

Configuration

Variable Description
MONGODB_URI MongoDB connection (replica set required)
REDIS_URL Redis connection
JWT_SECRET JWT signing secret
TELEGRAM_BOT_TOKEN Bot token for notifications
CLUSTER_WORKERS 0=single, auto=all cores

Rate Limits

  • Short: 20/sec · Medium: 100/10sec · Long: 300/min

Load Testing

# HTTP
pnpm run load-test           # Standard
pnpm run load-test:stress    # Extreme

# WebSocket
npx artillery run test/artillery/websocket-extreme.yml  # 63K emit/s

Design Decisions

  • MongoDB transactions — Atomic financial operations
  • Redis Lua scripts — Single call for all validation + bid placement (~0.02ms)
  • Background sync — 5s interval balances speed vs durability
  • WebSocket bidding — Eliminates HTTP overhead for max throughput
  • Unique bid amounts — Deterministic leaderboards, no ties

More details: docs/architecture.md · docs/concurrency.md


License

MIT

About

Multi-round auction backend for Telegram Gift Auctions. NestJS + React + MongoDB + Redis ↓ Demo ↓

drive.google.com/file/d/1LDe0RLi3uc7IIbew3JpeaXCRfDLKn0le/view?usp=sharing

Resources

Readme
Activity

Stars

0 stars

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.