Novel Novels —Stepping Into React + Rails

This August, a professor’s casual review of the New York Times’ “By The Book” column led to a startling conclusion. Male authors recommend other men’s books more than four times as often as they recommend women’s books.
Well, maybe it isn’t so startling.
After all, those “Top 100 Books of All Time” lists tend to skew as much as 70% or 80% male. Anecdotally, they also tend to be dominated by European and American authors. Contemplate for a minute: how much of your bookshelf is filled by the voices of males from Europe and the United States?
I thought it’d be nice to get a concrete answer to that question, so I decided to build a visual representation of the demographics of my Goodreads shelf. Along the way, I also learned a lot about Rails, React, and a whole bunch of other paradigms in web development.
The ultimate goal is to offer personalized recommend from underrepresented authors, diversifying our collective bookshelves. For now, the platform is just a sanity check on what we’ve been reading. If you have a Goodreads account, check it out at Novel Novels!
Building this interface was my first real foray into web development, and a chance to explore Ruby on Rails and React. I built a traditional REST API with Rails: to access users’ shelves, I used the excellent goodreads gem; to pull in demographic information about each book, I set up calls to the LibraryThing API (LibraryThing stores demographic information about millions of books and authors). The trickiest part of the Rails work was setting up OAuth for users to log in to their accounts, and navigating Goodreads’ spotty API documentation.
I used Webpacker and the react-rails gem to bring a React frontend into the Rails project (more on that later). With that setup complete, building the frontend in React was quite smooth, thanks to my previous experience with the framework. After building the skeleton of the app — asynchronous fetches to retrieve the user’s shelf and demographic data — I used recharts for plotting graphs, then threw in some basic Bootstrap styles and a navbar.
Technical Lessons Learned:
- If I could go back, I would completely decouple the React frontend from the Rails backend. In an age of modern JavaScript frameworks, there doesn’t seem to be much purpose in wrapping the whole React frontend into the Rails repo. Also, I would have avoided the react-rails package and Webpacker installation, and the headaches of using Webpacker to install npm packages.
- To my mild surprise, I couldn’t find any public APIs to get personalized book recommendations. The biggest providers, like Goodreads and Amazon, keep their recommendation APIs private, probably for good reason. If you know of any, I’d love to use it!
- Design is hard!
Going forward, I hope to implement the personalized recommendation system, introducing readers to more underrepresented authors. Again, you can check out the site at Novel Novels: if you have any feedback or ideas, please leave a comment!