This is my submission to the Myndstream Software Engineer Challenge.
I used the latest Ruby 3.4.1 and Rails 8 with Stimulus. Other notable gems include:
- ahoy for handling events
- phlex-rails for view component encapsulation
- wahwah for audio file metadata extraction.
- css-zero
- vite_rails
Audio playback in the frontend is handled by howler.js.
bundle install
rake db:create db:migrate db:seed
bin/dev
Open your browser to localhost:3000 and login with [email protected] / password. Click the play button and open the javascript console to view the data getting sent. You can also visit /events to view a sortable table of events data.
Tests are written with minitest and shoulda-context, can be run with rails test
.
I also added an /events table to view the data. It uses turbo to automatically update as new events are created.
- simplify use of Ahoy gem
-
e.g. use javascript ahoy.event() instead of fetch().
I didn't do this at first because ahoy_events schema had properties as a text field with serialized json. I modified it to a json field, but for performance it's better to have normalized columns.
-
there is also an
/ahoy/events/
controller that could be used rather than a custom API controller.
-
- I used the quick-and-dirty Rails 8 generator for authentication. In hindsight, I think authentication-zero is superior.
- use JWT for API authentication, allowing for front-end hosting on different server.
- switch Ahoy::DatabaseStore to Kafka
- Use Signed Expiring Links with AWS S3 to access music files
- For security, /events reporting page should not be accessible by regular users, but only admin users. Also it should have pagination because it will be unwieldy as data grows.
Song A:
Purple Dream by Ghostrifter bit.ly/ghostrifter-yt
Creative Commons — Attribution-NoDerivs 3.0 Unported — CC BY-ND 3.0
Song B:
Heart Of The Ocean by Purrple Cat | https://purrplecat.com/
Creative Commons CC BY-SA 3.0
https://creativecommons.org/licenses/by-sa/3.0/