DEV Community

Cover image for How We’re Building a Social Media Empire with Rails and Sidekiq
Shaher Shamroukh
Shaher Shamroukh

Posted on

How We’re Building a Social Media Empire with Rails and Sidekiq

It’s been a minute since I last published a blog post, mostly because we’ve been busy building RobinReach, a modern social media management platform powered by Ruby on Rails.

If you’ve ever tried building a tool that posts to multiple social platforms, handles different time zones, supports team approvals, automates publishing, and still provides clean analytics… you know it’s not a walk in the park.

What could’ve easily turned into a tangled mess of conditionals, platform-specific logic, and fragile scheduling code became a clean, maintainable, and scalable system thanks to Rails' service-oriented design and Sidekiq for background job handling.

The Stack That Powers RobinReach
RobinReach runs on a streamlined and modern Rails stack:

  • Ruby on Rails 7
  • PostgreSQL
  • Sidekiq + Redis for background jobs
  • Hotwire + Stimulus for reactive UI
  • TailwindCSS for styling

We manage thousands of scheduled posts across platforms like Instagram, LinkedIn, TikTok, Twitter, and YouTube, all orchestrated through Sidekiq workers that handle everything from publishing to AI content generation.

🧩 Why a Service-Oriented Architecture?
Each social media platform comes with its own rules: different APIs, content requirements, authentication flows, error handling, rate limits, the list goes on.

Instead of cluttering models or controllers with conditional logic, we split the logic by platform using dedicated service classes, like this:

module SocialMedia
  module InstagramDirect
    class Post < SocialMedia::ApplicationService
      def initialize(post, profile)
        # setup context
      end

      def call
        # 1. create media container
        # 2. wait for readiness
        # 3. publish
        # 4. return success or failure
      end
    end
  end
end
Enter fullscreen mode Exit fullscreen mode

We use the same structure for:

SocialMedia::Twitter::Service

SocialMedia::LinkedIn::Service

Each class is responsible for only one job: posting to its platform.

What This Gives Us:

  • A clean interface: PlatformService.new(post, profile).call
  • Separation of concerns
  • Platform-specific logging + error handling
  • Easier testing, mocking, and maintenance

⏱ Why Sidekiq?

Publishing a post isn’t instant:

  • It needs to go out at the scheduled time
  • Some platforms require polling
  • Others need multi-step media uploads
  • You don’t want users waiting for any of that

Welcome Sidekiq.

We use Sidekiq to handle everything asynchronously and at scale.

A Typical Flow:

  1. User schedules a post for a future time
  2. We enqueue the job like this:

PostJob.perform_at(post.publish_time, post.id)

  1. The job runs, finds the post, and calls the right service object
  2. Everything happens in the background, with automatic retries if things fail.

💡The Sweet Spot: Service + Sidekiq
Here’s why the combination is so powerful:

🔧 Service Objects ⏱ Sidekiq
Encapsulate platform logic Handles execution & timing
Keep jobs thin Makes everything async
Testable, predictable Retryable, resilient
Modular per platform Scalable with queues

We can:

  • Add new platforms without touching existing logic
  • Retry failed posts automatically
  • Track errors in logs or monitoring tools
  • Move fast without fearing regression

🧪 Testability Bonus

  • Each service object is unit-tested on its own.
  • Jobs are tested separately with inline Sidekiq workers.
  • Because logic is separated, we can:
  • Mock external API calls in services
  • Simulate platform failures
  • Write isolated tests for platform behaviors

This would be a nightmare with fat models or controllers.

Final Thoughts
If you’re building a Rails app that interacts with third-party APIs, handles user actions asynchronously, or needs to scale beyond a weekend project…

💡 Split logic into service objects
🧠 Run tasks with Sidekiq

That combo gave us:

  • A cleaner codebase
  • Faster iteration cycles
  • Fewer bugs
  • Less stress

Rails gives you the foundation. These two patterns help you build skyscrapers on top of it.

Oh, and one more thing…
Turns out we’re not the only social media management tool built with Rails, shoutout to Publer, whose product and UX has definitely inspired us along the way.

Rails is alive and well. And with service objects + Sidekiq, it scales beautifully.

Top comments (0)