Skip to content

Repository files navigation

WeirdStats

A personal Strava analytics app that tracks additional statistics.

Features

  • Sync activities from Strava
  • Detect stops during rides/runs
  • Identify stops near traffic lights using OpenStreetMap data
  • View activity details with route visualization
  • Download activity data as JSON for testing
  • Native iOS prototype with backend-owned Strava sign-in

Running Locally

Prerequisites

Setup

  1. Clone the repository:

    git clone https://github.com/ptmt/weirdstats.git
    cd weirdstats
  2. Create a .env file from the example and fill in your Strava credentials:

    cp .env.example .env
  3. Run the app:

    go run ./cmd/weirdstats
  4. Open http://localhost:8080

For OAuth flows behind Strava callbacks, set BASE_URL to the public URL that reaches your server. BASE_URL=weirdstats.com is accepted and normalized to https://weirdstats.com. The iOS prototype under ios/README.md uses the mobile endpoints exposed by the backend.

Docker

Build the image

docker build -t weirdstats .

Run the container

docker run -p 8080:8080 \
  -v weirdstats-data:/data \
  -e STRAVA_CLIENT_ID=your_client_id \
  -e STRAVA_CLIENT_SECRET=your_client_secret \
  weirdstats

Or with an env file:

docker run -p 8080:8080 \
  -v weirdstats-data:/data \
  --env-file .env \
  weirdstats

Docker Compose (optional)

services:
  weirdstats:
    build: .
    ports:
      - "8080:8080"
    volumes:
      - weirdstats-data:/data
    env_file:
      - .env

volumes:
  weirdstats-data:

Environment Variables

See .env.example for all available configuration options.

Mobile/iOS-related variables:

  • BASE_URL: used to derive /connect/strava/callback, /connect/strava/mobile/callback, and /webhook
  • MOBILE_APP_REDIRECT_URL: optional native-app callback like weirdstats://auth/strava

CI/CD

GitHub Actions workflows are included:

  • Test (test.yml): Runs on every push and PR to main
  • Docker (docker.yml): Builds and publishes to GitHub Container Registry on push to main or version tags

Pull the published image

docker pull ghcr.io/yourusername/weirdstats:main

Development

Run tests

go test ./...

Run tests with coverage

go test -race -coverprofile=coverage.out ./...
go tool cover -html=coverage.out

Live reload with Air

Install and run Air for automatic reloading during development:

go install github.com/air-verse/air@latest
air

If air is not in your PATH, you can run it directly:

go run github.com/air-verse/air@latest

Or use the full path:

$(go env GOPATH)/bin/air

Validate

curl http://localhost:8080/healthz

Notes

  • Without Strava credentials, the server still runs but activity fetching will fail when the worker processes items.
  • Use a SQLite viewer or sqlite3 to inspect weirdstats.db if needed.
  • The server runs a background worker loop to process the queue (see SPEC.md for workflow).
  • Webhook verification uses GET /webhook?hub.challenge=...&hub.verify_token=....
  • POST /webhook checks X-Strava-Signature when STRAVA_WEBHOOK_SECRET is set.

License

MIT

About

weird (cycling) stats

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages