Your Strides.ai app now automatically pulls data from Strava when a user connects! Here's the complete flow:
User visits: http://localhost:5173
What they see:
- Beautiful dark dashboard with sample data
- "Connect Strava" button in top navigation (orange gradient)
- Training metrics, charts, and AI coach
What happens:
- Frontend requests authorization URL from backend
- User is redirected to Strava's OAuth page
- User logs into Strava (if not already logged in)
- Strava shows authorization request:
- "Strides.ai wants to..."
- View your activities
- View your profile
- User clicks "Authorize"
Behind the scenes (happens automatically):
graph LR
A[User Authorizes] --> B[OAuth Callback]
B --> C[Save Tokens to DB]
C --> D[Create User Files]
D --> E[🔄 Auto-Import 30 Runs]
E --> F[Transform to JSON]
F --> G[Save to activities.json]
G --> H[Redirect to Dashboard]
H --> I[Show User's Data!]
Import happens in seconds:
- Fetches last 30 activities from Strava
- Filters for runs only (Run + VirtualRun)
- Transforms to our JSON schema
- Saves to
user_data/athlete_<id>/activities.json - All automatic - no manual click needed!
What the user sees:
- ✅ Top nav shows: "Connected | [Profile Pic] John Doe"
- 📊 Dashboard displays THEIR activities (not sample data!)
- 🎯 Goals Manager available
- 📥 Import more runs option (10, 30, or 100)
- 💬 AI coach has their training data
On subsequent visits:
- User is still logged in (session persists)
- Dashboard always shows their data
- Can import more activities anytime
- Can set goals via Goals Manager
- Can chat with AI coach about their training
GET /api/data
→ Check session for user_id
→ Load from user_data/athlete_<id>/activities.json
→ Return user's actual data
GET /api/data
→ No user_id in session
→ Load from database (sample data)
→ Return demo data
- 30 most recent runs from Strava
- Transformed to include:
- Distance (miles)
- Pace (min/mile)
- Moving time
- Elevation gain
- Heart rate (if available)
- Cadence (if available)
- Click "10" → Last 10 runs
- Click "30" → Last 30 runs
- Click "100" → Full history
Backend/user_data/athlete_<strava_id>/
├── activities.json # All imported runs
├── weekly_summary.json # Aggregated by week (via n8n)
└── metadata.json # Goals and preferences
┌─────────────────────────────────────┐
│ 🏃 Training Overview │
│ Sample data shown │
│ │
│ [Connect Strava] button visible │
└─────────────────────────────────────┘
┌─────────────────────────────────────┐
│ Redirecting to Strava... │
│ ↓ │
│ Strava Authorization Page │
│ "Authorize Strides.ai?" │
│ ↓ │
│ Importing your activities... │
│ (happens automatically!) │
└─────────────────────────────────────┘
┌─────────────────────────────────────┐
│ ✓ Connected | [Pic] John Doe │
│ │
│ 🏃 YOUR Training Overview │
│ Your actual runs displayed │
│ │
│ [Goals Manager] [Import More] │
└─────────────────────────────────────┘
- No manual "import" button needed
- Data appears immediately after OAuth
- Smooth, seamless experience
- Each user has separate data files
- Sessions keep users logged in
- Data never mixed between users
- Not connected? See sample data
- Connected? See your data
- Graceful degradation
- Want more than 30 runs? Click to import
- Choose 10, 30, or 100 activities
- Duplicate detection (won't import twice)
-
Helper Function (
import_user_activities())- Reusable activity import logic
- Used by both OAuth callback and manual import
-
OAuth Callback (
/api/strava/callback)- After saving tokens:
import_user_activities(user_id, 30) - Non-blocking - won't fail OAuth if import fails
- Logs import results
- After saving tokens:
-
Data Endpoint (
/api/data)- Checks for
session['user_id'] - If exists: load from
user_data/athlete_<id>/ - If not: load from database (sample data)
- Checks for
- Dashboard already checks connection status
- Automatically requests
/api/data - Backend handles user vs. sample data
-
Ensure Strava credentials configured
cat Backend/.env # Should have STRAVA_CLIENT_ID and STRAVA_CLIENT_SECRET -
Open dashboard
http://localhost:5173 -
Click "Connect Strava"
- Redirects to Strava
- Authorize the app
-
Watch the magic!
- Returns to dashboard
- Activities automatically imported
- Dashboard shows YOUR runs
- No additional clicks needed
-
Check the data
ls -la Backend/user_data/athlete_*/ # Should see activities.json with your runs cat Backend/user_data/athlete_*/activities.json # Your actual Strava data!
- Open app → See demo data
- Click Connect → Go to Strava
- Authorize → Auto-import 30 runs
- Returned to app → See YOUR data
- Set goals → Use Goals Manager
- Import more → Click 10/30/100 button
- Chat with coach → AI knows your training!
Total clicks needed: Just 2 (Connect + Authorize)
Time to see your data: ~5 seconds
Manual steps: ZERO! Everything automatic!
- Instant gratification - data appears immediately
- No learning curve - just sign in
- Personalized experience from the start
- Multi-user ready from day 1
- Scalable architecture
- Clean separation of user data
- Real training data to analyze
- Personalized recommendations
- Context-aware coaching
When you deploy to production and set up n8n:
-
Real-time Sync
- Complete a run on Strava
- Webhook triggers n8n
- New run appears in dashboard automatically
-
Weekly Aggregation
- n8n calculates weekly metrics
- Updates
weekly_summary.json - Dashboard charts update
-
Advanced Analytics
- Training load calculation
- Fatigue detection
- Performance trends
All built on the foundation you have now! 🎉