An AWS-hosted web app that automatically edits Strava activities with a summary report of visited summits from the database of British and Irish Hills, according to their summit classification, and a description of the weather during the activity, generated using weatherapi.
To register for the app:
- visit the user registration endpoint to generate your sign-up link.
- Navigate to the
Authorisation url
property from the returnedJSON
. - You should be directed to a Strava login page. Login and Authorise the app to access your user profile
- You should then be redirected back to the app. If registration has been successful, you should see the message
Successfully registered athlete with ID <YOUR ATHLETE ID>
- All of your Strava activities will now be automatically updated with summit and weather reports
Please note, this is a hobby project, and I am trying to keep costs low. There is currently a hard limit on the number
of registered users of 5. If you instead see the message Unable to register athlete.
, it is likely this hard limit
has been exceeded.
When a user registers for the app, strava generates an authorisation_code
, which can be used to retrieve an
authorisation_token
and a refresh_token
from Strava (details regarding token exchange and refreshing expired tokens
are given in the Strava API documentation). These
tokens are unique per registered user, and are stored in a DynamoDB
table at the time of registration:
The app is registered for the Strava webhook events API. When a user
uploads a new activity to Strava, the events API triggers the process_strava_webhook
Lambda functionm which adds a
notification to an AWS SNS
storage service if the event is a newly-created activity:
The SNS
service is used here so that processing can be done asynchronously, and so that the Strava webhook events API
can receive a timely response. The SNS
service triggers the update_strava_description
lambda function, which:
- Reads the
athlete_id
andactivity_id
from the notification - Requests the corresponding activity metadata from Strava
- Extracts the start point latitude, longitude and start and end timestamps from the metadata
- Sends a request to WeatherAPI to retrieve weather data for the activity
- Generates a summary weather report using the returned data
- Requests the GPS coordinate trail from the Strava API
- Runs a nearest-neighbour search of GPS coordinates against the database of British and Irish hills and extracts any summits that were visited in the GPS trail.
- Generates a report of visited summits by classification, according to the configuration defined in
src/summits/report_configuration.py
- Concatenates the weather and summit reports, and updates the strava activity description
The Lambda endpoints themselves are defined in the top-level scripts of the src
folder. To deploy a Lambda endpoint,
save the contents of src
as a .zip
file and upload the package as detailed in the AWS documentation.
The app is hosted in AWS Lambda. To ensure compatibility with the AWS Lambda environment, dependencies are built using an amazonlinux Docker image, and uploaded as a lambda layer. To deploy dependencies, first build the packages using Docker:
- Build and run the docker image defined in
Dockerfile
:
docker build -t awslayerdocker .
docker run -it awslayerdocker bash
- Navigate to the installed python packages and create a
.zip
file:
cd ..
cd ./layer_dir
zip -r docker_layer.zip .
- Exit the container using
Ctrl + P + Q
- Identify the running container ID using
docker container ls
- Copy the
.zip
file onto the host machine:
docker cp <container ID>:/layer_dir/docker_layer.zip ./
- Deploy the Lambda layer, following the instructions in the AWS documentation.