SigmaFit: Workout tracking made easy

SigmaFit: Workout tracking made easy

Aug 1, 2022ยท

7 min read

Hey folks ๐Ÿ‘‹. This post is my submission for the planetscale hackathon. It covers all aspects right from motivation to implementation part. I trust that you'll enjoy reading this one. So without further ado, let's begin!


๐Ÿ’ฌ Inspiration

A few months back, I started hitting the gym. Everything was just excellent; I was happy with my Newbie Gains ๐Ÿ’ช. But then I noticed something peculiar. I often saw people (including my gym bro) tracking their progress on Google Keep, and a few were even using Whatsapp and Telegram chats ๐Ÿ˜•. Is this the best way?

Ask them how much you lifted last Saturday; they will be scrolling their phone for eternity. ๐Ÿฅบ Many people don't even realize if overall their fitness and weight training journey are improving or not because of a lack of data-driven insights.

And let's not forget the painful process of typing the workout name, date, and sets repeatedly! ๐Ÿ˜ฃ

PS: Here is a telegram chat which we shall make obsolete. ๐Ÿ˜Ž



โœจ Presenting SigmaFit

sigmafit landing page

โšก๏ธ Features

  1. Track Everything: Log all your workouts on SigmaFit. It's simpler and more rugged than any notes-taking app out there. It will help you with the planning, execution and tracking of progress.
  2. Wide support: SigmaFit lets you log the thing you want to track. You can track distance, duration, weight, reps, and anything based on your workout requirements.
  3. Fully customizable: In SigmaFit, it's super easy to get started with community Training Routines. You can build your custom workout plan too. SigmaFit is super customizable, and creating a training routine is a cakewalk.
  4. Record History: Personal Records are not just any numbers. They're very special for every athlete out there. SigmaFit keeps track of it and provides extra motivation to make it even bigger!
  5. Sharing is caring: If you've created a training routine you're particularly proud of, you can share it with the community and friends.
  6. Available on all devices: SigmaFit is a progressive web app. You can run it on any browser environment. It takes lesser resources and is blazingly fast ๐Ÿš€.
  7. Superb easy onboarding: SigmaFit offers convenient ways of signing in using social auth like Google, Twitter and GitHub. No need to memorize another password for our platform.

๐Ÿ’ผ Entity Relationship diagram

I really like planning before taking the first step. So, after finalizing the features to include in SigmaFit MVP, I started working on the Entity Relationship Diagram (ERD). Here is the ERD built using


๐Ÿ“Ÿ Tech Stack

Sigma is built using the following technologies.


๐Ÿฅน Quick Demo

Ignore my poor video editing skills. It was my first time. ๐Ÿ™‚

๐Ÿ‘จโ€๐Ÿ’ป Building SigmaFit: Implementation Details

๐Ÿ“˜ Monorepo setup

Usually, when we build these full stack applications, there are two major components: backend and frontend. But often, we have shared logic used by both of them. How do we share it effectively without duplicating code?

Here comes the magic of monorepos, and yarn workspaces. Setting up was pretty simple. We just need to define apps, configure nohoist (if required), write scripts etc, in package.json.


๐Ÿ—ƒ Implementing Backend

After the monorepo setup, I started with implementing the backend. It was a straightforward workflow. Implement a specific logic, export the functionality carefully as an API, and finally test it on Postman.


While implementing a few features, I had to write a few raw SQL queries to keep things performant compared to what Prisma ORM can offer. The following is the largest of all, spanning over 74 lines. (Even I'm scared of it now. ๐Ÿ˜ฑ)


๐ŸŽฎ Implementing Social Auth


Reason: So far, I've always built apps which allowed signIn through email and password; But we all are now visiting millions of websites, and keeping track of passwords is a headache. Password managers are a thing, but I never find them convenient on mobile devices. So because for the following reasons, I went ahead with Social Auth. Also, the number of spam users on the platform will reduce drastically.

In case you're curious about my other projects. Feel free to check out my github profile.

Here is a simplified OAuth flow we're following. Please note that different providers have slightly different flows, but the overall spec is kinda same.

Pro tip: Login with GitHub is the best and easiest to implement. No confusing docs, no weird bugs etc.


๐ŸŒ Implementing Frontend

This part took a lot of time. A good UI makes or breaks a product, and SigmaFit is no exception.

fun fact: I never consider myself a frontend developer, and I'm just terrible at it. The first time I worked on the front-end was because none of my hackathon teammates wanted to do it (back in my college days).

SigmaFit uses Next.js for building the frontend. I'm primarily a big fan of Next.js routing logic and page organization features.

Notable features Demo

  1. Draggable Blocks: draggable.gif

  2. Pagination: pagination.gif

  3. Navbar animation navbar.gif

  4. Training insights: insights.gif

๐Ÿš€ Deployment

  1. Buying domain: It was very easy. Fill in the details, and get your domain. I got it for free using GitHub Student Developer Pack. image.png

  2. Setting up Cloudflare: Strictly speaking, this step is optional. My initial plan was to use it for path-based routing. The idea was to forward all requests with slug /api/** to backend infrastructure and all others to the frontend vercel server. But it turns out that this feature is only in the Enterprise plan ๐Ÿ˜ญ. Still, there are many other benefits of having Cloudflare, like DDoS protection etc. image.png

  3. Setting up deployment pipeline: Finally, we deployed the frontend on vercel, and the backend on Heroku. Building a deployment pipeline at both of these was very smooth. And now we just had to wait for the pipeline to finish...... image.png

๐Ÿ˜ฅ Challenges I faced

  1. While implementing Twitter OAuth 1.0, I faced many issues. There's insufficient official documentation, and figuring out things from outdated blog articles was difficult.
  2. Initially, I didn't know that planetscale databases don't check for referential integrity. I faced many issues in the early development phase, where I expected things to get deleted because of CASCADE etc.
  3. Managing the development of SigmaFit along with my internship was a bit challenging. I couldn't put regular efforts into this project because of an imperative release. But it was a pleasant experience, building a side project and working on a full-time internship simultaneously. (Had to sacrifice a few weekends. ๐Ÿฅฒ)
  4. I faced a lot of issues while configuring Cloudflare DNS and Page Rules. At first, the page rules weren't propagating correctly, and later I encountered an infinite redirection loop issue. Wasted a total of five hours on it. ๐Ÿ˜… Finally, this blog post rescued me from it. ๐Ÿ™Œ

๐Ÿ–ฅ Code Artifacts

GitHub Repository: Link

Live Website:

๐Ÿ’ญ Few thoughts on planetscale & a feature request

I've always loved the referential integrity feature of all relational databases but never liked the fact that horizontal scaling is not very straightforward in them. That led me to explore Cassandra and whatnot!

Planetscale offers a simple managed solution to remove all the complexities of scaling a relational database horizontally. That's so cool. But it does come at the cost of forgoing the beloved referential integrity feature. ๐Ÿ˜ญ

I've got a feature request for you planetscale folks. Can we have the referential integrity check in the development branch? Don't allow CASCADE commands, just throw an error and let the developer fix the logical error. In production, continue using the more performant version (without this integrity check).

โญ What's Next

  1. In the next version, we shall allow people to join friend circles to track each other's progress. It will keep everyone motivated to do physical activity and stay healthy.
  2. In future, we shall also add offline support. (Currently, some functionalities can work offline ๐Ÿคซ, but there is no logic to fix the synchronization conflicts ๐Ÿ˜ข).

I will now stop talking now and let you try SigmaFit. Kindly visit, and please install the PWA version for the best experience. That concludes my first post on this platform. See ya!

Did you find this article valuable?

Support Subham Sahu by becoming a sponsor. Any amount is appreciated!