This application, Platters, is an example web application developed using the Ruby on Rails web framework and associated technologies.
The Platters application is my complete album collection converted into a database-backed web application with optional user registration, log in and commenting components.
Platters is primarily a server-side application with sprinkles of JavaScript. Note, using a client-side JavaScript framework, such as Ember.js or React, was ruled out due to complexity for such a small application such as this.
- Font Awesome
- Bootswatch
- jQuery
- Kaminari
- FriendlyId
- CarrierWave
- Clearance
- JWT
- Rack::Attack
- Bootsnap
- local-time
- invisible_captcha
- Rinku
- obscenity
- New Relic
- Lograge
- Faker
- Jbuilder
- DigitalOcean
- Ubuntu Server
- Rackspace Cloud Files
- Mailgun
- Skylight
- Rollbar
- Namecheap
- Let's Encrypt
- Mina
- ruby-install
- chruby
- Fail2ban
- jemalloc
All form submission buttons use the Rails Unobtrusive JavaScript (UJS)
data-disable-with
functionality to disable, and display a spinner icon,
whilst a submitted form is being processed.
Certain form elements, such as Artist name and Album title, are validated client side for blankness in addition to traditional server-side validation.
This Rails application uses Turbo Drive for performant in-app page to page navigation. The Turbo top-of-page progress bar is enabled to provide visual feedback for page navigation that takes longer than 500ms. Turbo Drive also loads visited in-app pages from an internal transition cache, this will result in near instant page loads for cached pages, with later automatic page refresh if page changes have occurred. The transistion cache is disabled only for the randomized albums page due to a jarring effect with cover images.
Artist and Album search both use the PostgreSQL @@
text search operator
which provides support for: English dictionary stemming, multi-word search,
stop words, and fuzzy text search for misspellings.
Flash notice messages, as seen during resource creation, deletion and modification, will automatically hide, then be removed after a few seconds as well as being user dismissible.
Album, artist and user Comments will be displayed in bundles of 25 at a time, newest to oldest. Scrolling to the end of a page of comments will result in the retrieval of the next 25 comments, and so on until all comments have been retrieved. Whilst comments are being retrieved a spinner icon will be displayed until that batch of comments have been appended to the page. This behaviour is modelled on Twitter infinite scrolling.
Albums with more than twenty tracks will, by default, show only the first twenty tracks with a fade effect over the last four tracks of those twenty. A toggle is available to show all tracks, and once selected a show less toggle is then provided.
Users are only allowed to post 100 comments per-day. This will prevent rogue users abusing the site.
Comments can be posted for artists and albums, hence individual comments can belong to either an artist or album instance. Polymorphic associations are the most elegant way to model this multi-owner relationship.
Counter caches are a mechanism to efficiently return the number of records through a has_many association. Using counter caches avoids the SQL COUNT operation which is an expensive operation especially for very large tables. Counter caches are defined for: Artist albums_count, Artist comments_count, Album tracks_count and Album comments_count.
The separate React-based front-end application uses JSON Web Tokens for sesssion management. The tokens created by this server are short-lived (30 minutes), but can be unobtrusively refreshed (up to 6 months). Note, resetting a user password via Forgot Password? in the front-end application will invalidate all current API sessions for that user, useful if the user has had their session hijacked via a lost or stolen machine.
Ruby on Rails was chosen early on, from a host of possible web development choices, due to the following appealing factors:
- Developer happiness and enjoyment.
- Unix based tooling, development and hosting.
- Active communities, both locally and abroad.
- Future employment possibilities.
- Gateway to interesting new technologies.