Alphacoach Evolve

Image by dylan nolte

The 
Story

Fitness has always been a tricky space to generate stickiness. The average tech-savvy consumer owns a fleet of devices that are tracking several health metrics every second. This leads to an overwhelming amount of information that’s usually presented to users as insights.
 

Alphacoach was founded in 2019 with the goal of offering a sustainable approach to fitness. It offers a suite of products that present guided pathways and heavily customized plans for diverse lifestyles and specific fitness goals. Alphacoach has been working at eliminating the information overload with clear directional insights and recommendations.

Alpha coach logo_edited.png

Building The Platform

Alphacoach engaged Core27 to lay the technical foundations for their consumer offering called Evolve and set the standards for a platform that could mature quickly. Evolve generates huge volumes of time-series data. The data is then run through computational layers before insights are generated and offered to the users as actionable outcomes. These insights emerge as nudges, recommendations, scores among other things.

Python3

PostgreSQL

ElasticCache

FastAPI

TimescaleDB

PrefectIO

Asyncio

Amazon ECS

GitabCI

Laying The Groundwork For Quick Iterations

It was essential to let the teams build, launch and scale features without having to worry about the infrastructure. The small team size meant the teams required a low-touch, reliable platform that didn’t break the bank. Services needed deterministic build pipelines that would test and launch the application with minimal surprises.

So we settled on launching the platform on AWS Elastic Container Services using Fargate. The platform was set up to run multiple environments for the consumer-facing and data workloads. The ability to scale when thresholds hit was built into it. The environments catered to the mobile apps, testing, staging, pre-release, data and production consumers. Observability and centralized logging were set up as configuration, allowing teams to launch quickly.

Ensuring customer data was secure, encrypted and locked away from public access was one of the primary design goals for the infrastructure.

A Lean Team Needs A Cohesive And Decoupled Platform

Early conversations around the architecture frequently led to microservices. However, after careful analysis Core27 designed the system as an event-sourced monolith. The systems were organized as domains dealing with time-series data that could be easily decoupled when required.

Composable application and domain services offered the cohesiveness a computationally complex system like Evolve needed. Event sourcing allowed for greater decoupling and the ability to re-create state. An array of asynchronous event handler pipelines allowed the application to add application logic quickly.

Simplicity and SQL

A huge portion of the heavy lifting is offloaded to the database and background processes. PostgreSQL and TimescaleDB have been at the heart of most of the number crunching at Evolve. Data orchestrator managed pipelines were introduced only when all attempts to crunch the numbers with SQL proved inadequate. Read replicas, materialized views and the right indexes proved invaluable in simplifying a lot of the data challenges. The ability to handle unstructured data in modern relational databases has been a major win.

Speed Is A Feature

All services were designed to be async, or running on threads and background processes. Since a lot of the data crunching had been offloaded to the database, it was essential that we configured the database connection pooling carefully across our workers processes to ensure our servers had the right number of concurrent requests per worker. With Python’s collaborative concurrency model it was essential to not overshoot the sweet spot on the CPU usage per worker. At the same time having too many queued requests meant poorer response times. The sweet balance was critical to offer sub 200 ms response times. The right amount of caching furthered the efforts at being a snappy app.

Image by Luke Chesser

Testing and Exhaustive Documentation

Image by Kelly Sikkema

Working with fitness metrics meant accuracy was paramount. Incorrect insights or recommendations could not be offered even when the data wasn’t entirely reliable. An elaborate test suite ensured every feature is run through meticulously designed tests that check for correctness and deterministic results. Human errors were managed by carefully peer-reviewed pull requests before merges.

The computation and the algorithms had evolved slowly and it was essential that every engineer understood how they were arrived at. This meant API specifications, product design decisions had to be meticulously documented.

Emerging Culture

As in most cases, Alphacoach developed a culture that encouraged remote work, focused time without interruptions, asynchronous communication, testing and written documentation. Core27 is immensely proud to be part of the evolution of the Alphacoach platform.

To know more technical details about this project