Templatus Inertia

screenshot of Templatus Inertia
rails
svelte
vite
tailwind

Opinionated template for starting new web applications with Ruby on Rails and Inertia (using Svelte.js)

Overview:

Templatus is an opinionated template for building web applications with Ruby on Rails and Inertia using Svelte.js. It simplifies the process of setting up a new application while following best practices. The template provides a live demo and has sister repositories for alternative approaches using Hotwire and API instead of Inertia.

Features:

  • Backend:

    • Ruby 3.2
    • Ruby on Rails 7.0
    • ActionCable for WebSocket communication
    • PostgreSQL for using as SQL database
    • Sidekiq for background processing
    • Redis for caching, ActionCable, and Sidekiq
  • Frontend:

    • Inertia as a protocol for frontend/backend communication
    • Tailwind CSS 3 to not have to write CSS at all
    • Tabler Icons for free SVG icons
    • Vite for bundling JavaScript and CSS with Hot Module Replacement (HMR) in development
  • Development:

    • Puma-dev for using .test TLD (instead of localhost:3000) and https in development
    • Foreman for starting up the application locally
    • dotenv to load environment variables from .env into ENV
    • TypeScript for writing strongly-typed JavaScript
    • Prettier for auto-formatting TypeScript and Ruby code in Visual Studio Code
  • Linting and testing:

    • RuboCop for Ruby static code analysis
    • RSpec for Ruby testing
    • ESLint for TypeScript static code analysis
    • Cypress for E2E testing
  • Deployment:

    • Docker for production deployment, NOT for development
    • DockerRailsBase for fast building an optimized Docker image based on Alpine Linux
    • GitHub Actions for testing, linting, and building Docker image
    • Dependabot configuration for updating dependencies (with auto-merge)
    • Ready for serving assets via CDN like CloudFront
    • Honeybadger for error tracking in Ruby and TypeScript
    • Plausible for privacy-friendly analytics
  • Production:

    • Lograge for single-line logging
    • Gzip and Brotli compression of dynamic responses (HTML, JSON) using Rack::Deflater, Rack::Brotli
    • Fine-tuned Content Security Policy (CSP)

Installation:

To install Templatus, follow these steps:

  1. Install Ruby 3.2 and Ruby on Rails 7.0.
  2. Set up a PostgreSQL database and configure the connection in the Rails application.
  3. Install Sidekiq and Redis for background processing and caching.
  4. Set up the frontend with Inertia, Tailwind CSS 3, Tabler Icons, and Vite.
  5. Install the necessary development tools like Puma-dev, Foreman, dotenv, TypeScript, and Prettier.
  6. Set up linting and testing with RuboCop, RSpec, ESLint, and Cypress.
  7. Configure the deployment process using Docker, DockerRailsBase, GitHub Actions, Dependabot, and CDNs.
  8. Set up error tracking with Honeybadger and privacy-friendly analytics with Plausible.
  9. Configure the production environment with Lograge, compression using Rack::Deflater and Rack::Brotli, and a fine-tuned CSP.

Summary:

Templatus is a comprehensive template for building web applications with Ruby on Rails and Inertia using Svelte.js. It includes a wide range of features and technologies for both the backend and frontend development, as well as tools and configurations for development, testing, and deployment. The template focuses on optimized performance and security, as evidenced by the benchmarks performed on the demo installation. Templatus aims to simplify the process of setting up a new application while following best practices.

rails
Ruby on Rails

Ruby on Rails, often referred to as Rails, is an open-source web application framework written in Ruby. Known for its convention over configuration and don't repeat yourself (DRY) principles, Rails simplifies and accelerates the development of database-backed web applications.

svelte
Svelte

Svelte is a modern front-end framework that compiles your code at build time, resulting in smaller and faster applications. It uses a reactive approach to update the DOM, allowing for high performance and a smoother user experience.

vite
Vite

Vite is a build tool that aims to provide a faster and leaner development experience for modern web projects

tailwind
Tailwind

Tailwind CSS is a utility-first CSS framework that provides pre-defined classes for building responsive and customizable user interfaces.

template
Templates & Themes

A template or theme refers to a pre-designed layout or structure that provides a basic framework for building a specific type of application or website. It typically includes good design, placeholder content and functional features, allowing developers to customize and fill in the details according to their specific needs.

eslint
Eslint

ESLint is a linter for JavaScript that analyzes code to detect and report on potential problems and errors, as well as enforce consistent code style and best practices, helping developers to write cleaner, more maintainable code.

postcss
Postcss

PostCSS is a popular open-source tool that enables web developers to transform CSS styles with JavaScript plugins. It allows for efficient processing of CSS styles, from applying vendor prefixes to improving browser compatibility, ultimately resulting in cleaner, faster, and more maintainable code.

typescript
Typescript

TypeScript is a superset of JavaScript, providing optional static typing, classes, interfaces, and other features that help developers write more maintainable and scalable code. TypeScript's static typing system can catch errors at compile-time, making it easier to build and maintain large applications.