A modern Rails template for building AI-powered apps — with built-in chat, MCP tools, multi-provider LLM support, and agent-native architecture. Follows 37signals' vanilla Rails philosophy.
- Ruby 4.0.x / Rails (edge)
- AI: RubyLLM (OpenAI, Anthropic) with streaming chat
- MCP: Model Context Protocol server via fast-mcp
- Database: SQLite with Solid Stack (Cache, Queue, Cable)
- Replication: Litestream (SQLite → S3-compatible storage)
- Frontend: Hotwire (Turbo + Stimulus), Tailwind CSS 4
- Billing: Stripe (subscriptions, checkout, customer portal)
- Deployment: Kamal 2
- Authentication: Magic Links (passwordless)
- Multitenancy: Team-based with roles (owner/admin/member)
- Multilingual: Mobility gem with RubyLLM auto-translation
- Analytics: Nullitics with MaxMind geolocation (optional)
- Admin Panel: Madmin
- Error Tracking: Rails Error Dashboard (RED) at
/red - Primary Keys: UUIDv7 (sortable, distributed-friendly)
- AI Chat with OpenAI and Anthropic models
- Streaming responses via Turbo Streams
- Model switching per chat
- Token tracking and cost estimation
- MCP Server — every UI action is also available as an MCP tool
- Streamable HTTP transport at
/mcp/messages - Team-level API key authentication
- 30+ tools for chats, messages, models, billing, teams, users, articles, and languages
- Streamable HTTP transport at
- Agent-native architecture — agents have full parity with human users
- Magic Link Authentication for users and admins
- Users: First magic link creates account, subsequent ones sign in
- Admins: Only existing admins can create new admins (via Madmin)
- Team-Based Multitenancy with configurable single/multi-tenant modes
- Roles: owner, admin, member
- Team-scoped routes under
/t/:team_slug/
- Multilingual Content with automatic LLM translation
- Per-team language management
- Auto-translates user-generated content (articles, etc.) on save
- Stripe Billing with subscriptions, checkout, and customer portal
- Litestream SQLite Replication to S3-compatible storage (optional)
- Continuous backup of all databases (main, cache, queue, cable)
- UUIDv7 Primary Keys for better distributed system support
- Solid Stack for production-ready background jobs, caching, and cable
- Vanilla Rails approach — no unnecessary abstractions
# Clone this template
git clone git@github.com:newstler/template.git my_new_project
cd my_new_project
# Setup project (runs configuration wizard on first run)
bin/setupOn first run, bin/setup will launch the configuration wizard that:
- Renames the project from "Template" to your project name
- Configures deployment domain and admin email
- Optionally enables Nullitics analytics
- Consolidates migrations into a single initial schema
- Renames git origin to
templateand asks for your repo URL - Commits all configuration changes
- Installs dependencies, prepares database, and starts dev server
# Pull latest changes from template
git fetch template
git merge template/main
# Or cherry-pick specific commits
git cherry-pick <commit-hash>Users can sign up and sign in using magic links sent to their email:
- Visit
/session/new - Enter email address
- Receive magic link via email (creates account on first use)
- Click link to sign in
Admins are managed via the Madmin admin panel:
- First admin is created via
rails db:seed(email configured duringbin/setup) - Existing admins can create new admins at
/madmin/admins - New admin receives magic link via email
- Admin signs in at
/admins/session/new
- Admin panel:
/madmin - Error dashboard:
/red(Rails Error Dashboard) - Admin login:
/admins/session/new
Only authenticated admins can access Madmin and the error dashboard.
# Start dev server (Procfile.dev)
bin/dev
# Console
rails console
# Database
rails db
rails db:migrate
rails db:seed
# Tests
rails test
rails test test/models/user_test.rb:42
# Code quality
bundle exec rubocop -A
# Reconfigure project (delete .configured first)
rm .configured && bin/setupThis template follows 37signals vanilla Rails philosophy:
- Rich domain models over service objects
- CRUD controllers - everything is a resource
- Concerns for horizontal code sharing
- Grow into abstractions - don't create empty directories
- Ship to learn - prototype quality is valid
See CLAUDE.md for complete guidelines.
app/
├── controllers/
│ ├── sessions_controller.rb # User auth (magic links)
│ ├── chats_controller.rb # AI chat
│ ├── articles_controller.rb # Multilingual articles
│ ├── home_controller.rb # Team dashboard
│ ├── onboardings_controller.rb # First-time user setup
│ ├── profiles_controller.rb # User profile
│ ├── admins/
│ │ └── sessions_controller.rb # Admin auth
│ ├── teams/ # Team management
│ │ ├── settings_controller.rb
│ │ ├── members_controller.rb
│ │ ├── pricing_controller.rb
│ │ ├── billing_controller.rb
│ │ └── languages_controller.rb
│ └── madmin/ # Admin panel overrides
├── models/
│ ├── user.rb, admin.rb, team.rb # Core models
│ ├── chat.rb, message.rb, model.rb # AI chat
│ ├── article.rb, language.rb # Multilingual content
│ ├── membership.rb # Team membership
│ └── concerns/ # Shared behavior
├── tools/ # MCP tools
├── resources/ # MCP resources
├── mailers/
│ ├── user_mailer.rb # User magic links
│ └── admin_mailer.rb # Admin magic links
└── views/
Using Kamal 2:
# Update config/deploy.yml with your settings
kamal setup
kamal deploySee config/deploy.yml for configuration.
API keys (AI, Stripe, SMTP, Litestream) are managed in the admin panel at /madmin/settings.
For credentials that must be encrypted (e.g. MaxMind geolocation keys), use Rails credentials:
rails credentials:edit --environment development
rails credentials:edit --environment production# MaxMind GeoLite2 for IP geolocation (optional, for Nullitics analytics)
maxmind:
account_id: "123456"
license_key: "abc..."Litestream provides continuous replication of all SQLite databases to S3-compatible storage:
Setup: Configure S3-compatible credentials in the admin panel at /madmin/settings.
What gets replicated:
- Main database
- Solid Cache
- Solid Queue
- Solid Cable
Commands:
rails litestream:replicate # Start replication
rails litestream:restore # Restore from backupSee config/litestream.yml for full configuration and CLAUDE.md for details.
MIT
Built by Yuri Sidorov following best practices from 37signals.