Skip to content

OkayDave/sprint_zero

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

62 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

⚠️ This is a work-in-progress and not yet fit for human consumption ⚠️

CI

SprintZero

Kickstart your next Rails project with sensible defaults and a curated setup.

SprintZero is a boilerplate Ruby on Rails application designed to save time and effort when starting a new project. It comes pre-configured with modern defaults and carefully selected tools so you can get straight to building your app — not configuring it.

Setting up a new Rails application can often feel repetitive — setting up the same gems, tweaking the same config files, installing the same frameworks. SprintZero removes that friction. Clone it, rename it, and you're off.

✨ Features

  • Ruby 3.4.2 & Rails 8.0.2
  • SQLite3 for development database
  • Turbo and Hotwire enabled out of the box
  • Bulma CSS framework for sleek and responsive UIs
  • HAML templating for cleaner view code
  • Brakeman, Bundle Audit, and Rubocop for security and linting
  • Rspec for robust testing
  • Avo as the admin panel
  • Anthropic's Claude Sonnet for AI/LLM integration
  • Devise and Pundit for authentication and authorisation

🧰 Included Gems & Tools

Purpose Gem/Tool
Admin Panel avo
AI omniai_anthropic
Authentication devise
Authorisation pundit
Database sqlite3
Frontend bulma-rails, stimulus-rails, turbo-rails
Linting rubocop
Local Development awesome_print, bullet, dotenv, letter_opener, overcommit
Pagination pagy
Rails rails 8.0.2
Ruby ruby 3.4.2
Security Scanning brakeman, bundle-audit
Testing capybara, factory_bot_rails, faker, pundit-matchers, rspec-rails, rswag, simplecov
View Templates haml-rails

📦 Helpful Concerns

Slugged

The Slugged concern provides URL-friendly parameterisation for your models. When included, it:

  1. Overrides the to_param method to create SEO-friendly URLs
  2. Provides a name_or_title method that intelligently selects the best identifier for your model

Usage

class Article < ApplicationRecord
  include Slugged
end

# to_param override
article = Article.create(name: "My First Article")
article.to_param # => "123-my-first-article"

# url helper
article_path(123) # => "/articles/123-my-first-article"

The #name_or_title method will look for attributes in this order:

  1. name (if present)
  2. title (if present)
  3. slug (if present)

If none of these attributes are present, #name_or_title will return a blank string, and #to_param will fallback to default Rails behaviour; so article_path(123) # => /articles/1

HasAIContent

The HasAIContent concern assists with automatically generating content with Anthropic's Claude Sonnet.

See the StaticPage model for an example of its implementation.

First, you must create an AI::Prompt (easy via the avo panel /admin).

You should then add the relevant columns to the Model you wish to generate content for.

class AddAIContentColsToArticle < ActiveRecord::Migration[8.0]
  def change
    add_column :articles, :content, :text # omit if you're using ActionText for content
    add_column :articles, :prompt_id, :integer
    add_column :articles, :prompt_additions, :text
    add_column :articles, :generate_content_on_create, :boolean, default: false

    # add_index :articles, :prompt_id # optional, add this if you're planning on querying based on prompt_id
  end
end

Include the Concern

class Article < ApplicationRecord
  include HasAIContent
end

Set the prompt_id, prompt_additions, and generate_content_on_create before saving the new record.

@article = Article.new(article_params)
@article.generate_content_on_create = true
@article.prompt_additions = "This article is about how much fun the Ruby programming language is. Please write an article about this with 5 mind-blowing facts about Ruby."
@article.prompt_id = AI::Prompt.first.id
@article.save

Provided @article is valid, a background job will be created via AI::GenerateContentFromPromptJob which calls the AI::ContentGenerator service. This service will build a prompt based off the provided AI::Prompt and @record.prompt_additions and return the results to @record.content once complete.

🚀 Getting Started - Making SprintZero your own

SprintZero is intended as a one-off starter kit rather than an engine/template/generator or whatever. It's not something you would update your own repo against in the future.

Clone -> Personalise -> Crack On.

So, first thing you need to do is treat yourself to a new repo on Github or Gitlab or whatever you're feeling.

Then, grab a clone of this repo.

git clone git@github.com:OkayDave/sprint_zero.git your_new_app_name
cd your_new_app_name

After cloning, you'll want to adjust the origin to your new repo

# Remove the SprintZero remote
git remote remove origin

# Add your new repository as the origin
git remote add origin git@github.com:your_username/your_new_app_name.git

# Give it a cheeky push, if you like
git push -u origin main

Get you .env files in order. I'd recommend having separate files for each env:

  cp .env.example .env.development.local
  cp .env.example .env.test.local

Replace the values within these two new files with your own.

Replace references to SprintZero with your own app name. I use Find and Replace in my editor but if you're brave and smarter than me you could use something like sed. Here's what you're looking for though. There's around 40ish references in total.

sprintzero
SprintZero
sprint_zero

Generate a new config/master.key by throwing away the current secrets and creating a new one.

rm config/credentials.yml.enc
bin/rails credentials:edit 

Make any changes you need to your Database setup. I default to sqlite3 with values declared in the .env*.local files, so if you want to use an alternative datastore then you'll also need to add the supporting gem to the Gemfile.

Last thing is to run the bin/setup script. This will install your bundle; install your js dependencies; configure pre-commit Git hooks via overcommit; and create your DB with the schema and seeds.

bin/setup

Now you're ready to roll. The procfile is configured to run rails s, watch for CSS changes, and run the worker processes.

bin/dev

Have fun, you productive, magnificent person!

Environment Vars

SprintZero uses dotenv for environment configuration.

See .env.example and copy the file to your *.local overrides as described in the instructions above.

DB_HOST=localhost
DB_USER=local
DB_PASSWORD=password
DB_NAME=storage/sprintzero.sqlite3
DB_QUEUE_NAME=storage/sprintzero_queue.sqlite3
DB_CABLE_NAME=storage/sprintzero_cable.sqlite3
DB_ADAPTER=sqlite3
ANTHROPIC_API_KEY=your_anthropic_api_key
JOB_CONCURRENCY=1

Git Hooks

SprintZero uses overcommit to manage Git hooks. When you first clone the repository, run:

The following pre-commit hooks are configured:

  • RuboCop: Automatically fixes style issues and fails if there are unfixable issues
  • RSpec: Runs the test suite and fails if any tests fail

Cursor Rules

I've added a couple of rules for Cursor's AI Agent. You can find them in the .cursor/rules folder.

These set out my guidelines for how Cursor returns autocompletions, suggestions, and generated content.

I currently have rules for Ruby implementation code and Rspec tests. They're not perfect but they work quite well.

Alternative Rails Starter Apps / Generators / Templates

SprintZero isn't the only offering in the community. There's a few others, with different bundled software, pricing, licensing, defaults, configurability, etc.

For example:

💡 Contributing

Feel free to fork, clone, and make PRs. If there's a configuration or gem you think should be included, open an issue and let's discuss.

About

My opinionated 'rails new' starting point

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •