Skip to content

Instantly share code, notes, and snippets.

@pm0u
Last active January 15, 2024 16:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pm0u/e810e389c5efa463c4fef163ccda0eca to your computer and use it in GitHub Desktop.
Save pm0u/e810e389c5efa463c4fef163ccda0eca to your computer and use it in GitHub Desktop.
Arch Idea for strava <-> webmap
graph LR
  strava_server[Strava]
  strava_server<-- authenticated --> node_server
  node_server["Node Server
  -------
  OAUTH2
  route fetching
  activity fetching
  "]
  node_server <-- authenticated --> Webmap


  subgraph Webmap
    direction TB

    strava_component["Strava Component
    ------
    displays activity list
    CTA to show/edit on map
    "]

    strava_explanation[\"Passes initialRoute data
      to routebuilder - strategy TBD
      ------
      ** How to get strava -> webmap line?
      - Use polyline data & mapbox tools
      - OR get stream & convert lat/lng to geojson
      ** How to make the route show on the map?
      - localStorage hack similar to the upsell flow
      - Create route first then edit new ID
    "/]

    route_builder["Route Builder
      ------
      Initializes route edit with
      data from strava
    "]
    strava_component-->strava_explanation-->route_builder
  end
sequenceDiagram

  participant Strava Oauth
  participant Strava Data
  participant Node Server
  participant Webmap
  Node Server-->>Webmap: Sends Oauth2 URL with<br/>redirect, client ID encoded
  Webmap-->>Strava Oauth: Send user to OAUTH login on user interaction
  Strava Oauth-->>Node Server: Redirect with code
  Node Server-->>Strava Oauth: Obtain refresh, access token
  Strava Oauth-->>Node Server: Reply with tokens
  note over Node Server: Stores tokens in JWT cookie
  Node Server-->>Webmap: 301: Redirect user back to webmap<br/>(strava window open?)
  Webmap-->>Node Server: Request activities, routes
  note over Node Server: Reads tokens from cookie<br/>and validates
  Node Server-->>Strava Data: Requests routes/activities<br />using authentication from cookie
  Strava Data-->>Node Server: Returns requested data
  Node Server-->>Webmap: Returns requested data
  Webmap-->>Node Server: Requests Activity data
  note over Node Server: Authenticates request using JWT cookie
  Node Server-->>Strava Data: Requests activity data
  Strava Data-->>Node Server: Returns activity data
  Node Server-->>Webmap: Returns activity data
  note over Webmap: Passes data to route builder<br/>for preview
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment