From local storage To-do list to Fractal, Peer-to-Peer Habit Tracker
Part 1: Beginnings
“It started with a liiiist”
It started with a To-do list. The word(s?) lost all meaning…
‘Add To-do item’
‘Delete To-do’
‘Add new To-do list’
‘To-do or not To-do…’
We’ve all been there; after all, it’s a canonical CRUD example. As somebody who was drilling code problems all day, it was a step up to something a little more cohesive. For me it was also an introduction to Sinatra and Rack-based frameworks in general.
I persisted as long as I needed to and moved on — exploring what else Sinatra was capable of. It led me to develop a multi-page app that would store data on tracking personal habits — exercise, meditation, diet etc. I stored an array of linked lists (habits) which had a boolean value (completed/not completed) for each day of tracking.
Most of my time was spent prettying the front-end with Bootstrap and more JavaScript than was strictly necessary, appropriating SwiperJS so that I could swipe back and forth between consecutive tracked days. I stored each habit as a node in linked list, visualised by a triangle, and tried extending Flexbox (gasp) to allow an inverted ‘stacking’ of the triangles into a ‘Habit Pyramid’.
I was pleased with my progress, but not pleased enough to draw a line under it. There was a bigger, more scalable project lurking underneath the cluttered codebase.
Enter Uncle Bob
They say Mastery involves mentorship. I feel lucky to have studied (and currently finishing) the Launch School curriculum where they put a total focus on these principles. I have to admit having deviated from strictly following the course in sequence, deciding to get lost my fair share of rabbit-holes throughout the last 2 years of study, but always returning to their trusted and valued community.
One of the more recent but inevitable diversions was a video by Robert (‘Uncle Bob’) Martin: Architecture, the Lost Years. I had hear about SOLID principles of design but it seemed a bit too advanced for me, still mastering the basics of HTTP requests and JavaScript object creation.
This video stretched, or should I say expanded, my comprehension of what I could build. It got me thinking about how I can de-couple the application layer from the persistence layer. I had heard of Uncle Bob before, but seeing his presentation made me understand why he was so valued to the industry… and now separation of concerns makes so much sense!
With a mind to develop decentralised applications later on down the line, I suddenly saw the possibility of extending Habit Triangles to be a social app, where we could encourage each other to develop self-actualising habit patterns and retain sovereignty over our private data. Holochain is what inspired this; fall into that rabbit hole if you choose.
A new goal: create a version of Habit Pyramids that can take any type of data store. ‘Defer important decisions as long as possible’.
Whether to use traditional client-server architecture or decentralised/distributed architecture seemed like a suitably huge decision.