This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
The Fitness Matrix is an Astro-based web application that visualizes fitness data from Strava and Hevy APIs in a Matrix-inspired terminal interface. It displays activity heatmaps, workout statistics, and interactive maps.
Tech Stack: Astro 5.x, Bun runtime, TypeScript, Tailwind CSS
bun dev # Start dev server (http://localhost:4321)
bun build # Build for production (runs astro check first)
bun preview # Preview production build
bun test # Run Vitest tests
bun lint # Lint with ESLint
bun format # Format with Prettier
bun strava-script # Manually fetch Strava data to public/last-activities.json
bun clean # Remove artifacts and reinstall dependenciesNode version: >=18.17.1 required. Use Bun as the package manager.
stravaService.ts - Strava API integration
getBearerToken(): Refreshes OAuth token using environment variables (STRAVA_CLIENT_ID, STRAVA_CLIENT_SECRET, STRAVA_REFRESH_TOKEN)fetchActivities(page, perPage): Fetch recent activitiesfetchDistanceData(): Fetch 365 days of activity data for heatmapprocessDistanceData(distanceMap): Convert to heatmap-ready format with Sunday alignmentgetLastActivityDate(activityType?): Get date of most recent activitygetLastActivityInfo(activityType?): Get detailed info about last activitygetActivityStats(activities): Calculate statistics by activity type
Critical: All date handling uses "America/New_York" timezone to ensure consistent day boundaries across heatmap visualization.
hevyService.ts - Hevy API integration
fetchHevyData(apiKey?): Fetch all workouts (sorted newest first)fetchWorkoutCount(apiKey?): Get total workout count- Exports TypeScript interfaces:
Workout,Exercise,Set
- HeatmapGrid.astro: 365-day visualization with Matrix green gradient coloring
- DaysSinceLast.astro: Activity status indicators (EXCELLENT/WARNING/CRITICAL based on days since last activity)
- ActivityMap.astro: Leaflet map with polyline route rendering
- HevyWorkoutCount.astro: Workout count displayed in binary Matrix style
- MatrixBackground.astro: Animated Matrix rain effect
index.astro: Main dashboard with heatmaplast.astro: Latest activities with statsmap.astro: Interactive map viewhevy.astro: Hevy workout dashboardabout.astro: About page
heatmapUtils.ts: Matrix color gradients and animation styles (matrixFade, digitalGlitch, matrixRain)formatUtils.ts: Distance and time formatting
Required in .env (see .env.sample for template):
STRAVA_CLIENT_ID=...
STRAVA_CLIENT_SECRET=...
STRAVA_REFRESH_TOKEN=...
HEVY_API_KEY=...For Strava OAuth setup instructions, see DOCS-STRAVA.md. The refresh token must be obtained through the OAuth authorization flow.
GitHub Actions workflow (.github/workflows/strava-build.yml) runs daily at 6am UTC:
- Executes
bun run strava-script - Fetches last 365 days of Strava activities
- Summarizes distance by date (EST timezone, UTC-5)
- Updates
public/last-activities.json - Auto-commits changes
Uses repository secrets for Strava credentials.
Timezone Handling: All Strava date processing uses "America/New_York" timezone. This is critical for heatmap day alignment - activities are bucketed by NY local date, not UTC. The heatmap grid starts on Sunday and processes 365 days of data.
API Rate Limits: Strava API has rate limits. The service gracefully handles "Rate Limit Exceeded" responses.
Matrix Theme: Use Matrix green (#00ff00, rgb(0, 255, 0)) for active states and dark backgrounds. Color gradient in heatmap ranges from very dark green to neon green based on activity intensity.
Development vs Production: Some functions (like getLastActivityDate) return mock data in development mode to avoid excessive API calls during development.
- Platform: Netlify (config in
netlify.toml) - Live URL: https://fit.jpdiaz.dev
- Build command:
bun build - Output directory:
dist/