Skip to content

Segment Challenge is an Elixir Phoenix web application built using Commanded

Notifications You must be signed in to change notification settings

ronaldofs/segment-challenge

 
 

Repository files navigation

Segment Challenge

Segment Challenge is an Elixir Phoenix web application built using Commanded for CQRS/ES. The front-end is mostly server generated HTML plus a few React components for responsive forms.

Segment Challenge homepage

What is Segment Challenge?

Segment Challenge allows any Strava athlete to host their own Strava-based challenge. Strava is a social network for athletes.

A challenge comprises one or more stages. You can create a challenge based around different Strava segments, or an activity challenge where you decide what type of activity to record (distance, duration, or elevation) and can set an optional goal.

Why is this being made public?

In March 2019 Strava decided to revoke access to the Strava API for Segment Challenge as "... the purpose of this app is competitive with Strava". Without API access the site cannot function. I am making the source code public to demonstrate one approach to building event sourced Elixir applications using Commanded.

Can I run this locally?

Yes, first you need to create a Strava account and create your own Strava API Application and then follow the steps below to clone the Git repo, prepare, and run the application.

Can I deploy this publicly?

No, Strava will not allow Segment Challenge access to their API in public.


Prerequisites

Install Elixir v1.8 and a Postgres database.

You will need to create a Strava API Application to access the API. Any Strava account can be used to create an application. Please refer to the Strava Developers documentation for help.

Getting started

  1. Install Elixir dependencies:

    mix deps.get
  2. Configure your Strava API Application settings:

    cp config/dev.secret.example config/dev.secret.exs

    Edit the config/dev.secret.exs config file and enter the Client ID, Client Secret, and Access Token values from you Strava API Application settings.

    You will need to do the same for test.secret.exs to run tests and prod.secret.exs to run in production.

  3. Create the event store and read store databases:

    mix setup

    This command will create and initialise two databases (segmentchallenge_eventstore_dev and segmentchallenge_readstore_dev) using the default Postgres connection settings configured in config/dev.exs.

  4. Install JavaScript dependencies and compile assets:

    npm install
    npm run compile

    You can use the npm run watch task to watch the assets and recompile on change.

  5. Run the Phoenix web server:

    iex -S mix phx.server

Useful tasks

Import active challenge stage efforts

Attempts at active stages are fetched from Strava every four hours. To import them immediately you can run the following from an iex -S mix console:

iex> SegmentChallenge.Tasks.ImportActiveStageEfforts.execute()

About

Segment Challenge is an Elixir Phoenix web application built using Commanded

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Elixir 75.6%
  • HTML 11.7%
  • JavaScript 9.7%
  • CSS 3.0%