5.8 KiB
5.8 KiB
TeleBot - LittleShop Integration Summary
✅ Completed Implementation
1. Privacy-First Architecture
- ✅ Anonymous user identification (SHA-256 hashed Telegram IDs)
- ✅ Ephemeral sessions by default (30-minute timeout)
- ✅ PGP encryption support for shipping information
- ✅ Tor support for routing (SOCKS5 proxy configuration)
- ✅ Zero-knowledge cart storage (encrypted with session keys)
- ✅ Privacy-preserving logging (PII redaction)
2. Core Components Created
Models (/Models/)
UserSession.cs- Privacy-focused session managementShoppingCart.cs- Cart and item managementOrderFlowData.cs- Checkout flow state tracking
Services (/Services/)
PrivacyService.cs- Encryption, hashing, Tor client creationSessionManager.cs- Session lifecycle with Redis/LiteDB supportLittleShopService.cs- Wrapper for LittleShop Client SDK
Handlers (/Handlers/)
CommandHandler.cs- Telegram command processing (/start, /browse, etc.)CallbackHandler.cs- Button interaction handlingMessageHandler.cs- Text message processing (checkout flow)
UI Components (/UI/)
MenuBuilder.cs- Dynamic Telegram keyboard generationMessageFormatter.cs- Rich text formatting for products/orders
3. Features Implemented
Shopping Flow
- Browse categories → View products → Product details
- Add to cart with quantity selection
- Cart management (view, update, clear)
- Multi-step checkout (name, address, city, postal, country)
- Payment method selection (8 cryptocurrencies)
- Order confirmation with payment instructions
- QR code generation for crypto addresses
Privacy Features
/ephemeral- Toggle ephemeral mode/pgpkey- Set PGP public key/delete- Instant data deletion/tor- Tor configuration guide/privacy- Privacy settings menu
Order Management
- Anonymous order references (ANON-XXXXXXXXXXXX)
- Order history viewing
- Payment status tracking
- Shipping status updates
4. Configuration System
appsettings.json Structure
{
"Telegram": { "BotToken": "..." },
"LittleShop": { "ApiUrl": "...", "UseTor": false },
"Privacy": { "EphemeralByDefault": true, "EnableTor": false },
"Redis": { "Enabled": false },
"Features": { "EnableQRCodes": true, "EnablePGPEncryption": true }
}
5. Dependencies Integrated
- ✅ LittleShop.Client SDK
- ✅ Telegram.Bot framework
- ✅ PgpCore for encryption
- ✅ LiteDB for local storage
- ✅ Redis for distributed cache
- ✅ QRCoder for payment QR codes
- ✅ Serilog for logging
- ✅ Hangfire for background jobs
🔧 Integration Points
LittleShop Client SDK Usage
// Authentication
await _client.Authentication.LoginAsync(username, password);
// Fetch categories
var categories = await _client.Catalog.GetCategoriesAsync();
// Get products
var products = await _client.Catalog.GetProductsAsync(categoryId: id);
// Create order
var order = await _client.Orders.CreateOrderAsync(request);
// Generate payment
var payment = await _client.Orders.CreatePaymentAsync(orderId, currency);
Privacy Implementation
// Anonymous user identification
var hashedId = SHA256(telegramUserId + salt);
// PGP encryption for shipping
if (user.RequiresPGP) {
shippingInfo = await EncryptWithPGP(data, publicKey);
}
// Tor routing
var httpClient = await CreateTorHttpClient();
📊 Data Flow
User → Telegram → TeleBot → [Tor?] → LittleShop API → Database
↓
Session Manager
↓
[Redis/LiteDB]
🚀 Deployment Architecture
Docker Compose Setup
services:
telebot: # Main bot service
tor: # Tor proxy (optional)
redis: # Session cache (optional)
littleshop: # API backend
btcpay: # Payment processor
🔒 Security Features
-
No Personal Data Storage
- Only hashed identifiers
- Ephemeral sessions
- Auto-cleanup after timeout
-
Encrypted Communications
- Optional Tor routing
- HTTPS for API calls
- PGP for sensitive data
-
Payment Privacy
- Cryptocurrency only
- No payment data stored
- Anonymous order references
📝 Next Steps for Production
Required
- Set up actual Telegram bot token
- Configure LittleShop API credentials
- Set up BTCPay Server integration
- Configure proper encryption keys
Optional Enhancements
- Enable Redis for distributed sessions
- Set up Tor hidden service
- Configure Hangfire for background jobs
- Implement order status webhooks
- Add multi-language support
🎯 Key Achievements
- Complete e-commerce flow through Telegram
- Privacy-first design with multiple layers of protection
- Clean architecture with separation of concerns
- Extensible framework for future enhancements
- Production-ready configuration system
- Comprehensive documentation for deployment
💡 Technical Lessons
- Telegram.Bot API Evolution: Methods change between versions
- Session Management: Balance between privacy and UX
- Tor Integration: Manual SOCKS5 proxy more reliable than libraries
- PGP Implementation: PgpCore simplifies encryption
- QR Code Generation: Essential for crypto payments
🏗️ Architecture Decisions
- No User Accounts: Privacy through anonymity
- Ephemeral by Default: Data minimization
- Cryptocurrency Only: No traditional payment tracking
- Modular Handlers: Easy to extend functionality
- Configuration-Driven: Environment-specific settings
This integration successfully bridges the LittleShop e-commerce platform with Telegram, providing a privacy-focused shopping experience through a familiar messaging interface.