Skip to content

Yajat-Sharma/Runrush

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

21 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸƒ RunRush

Your Personal Running Intelligence Platform β€” Track runs, build streaks, earn badges, and compete with your community.


πŸ“– About

RunRush is a full-stack web application for everyday runners who want smart analytics and social motivation β€” without GPS hardware or expensive subscriptions. Log a run in seconds, get a personalized AI insight, and watch your streaks grow.


✨ Features

Category Features
Tracking Log runs (date, distance, time, type, notes) Β· Auto pace & calorie calc Β· Personal bests (5K / 10K)
Analytics 365-day activity heatmap Β· Run-type breakdown Β· Monthly & weekly stats
Motivation AI run insights Β· Streak tracker Β· Badge system with confetti Β· Weekly goal progress
Social Follow/unfollow runners Β· Social feed Β· Smart Discover ranking Β· All-time & weekly leaderboard
Communication Weekly HTML email summary (opt-in) via Resend API Β· @mention friends in run notes
Offline Log runs offline β†’ SHA-256 verified auto-sync on reconnect
Settings Dark/light mode Β· Display name Β· Weight & height Β· PIN change Β· CSV export
Admin User management Β· Block/unblock Β· Role assignment Β· Activity logs Β· Admin notes

πŸ› οΈ Tech Stack

Layer Technology
Frontend Vanilla HTML5, CSS3 (glassmorphism), Vanilla JavaScript
Backend Python 3 Β· Flask 3.0
Database (dev) SQLite (runs.db)
Database (prod) PostgreSQL 16
Auth Flask session Β· 4-digit PIN Β· hmac.compare_digest
Email Resend API (via Python urllib)
Offline Sync localStorage + custom sync-engine.js
Hosting Render (Web Service + PostgreSQL)
WSGI Gunicorn

πŸ—„οΈ Database Tables

Table Purpose
users Accounts, profile, theme, role, status
runs Individual run entries with computed stats
user_stats Cached totals: total km, current & best streak
badges Badge catalog (criteria definitions)
user_badges Badges earned per user
friends Directional follow relationships
edit_history Field-level audit log of run edits
activity_logs App-wide action audit trail
admin_notes Moderator notes on users

πŸš€ Quick Start (Local)

1. Clone & install

git clone https://github.com/your-username/runrush.git
cd runrush
python -m venv .venv
.venv\Scripts\activate        # Windows
pip install -r requirements.txt

2. Run

python app.py

Open http://localhost:5000 β€” SQLite is used automatically, no database setup needed.

3. Environment variables (optional)

Create a .env file (see .env.example):

DATABASE_URL=sqlite:///runs.db   # or a postgresql:// URL for production
ADMIN_USER_ID=1                  # user ID that gets admin privileges
RESEND_API_KEY=re_...            # for weekly email summaries
RESEND_FROM_EMAIL=RunRush <noreply@yourdomain.com>

☁️ Deploy to Render

  1. Create a PostgreSQL database on Render β†’ copy the Internal Database URL
  2. Create a Web Service β†’ connect your GitHub repo
  3. Set environment variables:
Key Value
DATABASE_URL Internal PostgreSQL URL from Render
ADMIN_USER_ID 1
FLASK_ENV production
  1. Build command: pip install -r requirements.txt
  2. Start command: gunicorn app:app

See RENDER_SETUP.md for full instructions.

Migrate existing data to PostgreSQL

set DATABASE_URL=postgresql://user:pass@host:5432/dbname
python migrate_to_pg.py

πŸ“ Project Structure

runrush/
β”œβ”€β”€ app.py                  # All routes & business logic
β”œβ”€β”€ db.py                   # SQLite / PostgreSQL abstraction layer
β”œβ”€β”€ migrate_to_pg.py        # Data migration script
β”œβ”€β”€ requirements.txt
β”œβ”€β”€ runs.db                 # Local SQLite database (gitignored in prod)
β”œβ”€β”€ static/
β”‚   β”œβ”€β”€ css/                # Stylesheets
β”‚   └── js/                 # sync-engine.js, offline-storage.js, etc.
β”œβ”€β”€ templates/              # Jinja2 HTML templates
β”‚   β”œβ”€β”€ index.html          # Dashboard
β”‚   β”œβ”€β”€ social.html         # Social feed
β”‚   β”œβ”€β”€ leaderboard.html
β”‚   β”œβ”€β”€ settings.html
β”‚   β”œβ”€β”€ login.html / register.html / onboarding.html
β”‚   └── ...
└── migrations/
    └── add_badges_system.py

🧠 Key Business Logic

Streak Calculation

Unique run dates fetched and sorted. Current streak walks backward from today; best streak is the longest consecutive chain in history. Recalculated from scratch on every add/delete.

AI Run Insight

Compares today's pace and distance against the user's last 30 days of runs. Returns a personalized motivational message β€” no external API, pure Python.

Social Score (Discover Runners)

Social Score = (30-day KM Γ— 2) + (30-day Run Count Γ— 5) + (Current Streak Γ— 10)

Surfaces the most currently active runners, not just all-time leaders.

Offline Sync

Runs saved to localStorage offline. On reconnect, each run is sent with a SHA-256 hash of date+distance+time for server-side integrity verification. Duplicates are detected and skipped (HTTP 409).

Edit Lock

Runs are editable within 24 hours of logging (created_at). Admins/moderators bypass the lock. All field changes are recorded in edit_history.


πŸ”’ Authentication

  • Username + numeric PIN (β‰₯ 4 digits)
  • Flask server-side session
  • PIN comparison via hmac.compare_digest() (timing-safe)
  • Role system: user β†’ moderator β†’ admin (also via ADMIN_USER_ID env var)

πŸ“¦ Dependencies

Flask==3.0.0
python-dotenv==1.0.0
gunicorn
psycopg2-binary

πŸ“„ License

MIT β€” feel free to use, modify, and distribute.


Built with ❀️ and Python · RunRush © 2026

About

πŸƒ RunRush β€” An AI-powered social running platform with analytics, streaks, badges, leaderboards, and offline-first tracking.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages