Skip to main content

Command Palette

Search for a command to run...

Building Big with Less: Rails and the Power of Monolithic Architecture

Updated
8 min read
Building Big with Less: Rails and the Power of Monolithic Architecture

You Have an Idea. Now What?

You've got a brilliant idea. You've gathered your friends - maybe 10-20 people who can code. Everyone's excited, the energy is incredible, and you're ready to build something amazing.

Then someone asks: "How should we actually build this?"

Suddenly you're confused. Should you use microservices? Do you need fancy cloud architecture? What even is Kubernetes, and do you need it?

Here's the truth: You're overthinking it.

Let's talk about the simplest way to turn your idea into reality.

The Big Question: Simple or Complicated?

Q: Everyone talks about splitting apps into tiny pieces (microservices). Is that what we need?

Imagine you're building a house. One contractor says: "First, you need to dig the foundation yourself. Then source all the materials. Then figure out the plumbing. Then the electrical. I'll supervise."

Another contractor says: "I've built 10,000 houses. I know exactly what you need. I'll handle the foundation, plumbing, electrical, everything. You just tell me how many bedrooms you want."

Which sounds easier?

Microservices are like hiring 10 separate contractors. Big companies like Google need this because they have thousands of programmers who can't all work on the same thing.

But you're not Google. You're a small team trying to build something people will love.

Q: But won't we need to scale eventually?

Yes, eventually. But here's what most people miss: GitHub handled millions of developers with a Rails monolith for years. Shopify processes billions in transactions on Rails. Basecamp has run profitably for decades without breaking into microservices.

The question isn't "will we need to scale?" It's "what's preventing us from building the product right now?"

Q: So what's the alternative?

A well-crafted monolith. And specifically, a Rails monolith.

What is Rails? Why Rails? Why Now?

Q: What is Rails? I haven't heard of this one.

Rails is a web application framework written in Ruby. Ruby is a programming language similar to Python or JavaScript. David Heinemeier Hansson (DHH) created the Rails framework to make web development faster and more enjoyable.

The Rails Philosophy: Two Core Principles

  1. Convention Over Configuration

  2. Don't Repeat Yourself (DRY)

Q: What does "Convention Over Configuration" actually mean in practice?

Let's get concrete. In many frameworks, before you can save a user to the database, you need to install a database driver, write configuration files connecting to the database, define your database schema manually, write queries or ORM mappings, set up connection pools, and configure transaction handling.

In Rails, you type:

rails generate model User name:string email:string

rails db:migrate

Done. You now have a User model that can save to the database. Rails assumed you want PostgreSQL or MySQL (you can change it), created the database table, set up all connections, and gave you methods like User.create(name: "Alice", email: "alice@example.com").

That's convention over configuration. Rails makes smart decisions so you don't have to.

Q: Give me another example.

Sure. Let's say you want to send password reset emails. In most frameworks, you'd need to choose an email library, configure SMTP settings, create email templates, write the logic to generate tokens, set up background job processing, and handle delivery failures.

In Rails, you run:

rails generate mailer UserMailer password_reset

Rails creates a complete email system. You write your email template in HTML and text versions. The mailer class handles everything. Want to send it in the background so your web request doesn't wait? Change UserMailer.password_reset(user).deliver_now to deliver_later. That's it.

Rails has been doing this for 20 years. It knows what you need.

Q: How does Rails keep code DRY?

"Don't Repeat Yourself (DRY)," which is a trademark concept for developers. You don't need to rewrite the same code again and again. Write it once in one place and reuse it throughout your application. It's a basic principle of software development, and Rails makes it incredibly easy.

Rails provides several tools for the DRY principle. Helpers extract logic from your views - as the name suggests, views are what's shown to the end user, and helpers keep them clean and focused. Concerns extract common controller logic into controller concerns and common model logic into model concerns. This promotes code reuse and keeps your codebase maintainable.

When you use these tools effectively, you avoid duplicating code across your application.

The Companies That Bet Big on Rails

Q: Who actually uses Rails? I hear it's outdated.

Let's look at the numbers:

GitHub - 100+ million developers, billions of repositories. Still Rails. They're not a small startup anymore - they're Microsoft-owned and processing some of the most critical infrastructure in software development.

Shopify - Over $200 billion in total sales processed. Rails handles Black Friday traffic spikes that would crush most systems. They've proven you can scale a monolith to handle millions of concurrent users.

Airbnb - Revolutionized an entire industry with Rails. They only started extracting services after they had millions of listings and needed specialized search functionality.

Basecamp - Built by DHH himself, profitable for 20+ years, never needed to break into microservices. They handle millions of users with a small team.

Q: So these companies never moved to microservices?

Some extracted specific services when they had a concrete reason. Airbnb pulled out search because Elasticsearch required specialized knowledge. GitHub extracted some Git operations for performance. But their core applications? Still monolithic Rails.

