How redf0x1/auto-forward-messages works
Project type and purpose
• This is a cloud-based, full-stack messaging platform centered on a Telegram Bot, with Web, iOS, and Android front-ends and a powerful AI-powered message-processing backend.
• The system’s core responsibility is to receive Telegram messages, apply forwarding rules and AI transformations (rewrite, translate, summarize, OCR), and dispatch them to one or many destinations.
File structure
• The repo only contains README, LICENSE, and .gitignore, indicating documentation only here; actual source lives elsewhere.
• Expect top-level services (bot, web frontend, mobile apps), shared libraries, deployment manifests, and CI/CD scripts in the full codebase.
Key insights from README
• Components:
• Telegram Bot (cloud)
• Web App (React/Vue/Angular)
• iOS App (Swift)
• Android App (Kotlin/Java)
• Backend microservices (message processing, AI integration, filtering, billing, analytics)
• External AI providers (OpenAI, Google AI, Perplexity)
• Data stores (user settings, message history, logs)
• Architectural patterns: Microservices, event-driven processing, pub/sub or message queue.
Main components and their relationships
a. Clients & Interfaces
• Telegram Bot API (bot receives commands & messages)
• Web Frontend (HTTPS REST/WebSocket)
• Mobile Frontends (HTTPS REST)
b. API Gateway / Load Balancer
• Routes client requests to appropriate backend services
• Handles SSL termination, authentication (JWT/OAuth)
c. Authentication & User Management Service
• Manages user accounts, subscriptions, plan tiers, affiliate tracking
d. Message Processing Pipeline
1. Ingest Service
• Subscribes to Telegram updates via long-polling or webhook
• Publishes raw messages to Message Queue (e.g., Kafka or RabbitMQ)
2. Filtering & Routing Service
• Consumes from queue, applies whitelist/blacklist, keyword/media filters
• Decides forwarding chains (one-to-many, chain forwarding)
3. AI Transformation Service
• On premium plans, invokes external AI APIs (OpenAI, Google AI, Perplexity) for rewrite, translate, summarize, OCR
• Returns modified message payload
4. Forwarding Service
• Takes (possibly transformed) message and pushes to target Telegram chats via Bot API
• Updates status in database
e. Data Stores
• Relational DB (PostgreSQL/MySQL) for user data, subscription, message metadata
• NoSQL/Cache (Redis) for rate-limiting, session, quick lookup
• Object store (S3) for media/temp storage
• Logging/Analytics (ELK stack or similar)
f. Billing & Subscription Service
• Integrates with in-app purchase APIs (App Store, Google Play, Bot upgrades)
• Manages plan entitlements and feature flags
g. Monitoring & Alerting
• Prometheus/Grafana for metrics, uptime (99.9% SLA)
• Alert manager for errors, processing lags
h. CI/CD & Deployment
• Docker images orchestrated via Kubernetes (EKS/GKE) or ECS
• Helm charts/CloudFormation for infra
• Automated pipelines (GitHub Actions, GitLab CI)
Architectural patterns & design principles
• Microservices: Decoupled components for ingest, processing, AI, forwarding
• Event-driven: Queue-based messaging ensures resiliency and scalability
• API-first: Clear REST or gRPC interfaces
• 12-factor app principles for config, logs, build/deploy
• Circuit breakers and retries when calling external AI APIs