A free book teaching advanced, production-oriented Sinatra development by building a Udemy-like course marketplace.
This is not a beginner's book - it dives straight into advanced topics for building real-world production software with Sinatra. The first two chapters cover essential concepts, then we build a fully functional course marketplace.
I highly recommend reading the Sinatra documentation and having a solid understanding of Ruby before starting.
Recommended Ruby resources:
- Eloquent Ruby, Second Edition by Russ Olsen
- Practical Object-Oriented Design in Ruby by Sandi Metz
- The Odin Project (free, comprehensive full-stack curriculum)
A fully functional Udemy-type clone where users can buy and publish short video courses, featuring user management, authentication, REST & GraphQL APIs, real-time WebSockets, database-backed content, and production deployment.
Each example in the examples/ directory is self-contained with its own Gemfile:
cd examples/ch01-modular
bundle install
bundle exec rackup
# Open http://localhost:9292For chapters that use PostgreSQL or Redis, use the included Docker environment:
docker compose upSee Running Examples for full details.
- Classic vs Modular Style Applications
- Useful Tools - Sinatra Contrib, Helpers, Logging, Code Analyzers
- A Brief Introduction to Rack
- Software Architecture Patterns
- Named Parameters
- Wildcard Routing
- Routing with Regular Expressions
- Using Query String Parameters
- Routing Conditions
- Configuration
- Types of Template Engines
- Namespacing Templates
- Layouts
- Embedding Partials
- Effectively Dealing with Mailers
- Rake-based Asset Bundling
- Sprockets
- Serving Directly with Rack::Static
- Effective Caching
- Serving Assets from Nginx
- Understanding WebSockets
- Basic WebSocket Setup with Sinatra
- Realtime Chat Application
- Embeddable JavaScript Applications with CORS
- Realtime Exception Tracking System
- MVC & Directory Structure
- Helpers
- Settings / Configuration
- Application Boot Process
- Creating Custom Helpers
- Creating Custom Extensions
- User Authentication
- Rack Protection Module
- API Authentication
- OAuth Authentication
- Input Validation
- SSL/HTTPS in Production
- Basic REST API Principles
- Creating a JSON API Service
- API Authentication
- Consuming External APIs
- GraphQL with Sinatra
- Testing & Documenting Your APIs
- Testing with Rack::Test
- Testing with RSpec
- Testing with Minitest
- Containerized Deployment with Docker
- Deploying with Puma behind Nginx
- Production Checklist
If you want to help by contributing to the content of this book, please submit a pull request.
Sean Nieuwoudt - sean@underwulf.com