Building Forty In The Open
published Saturday, February 27, 2021
I've built Forty in the open using public GitHub repos because I believe in the ideas of the Open Source by Default movement. There are three main repos that might interest you: forty-site, forty-web and forty-time-management. Here I'll summarize these projects and how I've used them to build the application. I can talk freely about all this stuff because they are open source - my favorite part of embracing Open Source by Default!!
The Forty web app is setup on the
app subdomain and the marketing site links
to it. It's a Rails application deployed to Heroku. It uses
Postgres for persistence, Sidekiq for background jobs and takes
advantage of React for a couple complex interactions.
I've integrated with Stripe for payment, specifically their Stripe Elements product that has great React support. I'm using the Webpacker gem and that pipeline to serve React components authored in Typescript.
For testing I use RSpec and Jest. There's some system tests that spin up headless Chrome using the Webdrivers gem to simulate user behavior and on the other end I have Enzyme setup so I can get good unit tests around the React component stack.
This is an interesting little project! The goal here is to ensure consistent behavior across Ruby and Typescript when it comes to dealing with time amounts. The problem to solve is that I use Ruby on the server and Typescript on the client for the same operations. If I'm going to add up ones time for a given week, I better get the same total on the server as I do on the client.
My approach to this problem was to create a single repo that produces both a Ruby gem and an NPM package. I wrote tests for each language so I can evolve my business logic but ensure each language behaves the same. They are published in unison using CircleCI.
For example, I have a Ruby class called
to_s to convert some number of minutes into a nicely formatted
string. I have the same sort of thing in Typescript with a class also called
FortyTime that has a
toString function. I drove out both of
these implementations with tests that match and now I can ensure whether I'm in
Ruby or Typescript that going from minutes to strings will work consistently.
Working in the Open
Having these repos public on GitHub means I'm working in the open and that frees me to talk about the code that I've built in whatever way I want. It's like a free source of content marketing ideas! And should I want to impress a potential employer at some point they'll be able to see exactly how I've built my side hustle down to the PRs I write to myself.