I have a personal project I want to put into practice, at the intersection of art and development. This post will be a living repository of this journey. I was inspired by a passage from Austin Kleon’s book “Share Your Work!”, in which he encourages you to be less of a hoarder, less of a spammer, and more of a contributor:
“Make stuff you love and you’ll attract people who love that kind of stuff.”
and
“If you want to get, you have to give. If you want to be noticed, you have to notice. […] Don’t turn into human spam.”
TL;DR
Go ahead and explore the bare bones version, it’s now live!
The idea
Some novelists choose to open their books with a quote from another writer. This is called an epigraph. These quotes taken out of their original context are given a new life, necessarily detached from the former one. Since writers are the utmost specialists in their fields, and since the beginning of a work has such relevance to the whole, I risk saying that these selected quotes will necessarily be the crème de la crème of the world’s literature. Change my mind.
The how
So I set out to build a crowd-sourced platform to compile said epigraphs and link the authors among themselves. Authors that are quoted and that quote and that are themselves quoted again.
On the platform you can choose to peruse ancient pearls of selected wisdom, or simply hop from author to author and see what they’ve been up to. At least that’s the original view. Let’s see where this lands after iterations and feedback from friends and fellow intellectuals.
The tools
This is a very basic CRUD web application. Essentially a related database of quotes and authors. In my developer / architect life I have focused on brochure websites, displaying information input via a CRM, or Single Page Applications such as cadamaca.co.
It’s been a long time since I got near a more database-centered web app. But I know Ruby on Rails was made for this, it has been battle-tested and has cool values behind it (I have been following 37 Signals since my Parisian days, circa 2009).
I have installed Ruby on Rails following the official guide and the one on GoRails.
The mockup
I used the excellent, browser-based penpot.app to lay out a rough mockup of what the main pages in the app would have. This is so I don’t forget what features and behaviour the app is supposed to have, as I dive deep into the nitty gritty of Ruby and Rails. Reminder that I don’t code in Ruby (yet).
Starting from the 101
I finished the proof of concept blog from the original guide, and loved the simplicity and intuitiveness I remember Rails had. Ruby is a human-centered and frankly quite fun language, so I am happy to explore more of it.
There are some really fresh and exciting ideas, some of which I have also seen in VueJS. Elegant design goes a long way for me, it gives me that pleasure when developing that can help me breeze through the day as I build, following The Happy Path. This is a feature.
Creating the first entities aka resources
I’m laying out the relationship between Books, Authors and Quotes as so:
A book has an author, the writer who wrote the book. The book also has an epigraph (or more) that opens it. This epigraph (or quote) also has an author. This author is the author of other books, and this is where the plot thickens. I don’t know if this kind of strange loop is allowed in database management. Stick around, find out.
Since this is the first stone cast on this future open source super-app, I also started committing to a repository on Github.
The environment
I’m running my Ruby and Rails environment on an Ubuntu (Linux) install, and am loving it. I have all the apps I need for productivity (code as IDE, Firefox for web browsing and testing, DB Browser for SQLite, gitg for visually analysing my repository, Typora for markdown notes), and the system is fast and snappy. I’m not looking back (sorry, Apple).
One powerful tool that comes out-of-the-box with Ruby / Rails is the console:
You can easily interact with the database, and produce all those good CRUD commands using this CLI tool. It’s smart in the sense that it provides relevant suggestions, and is very intuitive to use.
After some back and forth I slowly begin to get a grip of the Rails WayTM. Created the migrations according to my envisioned schema above:
Had to remove some constraints through more migrations (an Author can simply be quoted by another Author, and thus have no books), but finally got to a good place (I hope!). I can now display all data related to a specific quote in the quote’s Show view:
Actually, no. My good friend Francisco, a talented backend developer (link to follow soon), pointed to the fact that with this DB schema an author could only have one book, and one book alone. So I proceeded to redesign the schema and ended up with this one:
It’s quite the clever strategy from the ROR folks to have each edit on the database be a single migration file, and those edits can be short cut using the CLI. It took me a while to understand how to migrate, rollback, edit the migration files, but I start getting the hang of it.
So much so that I think I finally laid down the basic structure of this simple database-powered web application. I started adding quotes, and I have very rough versions with data for each resource index and show pages:
The production environment
It’s important to deploy early to a real-life scenario, so you can detect errors or misconfigurations early in the development process. For openingquot.es I used Render (things are still under heavy development and will potentially break. Come back in five minutes if they do.), as I had a great experience with cadamaca.co and anyway everyone seems to point to their free tier for hobbyists artists like myself.
I created a Blueprint following this honeybadger.io guide and everything went smoothly until I hit a database migration wall:
I did a lot of back and forth until I got the DB schema right, and at some point I was trying to remove a column that no longer existed.
Anyway, and to ensure the compatibility between my local setup and the production machine, I switched my development database from SQLite3 to Postgres. Now I have no database content, so instead of recreating everyone and their epigraphs, I’m just going to drop in some fixtures that will initiate the DB with initial content as we go. Hope this works!
Update: the best way to do this in my case is to use “seeds”. Simply write them in Ruby and run:
bin/rails db:seed
from your project root directory.
Meanwhile, as I committed changes to remove the problematic migration AND switched my development DB to Postgres, my build went green!
One last piece of the architecture I was missing was CSS compiling. I am long-time fan of SASS, and after some digging around the somewhat cryptic Assets Pipeline, I realized using the gem dartsass-rails is recommended. This is how I am used to compiling SASS while developing, having a process watch my *.sass
files and compiling them to .css
on save. It’s pretty flawless and lean.
It turns out that setting Dart Sass up isn’t necessarily trivial, even if the documentation is excellent. In my case everything was working in my dev environment, but not in my production environment. It took me the good part of the afternoon + a bit into the night to understand the problem, and I could only crack it in the morning, after a long night of restorative sleep and whacky dreams.
I had to keep the .keep file. But hey, at least now I have an idea of how Sprocket and Dart Sass work together. Man, (web) development takes perseverance. I guess this is how one learns.
My whole app is now up and running on my Render instance (things are still under heavy development and will potentially break. Come back in five minutes if they do.). Exciting times!
Now I can go back to expanding the features and the content on the app, and my production version will be up to speed with my development environment, always. Nice.
I went ahead and registered the domain openingquot.es, and proceeded to configure the DNS records so it points to my new app on Render. These are the most exciting days, when something wasn’t, and then is.
__
Share your thoughts and stay tuned for more developments on Mastodon, on Reddit or here.
Tu és um idiota (com muitas ideias) muito girinho. Estás pronto para fazer uma tese, arrisco-me a dizer.
Takes one to know one, meu amor!
Tchiii, granda trabalheira. Nice!