Building an AI Social Media Manager with Ruby on Rails: Architecture, Automation, and Lessons Learned
In a previous post, How We’re Building a Social Media Empire with Rails and Sidekiq,
I shared how we scaled background jobs and task automation using Rails and Sidekiq. That article focused on how RobinReach
Our social media management platform handled large-scale post scheduling and media processing.
This time, we’re taking a deeper dive into how we integrated AI into our architecture and how Ruby on Rails continues to be the backbone of everything we build.
Why Rails Still Works for AI SaaS
Even in 2025, Ruby on Rails remains a perfect fit for startups building fast, scalable, and flexible SaaS products. When we started building RobinReach, we needed to:
- Move fast with a clean architecture.
- Handle complex background automation.
- Support multi-tenant data isolation for agencies.
- Integrate AI models that evolve quickly.
Rails gave us that foundation. With Hotwire and Tailwind CSS, we kept the frontend lean and responsive, no heavy SPAs needed.
Our Service-Driven Architecture
One of our early decisions was to adopt a service-driven architecture. Every core component from AI post generation to video rendering lives inside a dedicated service class.
That means each domain (posts, media, analytics, automation) can evolve independently while staying testable and predictable.
Example:
class Ai::ContentGeneratorService
def initialize(post)
@post = post
end
def call
prompt = "Create a social media caption about #{@post.topic} in an engaging tone."
response = RubyLLM::Client.new(model: "gpt-4o- mini").complete(prompt)
@post.update!(caption: response.text)
end
end
By keeping logic inside services, we avoid bloated models and controllers, and it makes it easy to reuse across background jobs.
Using AI for Content Refinement
We started with the ruby-openai gem, but later switched to ruby-llm for its flexibility and broader model support.
Our AI layer powers features like:
- RobinGen → generates captions, hashtags, and text variations.
- RobinPilot → automates post creation from articles or ideas.
- Content refinement → rewrites existing drafts to fit platform tone (LinkedIn, Instagram, etc.).
The workflow is simple:
- User drafts or uploads content.
- AI refines tone, grammar, or platform style.
- User reviews and approves before scheduling.
We use background jobs to handle API calls asynchronously, ensuring the dashboard stays responsive while posts are being “AI-polished.”
Media Handling with MiniMagick and FFmpeg
For visuals, we rely on MiniMagick for image resizing and Streamio-FFmpeg for short-form video generation. These two tools help us dynamically create social media content that looks like it was edited manually.
Multi-Tenant Design for Agencies and Brands
RobinReach was designed for both businesses and marketing agencies. Each company account can manage multiple brands, each brand having its own users, social profiles, posts, and analytics.
We use a company context service to isolate data automatically:
- Every query is scoped by company.
- Each background job inherits that context.
- Admins can switch between brands instantly.
This approach ensures data security and scalability without introducing unnecessary complexity.
Lessons Learned Building RobinReach
- AI integration works best when it’s optional and assistive, not intrusive.
- Service objects keep Rails clean and maintainable as complexity grows.
- Multi-tenancy needs clear boundaries early, retrofitting it later is painful.
- Rails still excels when paired with modern, lightweight tools like Hotwire and Tailwind.
Closing Thoughts
Building RobinReach has been a continuous learning process. We’ve learned that Rails is still one of the best frameworks for quickly turning complex ideas, like AI-driven automation, into production-ready features.
Our next steps include making RobinReach’s AI even smarter, from better content understanding to predicting the best times to post.
If you’d like to follow our journey or see how AI can simplify your social media workflow, you can check out RobinReach at https://robinreach.com/en
.
Top comments (0)