All Projects
Backend & APIs Featured Case Study

SMP — Enterprise Multi-Platform Social Media Automation Engine

Omnichannel social media publishing and scheduling engine targeting Telegram, YouTube, Instagram, Bale, and Rubika, equipped with FFmpeg anti-duplicate video uniquification, Hangfire background queues, and real-time SignalR broadcasts.

.NET 10 React 19 TypeScript Python 3.12 PostgreSQL 17 Hangfire SignalR FFmpeg Telethon Docker
SMP — Enterprise Multi-Platform Social Media Automation Engine cover
Social Media Platform (SMP) is an enterprise-grade automation platform built to streamline the entire lifecycle of multi-network content scheduling and automated delivery across Telegram, YouTube, Instagram, Rubika, and Bale. Digital media teams face significant technical bottlenecks when orchestrating concurrent multi-channel broadcasts: disparate authentication protocols (OAuth 2.0, Meta Graph API tokens, Telegram MTProto user sessions, and custom local messenger protocols), strict rate limits, and aggressive duplicate content detection algorithms on platforms like YouTube and Telegram that trigger shadowbans when identical videos are cross-posted. SMP overcomes these challenges through Clean Architecture on ASP.NET Core 10, MediatR CQRS patterns, and a robust asynchronous Python execution bridge. The platform features an automated FFmpeg media preprocessing pipeline that alters subtle video attributes to generate unique digital file fingerprints, backed by resilient Hangfire background task processing and live SignalR event streaming directly to a React 19 dashboard.

The Problem

Managing multi-platform broadcasts manually presents several technical hurdles and operational risks: 1. Protocol & Authentication Divergence: Each network demands distinct auth flows: YouTube mandates OAuth 2.0 PKCE and token refreshes, Instagram demands publicly accessible media URLs for Graph API ingestion, Telegram requires stateful MTProto sessions with 2FA handling, and domestic messengers (Rubika & Bale) rely on custom client libraries. 2. Duplicate Content & Shadowban Risks: Re-uploading identical video binaries across multiple channels triggers hash-based duplicate filters, resulting in severe algorithmic penalties or shadowbans. 3. Partial Failures in Multi-Target Broadcasts: A single broadcast targeting 5 distinct channels must not fail globally if a single network experiences temporary rate limits or timeouts, nor should subsequent retries duplicate posts on already-successful channels. 4. Operational Blind Spots: Manual uploads of heavy media assets without real-time progress indicators waste administrative overhead.

The Solution

SMP resolves multi-channel broadcasting friction through a decoupled, multi-layered architecture: • Unified Hub for 5 Major Networks: Centralized management of Telegram Userbots and Bot APIs, YouTube Channels (OAuth 2.0), Instagram Business accounts (Meta Graph API), and Rubika & Bale channels. • Automated Video Uniquifier (Anti-Duplicate): Lightweight FFmpeg transformations applied on the fly (1% speed adjustment, 4px edge cropping, optional horizontal flip, and intro/outro splicing) that generate a novel digital binary hash to bypass duplicate fingerprinting without degrading viewing quality. • Smart Thumbnail Extraction: Automatic high-res keyframe extraction from video intervals, 720p HD scaling, and custom alpha-blended logo watermarking. • Resilient Hangfire Schedulers: High-reliability background dispatchers with exponential backoff (up to 3 retries), target-level idempotency, and atomic database state locks. • Real-Time SignalR Event Dispatch: Instant WebSocket streaming of upload progression and delivery status changes directly to client browsers. • Modern React 19 & TypeScript Dashboard: Responsive dark/light theme, interactive queue management, instant account health checks, and NSwag-generated type safety.

System Flow & Architecture

Architected with strict Clean Architecture separation of concerns: - Domain Core (SMP.Domain): Encapsulates Post, PostTarget, SocialAccount, and MediaFile entities, enums, and domain invariants with zero external dependencies. - Application Layer (SMP.Application): Orchestrates business use cases via MediatR CQRS handlers, FluentValidation pipeline behaviors, and FluentResults railway-oriented patterns. - Infrastructure Layer (SMP.Infrastructure): Manages PostgreSQL 17 persistence via EF Core, Hangfire background job dispatching, local storage pipelines, and the dynamic SocialMediaPublisherFactory. - Python Automation Bridge (runner.py): Handles isolated client processes (Telethon, Autobale, Rubpy, Meta API) and FFmpeg pipelines through structured JSON communication. - Web & Presentation Layer (SMP.WebApi & SignalR): Exposes secure REST endpoints, RFC 7807 ProblemDetails error handling, and WebSocket notification hubs. - Client Dashboard (React 19): Built with Vite, TypeScript, and TailwindCSS for a seamless operator experience.
flowchart LR A["💻 1. React 19 Web Dashboard"] --> B["⚙️ 2. .NET 10 CQRS & Hangfire"] B --> C["🎬 3. Video Uniquifier & Cover (FFmpeg)"] B --> D["📡 4. Python Multi-Client Bridge"] D --> E["🚀 5. Multi-Network Delivery (TG / YT / IG / Rubika / Bale)"] B -.->|"⚡ Live SignalR Stream"| A

Technical Challenges & Solutions

Synchronizing Frozen C# ↔ Python Bridge Contracts (ADR-0001)

Challenge

Python scripts unpacked incoming JSON payloads via func(**args). Any naming divergence in the JSON keys sent from C# (e.g., token vs. bot_token) immediately resulted in runtime parameter mismatch exceptions.

Solution

Enforced architectural standard ADR-0001, mirroring exact Python parameter names within C# publisher arguments and pinning the contract with reflection-based unit tests.

Impact: Zero runtime argument mismatch errors across all external platform dispatchers.

Public Media URL Resolution for Instagram Publishing (ADR-0002)

Challenge

Meta Graph API strictly requires accessible public HTTP(S) media URLs for media ingestion instead of raw filesystem uploads, while internal disk paths must remain protected.

Solution

Architected a secure public URL resolution mechanism dynamically bound to BasePath and PublicBaseUrl configurations, validating link schemes before submission.

Impact: Flawless Instagram video and container publishing with zero exposure of server storage structures.

Target-Level Idempotency & Partial Failure Resilience

Challenge

When broadcasting a single post to multiple networks, a failure on one target must not cause re-publishing to previously successful targets during retries.

Solution

Modeled discrete PostTarget tracking entities, isolated target lifecycle states, and enforced atomic TryMarkPublishing database transactions.

Impact: 100% protection against duplicate posts and seamless per-target retry capability.

Results & Metrics

• Complete multi-platform automation across 5 major social networks (Telegram, YouTube, Instagram, Rubika, Bale). • 100% mitigation of duplicate-content shadowbans via automated FFmpeg micro-perturbation. • Resilient background job execution with Hangfire and 3-stage exponential retries per channel. • Zero-latency broadcast tracking powered by persistent SignalR WebSocket connections. • Over 90% unit and integration test coverage across Domain, Application, and Infrastructure layers.