Motivation ⇡
Self-introduction into Roda, Sequel ecosystem and Zeitwerk autoloading.
Setup ⇡
- Install dependencies:
bundle install
- Configure the
.env
file
touch .env
# Generate a secret key:
ruby -r 'securerandom' -e 'puts "SECRET_KEY=#{SecureRandom.hex(32)}"' > .env
# Add database name:
cat "DATABASE_NAME=YOUR_DB_NAME" > .env
- Prepare the database (sqlite3):
bundle exec rake db:create
bundle exec rake db:migrate
- Run Puma application server at
http://localhost:9292
with a Rake default task:
rake
# OR to run explicitly:
rake start
Application structure & architecture ⇡
The application is built with:
- Roda routing toolkit for routing
- Sequel for database connection, migration and ORM
- sequel_tools to use Rake tasts for DB operations
- Zeitwerk to autoload/reload application during development
- dry-configurable for
ApplicationSettings
class to store application settings - tilt & erubi for the view layer
- Entrypoint:
config.ru
require
sconfig/boot
require
sconfig/application_loader
andconfig/application_settings
config/application_loader
sets up the zeitwerk gem, which autoloads the wholeapp
directory- Rack runs the
Router
fromapp/router.rb
(basically the application itself, with routes and actions)
Models are in app/models
directory.
Views are in app/views
directory. Partials are supported as well.