Skip to content

Tennis Coaching App using LLMs

Tennis Bro is a smart online tennis coaching app that offers personalized improvement advice, performance summaries, and string recommendations.

Coaching Advice

Example: Strategy Advice

Introduction & Philosophy

Tennis Bro works the following way:

  • User uploads written notes on matches & practices. (1)

    1. Reflect on what went well, what needs improving, tactics, what you want to remember for next time, etc.
  • Tennis Bro then processes all the historical notes and offers tailored recommendations.

Reflection & Clear Goals are the Key to Progress

The idea behind Tennis Bro is that by reflecting thoroughly and having clear goals one can improve faster.

Tennis Bro provides a platform to record your reflections, automatically analyze them, and provide tailored recommendations.

graph LR
G("Set clear goals")
P("Perform")

R("Reflect")

G-->P-->R-.->G

Features

Personalized Coaching Advice

Tennis Bro provides recommendations for improving in five specific areas of the game of tennis:

  1. Strategy
  2. Mental
  3. Technique
  4. Serve
  5. Nutrition

The app uses a combination of historical user notes and the understanding of the game of tennis to inform the recommendations.

The screenshot below shows an example recommendation:

Coaching Advice

Example: Coaching Advice

User also receives three keywords to keep in mind during their next session to reinforce new habits.

The screenshot below shows an example of 3 keywords:

Coaching Advice

Example: Keywords

To get the best coaching advice: Upload often + In detail

The more notes the user uploads the better the underlying algorithm becomes at identifying areas for improvement.

With more detail in each note the advice will be less generic and more specific.

Summary of Past Performance

Tennis Bro analyzes all the users historical notes and provides a summary of trends, as well as a projection going forward.

Coaching Advice

Example: Summary of Past Performance

Upload Data

User can record notes using two different approaches 1) Answer Questions, or 2) Free Flow.

For either approach, the user is also asked to note down the following:

  • Session Type (1)

    1. Session can be either a practice or a match. If neither is applicable then not applicable.
  • Outcome (1)

    1. The outcome of a session can be a win, loss or a draw. If none is applicable then not applicable.

Answer Questions

Tennis Bro has a database of various questions to prompt the user to reflect on different aspects of the game.

Each time a user decides to upload new notes, Tennis Bro will select two questions randomly to ask the user.

Coaching Advice

Example: Upload Data Q&A

Free Flow

The user is also able to write down notes without any pre-defined structure.

Coaching Advice

Example: Upload Data Free Flow

Inspect Uploaded Data

The app allows the user to see all the historical notes they uploaded over time.

Coaching Advice

Example: Inspect historical notes

String Recommendation (Beta)

The String Recommendation feature provides a recommendation for what string, tension and gauge is likely to be suitable for the user.

The app uses various information to determine the optimal string, such as the tennis racket model, the type of forehand the user hits or for instance whether the user suffers from arm pain.

Coaching Advice

Example: String Recommendation Input

Once the user specifies all the variables, they will receive a string recommendation setup:

Coaching Advice

Example: String Recommendation

Sign up + Sign in Workflow

Each user can have their unique account by signing up through Tennis Bro.

By having an account, the user's historical data gets stored allowing the application to provide better recommendations.

Try the app as a Test User

You can try the app without signing up by logging in as a Test User.

Sign up
Test User

As a Test User, you can see all the features the app provides. However, uploading data or modifying data is disabled.

To sign up, simply visit Tennis Bro, provide your email address and you will receive a unique authentication token to your email.

Steps

  1. Sign up through Tennis Bro to create a new user for a given email address.

    Sign up
    Sign up

  2. Check your email to find an authentication token that will allow you to log-in. (1)

    1. The email will be sent from info@tennisbro.org with a subject "TennisBro Authentication Token".

    Sign up
    Authentication token

  3. Sign in by copy and pasting your token into the app. (1)

    1. Once logged in to the app, it will save the token to your cookies 🍪, so that you don't have to log in each time you visit the app on the given device for the next 10 days.

    Sign in
    Log-in

Technical Background

Tech Stack

The tech stack used to build this application is the following, including the main tools and packages used:

Whisper for transcription of Speech to Text

I used the whisper model for transcribing speech to text, in order to allow users to simply record notes by speaking and let the app transcribe it and summarize the note.

However, since the app is deployed with Streamlit Community Cloud, the CPU and memory (~1 GB) available is low, which does not make it feasible to use the large or medium Whisper models that provide good enough transcriptions.

Trying to use any of the bigger models results in out-of-memory errors and the transcriptions being too slow.

Whisper Ram
Whisper RAM requirements

Instead, users can take advantage of the the built-in dictation feature on iPhone.

Data Storage

The data is stored in Firestore.

There is a great tutorial for using Firestore in Python.

The data model has the following hierarchy:

  • High-level collection called Users, where each document represents a user.

    • For each user there are certain fields such as email, user_id or a token (1).

      1. Token is hashed, so its not sensitive information anymore once stored in the database.
    • There is also a subcollection for each user called Metadata.

      • Each document in the metadata subcollection represents an individual user Note.
        • A Note has various fields such as result, session_type, timestamp, or transcript.

Data Model: Users

Data Model: Metadata

Sign up + Sign in Workflow

Sign up application logic

The application has the following sign up workflow:


graph TD
    A("User clicks 'Create a new authentication token'")
    B("App generates a unique token")
    C("It sends the token to the user's email address")
    D("It hashes the token and creates a new user in the database")
    E("The app then shows a success message to the user in the app")

    subgraph Backend
        B --> C & D
    end

    A --> Backend:::yellow-->E
    classDef yellow fill: #ffffde

Token Hashing

The app uses argon2-cffi python package for hashing the token and for subsequently verifying a match between a user provided token and a hashed token.

Sign in application logic

The application has the following sign in workflow:


graph TD
    A("User clicks 'Submit' in the app providing a token")
    B("App gets all users metadata")
    C("It then checks whether there is a user who's hashed token is the same as the submitted token")
    D("The user's data is loaded and user is logged in")
    E("No user is found for the submitted token")
    F("Show message to user that token is invalid")
    G("Let user access all the features of the app")

    subgraph Backend
        B --> C
        C -->|A user is found| D
        C -->|No user is found| E
    end

    Backend:::yellow
    A --> B
    D --> G
    E --> F
    classDef yellow fill: #ffffde

Authentication token gets saved in cookies for faster log in

In order to automatically log a user in when they visit the app again, the authentication token is saved in the browser's cookies.

The cookie gets securely encoded using JSON Web Tokens using the PyJWT python library.

The cookie expires in 10 days after logging in, meaning the user will have to re-enter the original authentication token.

Uptime Monitoring

Tennis Bro has an uptime monitoring implemented using Better Stack with a dedicated status page.

Uptime Monitoring

This helps to increase trust with users by proactively reporting on:

  • Availability1
  • Scheduled Downtime2
  • Non-scheduled Downtime3

  1. This metric refers to the proportion of time the app is running as expected. 

  2. When an app is not working, but it is expected and intentional, for instance when a database migration happens. 

  3. When an app is not working, and it is not intentional, for instance when an incident happens due to a new deployment which contains a bug.