Overview
Sales Points is based on Ruby 3.4.2 and Ruby on Rails 8.0.2 (see Gemfile).
It requires a JavaScript engine and a mysql dev kit like libmariadb-dev.
To setup the development environment:
- Install ruby
- Install a JavaScript engine
sudo apt update && sudo apt install nodejs -y - Then run:
bundle install --gemfile /workspaces/sales-point/Gemfileto install all rails gems - Install at least a mysql dev kit like
libmariadb-devif bundle install fails formysql2.
All this is provided in the vscode devcontainer dockerfile .devcontainer/Dockerfile.
The only thing left is to run:
bundle install --gemfile /workspaces/sales-point/Gemfilecargo install mdbook
These are not yet integrated into the dockerfile.
Frontend
The frontend is based on Bootstrap 5.3.2 (see installation guide).
Live updates are implemented using turbo streams. The order screens (pending and history) are dynamically updated using separate turbo streams. There is one stream for the history, one for pending and one for the kitchen station summary. See https://blog.corsego.com/turbo-hotwire-broadcasts for a tutorial.
For the order history view the list is paginated with the pagy gem to handle many orders. The pending screen shows only 100 pending orders to limit the loading time.
Backend
To support active jobs and turbo streams we use SolidQueue and SolidCable gems introduced in Rails 8.
These require to setup a database for the queue and cable. We use the default sqlite approach and configure the development environment to match the production environment. To setup these, follow the official docs for SolidQueue and SolidCable.
SolidQueue integrated into puma
The SolidQueue supervisor must either be run as a separate process or can be integrated into the puma server. We use the integrated approach and must set the puma config correctly.
In config/puma.rb the solid_queue plugin is loaded depending on the SOLID_QUEUE_IN_PUMA environment variable.
For development, we always load the plugin independent of the variable.
For production, this variable must be set in the host or configured to true via the kamal config in config/deploy.yml (which will set it in the host).
Time zone setting
The rail application is configured to use a time zone via config.time_zone in application.rb.
An alternative, but unnecessary, way would be to set the container's time zone the simplest is to edit the symlink of /etc/localtime.
For this run ln -fs /usr/share/zoneinfo/Europe/Zurich /etc/localtime in the container.