The key insight: They started with monoliths and only broke things apart when they had specific, measurable problems that required it. They didn't start with complexity.

Inside a Rails Application

Q: What does Rails actually give me when I start a project?

Run rails new my_startup and you get a complete application structure:

The app/ directory - Where you'll spend 90% of your time:

  • models/ - Your business data and logic

  • controllers/ - Handle HTTP requests

  • views/ - HTML, JSON, or XML responses

  • jobs/ - Background tasks

  • mailers/ - Email templates and logic

  • channels/ - Real-time WebSocket features

  • assets/ - CSS, JavaScript, images

The config/ directory - Database, routes, environment settings, all configured intelligently by default.

The db/ directory - Database migrations tracked in code, so your entire team stays in sync.

The test/ directory - Because Rails believes good code has tests.

The Power of Rails Generators

Q: What is a generator?

A generator is a Rails tool that automatically creates code following Rails conventions. It eliminates thousands of tiny decisions that drain your energy. Because every generator follows the same conventions, code from one Rails app looks like code from another. New team members onboard faster, and you can move between projects without relearning the structure.

Q: What can generators create?

Everything. Here's a sampling:

Controllers: rails generate controller Products index show new create - Creates the controller, view templates, route entries, and test files.

Models: rails generate model Product name:string price:decimal inventory:integer - Creates the model, database migration, and tests. Automatically sets up the database table with correct data types.

Scaffolds: rails generate scaffold Article title:string body:text published:boolean - Creates everything - model, migration, controller, views, routes, tests. A complete CRUD interface in one command.

Mailers: rails generate mailer Order confirmation shipping_notification - Creates email templates and mailer classes.

Jobs: rails generate job ProcessPayment - Creates a background job class ready for Sidekiq or other job processors.

Q: Doesn't this generated code lead to bloat?

Only if you leave what you don't need. Experienced Rails developers generate the structure, then delete or modify what doesn't fit. The point is to get 80% of the boilerplate instantly, then customize the remaining 20%.

Everything You Need, Batteries Included

Q: What about features beyond basic CRUD?

This is where Rails truly shines. Most frameworks give you the basics. Rails gives you production-grade features:

Caching - Out of the box, Rails supports fragment caching, page caching, and Russian doll caching. Wrap slow operations in Rails.cache.fetch and Rails handles the rest. Your database query that takes 500ms? Now 5ms from cache.

File Uploads - Active Storage handles file uploads to your disk, Amazon S3, Google Cloud, or Azure. It processes image variants automatically. Upload a 5MB photo, Rails can generate thumbnails, handle responsive images, and serve them efficiently.

Internationalization (i18n) - Building for multiple countries? Rails has translation management built-in. Store text in YAML files, Rails handles plural forms, date formatting, and number formatting for every locale.

Action Cable - Real-time features without the complexity. Chat applications, live notifications, collaborative editing - WebSockets are first-class citizens in Rails.

Background Jobs - Send 10,000 welcome emails? Process video uploads? Rails queues jobs through Active Job, which works with Sidekiq, Resque, or other processors.

Q: What about security?

Rails takes security seriously with built-in protections:

Brakeman - Run bin/brakeman and get a security audit. It scans for SQL injection, cross-site scripting, unsafe redirects, and dozens of other vulnerabilities.

CSRF Protection - Every form automatically includes CSRF tokens. Rails rejects form submissions that don't have valid tokens.

Parameter Filtering - Passwords and sensitive data automatically filtered from logs.

SQL Injection Prevention - Active Record parameterizes queries. Writing User.where("email = ?", params[:email]) is safe by default.

Q: How does Rails help maintain code quality?

RuboCop - Run bin/rubocop and Rails checks your code style. Inconsistent indentation? Extra whitespace? Long methods? RuboCop flags them. Better yet, run bin/rubocop -a and it auto-corrects most issues.

Built-in Testing - Every generator creates test files. Rails encourages test-driven development from day one. Run rails test to verify everything works.

Database Migrations - Changes to your database schema are versioned. Every migration is timestamped. Rolling back a bad deploy? Just roll back migrations too. Your entire team's databases stay synchronized.

TLDR;

Stop overcomplicating your startup's tech stack. Rails gives you a complete, production-ready framework that powers GitHub, Shopify, Airbnb, and Basecamp. With convention over configuration, you'll spend less time on infrastructure decisions and more time building features your users will love. Start with a monolith, ship fast, and scale when you actually need to - not because someone told you microservices are "the future." Rails has 20 years of battle-tested wisdom baked in. Use it.

Let's Connect

Found this helpful? Connect with me on LinkedIn to continue the conversation and share your experiences with Rails or monolithic architecture. What's your take - monolith first or microservices from day one?

https://www.linkedin.com/in/manask-pradhan/

contact@devmanas.in