Skip to content

Amandot/FitChain

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

11 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿƒโ€โ™‚๏ธ Fitchain

Decentralized Fitness Tracking Platform on Stellar Blockchain

A revolutionary blockchain-powered fitness tracking application that combines real-time GPS tracking with Stellar blockchain technology to create a decentralized fitness ecosystem with contests, leaderboards, and crypto rewards.

License: MIT Stellar React


๐ŸŒŸ Features

๐ŸŽฏ Core Functionality

  • Real-Time GPS Tracking - Professional-grade GPS accuracy with live path visualization
  • Stellar Blockchain Integration - Store achievements permanently on Stellar blockchain
  • Freighter Wallet Support - Secure wallet connection for Web3 functionality
  • Interactive Maps - Leaflet-powered maps with real-time tracking visualization
  • Fitness Contests - Join competitions and compete for crypto prizes
  • Global Leaderboards - Track your performance against other runners
  • Payment System - Automated prize distribution via Stellar network

๐Ÿ† Contest System

  • Create and join fitness contests
  • Real-time leaderboard updates
  • Automated winner selection
  • Prize pool management
  • Contest history and statistics

๐Ÿ’ผ Wallet & Payments

  • Freighter wallet integration
  • Secure Stellar transactions
  • Prize distribution tracking
  • Payment history
  • Multi-currency support (XLM, USDC)

๐ŸŽจ User Experience

  • Stunning Earth Background - CSS-animated Earth with rotating sphere and starfield
  • Responsive Design - Works perfectly on desktop, tablet, and mobile devices
  • Glassmorphism UI - Modern glass-effect design with smooth animations
  • Professional Landing Page - Complete with features showcase and statistics
  • Smooth Page Transitions - Framer Motion powered animations

๐Ÿš€ Quick Start

Prerequisites

  • Node.js (v16 or higher)
  • npm or yarn
  • Freighter Wallet browser extension (Install here)
  • SQLite3 (for backend database)

Installation

1. Clone the Repository

git clone https://github.com/yourusername/stellar-strider.git
cd stellar-strider

2. Backend Setup

cd backend

# Install dependencies
npm install

# Setup environment variables
cp .env.example .env
# Edit .env with your configuration

# Initialize database
npm run init-db

# Start backend server
npm start

The backend API will run on http://localhost:3001

3. Frontend Setup

cd frontend

# Install dependencies
npm install

# Setup environment variables
cp .env.example .env
# Edit .env with your configuration

# Start development server
npm run dev

The frontend will run on http://localhost:5173

Environment Configuration

Backend .env

PORT=3001
NODE_ENV=development
FRONTEND_URL=http://localhost:5173

# Database
DATABASE_PATH=./database/stellar-strider.db

# Security
RATE_LIMIT_WINDOW_MS=900000
RATE_LIMIT_MAX_REQUESTS=100

# Stellar Network
STELLAR_NETWORK=testnet
STELLAR_HORIZON_URL=https://horizon-testnet.stellar.org

Frontend .env

# Stellar Configuration
VITE_STELLAR_NETWORK=testnet
VITE_STELLAR_HORIZON_URL=https://horizon-testnet.stellar.org

# Backend API
VITE_API_URL=http://localhost:3001

# Optional: Smart Contract Address
VITE_PUBLIC_CONTRACT_ADDRESS=your-contract-address-here

๐Ÿ“ฑ Usage

1. Connect Your Wallet

  • Install Freighter wallet extension
  • Create or import your Stellar wallet
  • Click "Connect Wallet" in the app
  • Approve the connection

2. Start Tracking

  • Click "Start Run" to begin GPS tracking
  • Move around to record your path
  • Watch real-time stats update
  • Click "Stop Run" when finished

3. Join Contests

  • Browse available contests
  • Join contests that interest you
  • Complete your runs during contest period
  • Check leaderboards for rankings

4. Earn Rewards

  • Win contests to earn crypto prizes
  • Prizes automatically distributed to your wallet
  • Track your earnings in payment history

๐Ÿ—๏ธ Project Structure

stellar-strider/
โ”œโ”€โ”€ backend/                    # Express.js API Server
โ”‚   โ”œโ”€โ”€ config/                # Database and app configuration
โ”‚   โ”œโ”€โ”€ database/              # SQLite database files
โ”‚   โ”œโ”€โ”€ models/                # Database models
โ”‚   โ”œโ”€โ”€ routes/                # API route handlers
โ”‚   โ”‚   โ”œโ”€โ”€ contests.js       # Contest management
โ”‚   โ”‚   โ”œโ”€โ”€ leaderboard.js    # Leaderboard endpoints
โ”‚   โ”‚   โ””โ”€โ”€ payments.js       # Payment processing
โ”‚   โ”œโ”€โ”€ scripts/              # Utility scripts
โ”‚   โ”œโ”€โ”€ server.js             # Main server file
โ”‚   โ””โ”€โ”€ package.json
โ”‚
โ”œโ”€โ”€ frontend/                  # React Application
โ”‚   โ”œโ”€โ”€ public/               # Static assets
โ”‚   โ”‚   โ””โ”€โ”€ images/          # Image files
โ”‚   โ”œโ”€โ”€ src/
โ”‚   โ”‚   โ”œโ”€โ”€ components/      # React components
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ LandingPage.jsx
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ SimpleMap.jsx
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ ContestPage.jsx
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ Leaderboard.jsx
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ ContestLeaderboard.jsx
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ WalletIntegration.jsx
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ ...
โ”‚   โ”‚   โ”œโ”€โ”€ utils/           # Utility functions
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ stellarWallet.js
โ”‚   โ”‚   โ”œโ”€โ”€ App.jsx          # Main application
โ”‚   โ”‚   โ”œโ”€โ”€ App.css          # Global styles
โ”‚   โ”‚   โ””โ”€โ”€ main.jsx         # Entry point
โ”‚   โ”œโ”€โ”€ package.json
โ”‚   โ””โ”€โ”€ vite.config.js
โ”‚
โ”œโ”€โ”€ contract/                  # Soroban Smart Contract (Rust)
โ”‚   โ”œโ”€โ”€ src/
โ”‚   โ”‚   โ””โ”€โ”€ lib.rs           # Contract logic
โ”‚   โ”œโ”€โ”€ Cargo.toml
โ”‚   โ””โ”€โ”€ target/              # Compiled WASM
โ”‚
โ”œโ”€โ”€ DEPLOYMENT.md             # Deployment guide
โ”œโ”€โ”€ LICENSE                   # MIT License
โ””โ”€โ”€ README.md                # This file

๐Ÿ› ๏ธ Technology Stack

Frontend

  • React 19 - UI framework with latest features
  • Vite - Fast build tool and dev server
  • Framer Motion - Smooth animations and transitions
  • Leaflet - Interactive mapping library
  • React Leaflet - React bindings for Leaflet
  • Stellar SDK - Stellar blockchain integration
  • Freighter API - Wallet connection

Backend

  • Node.js - JavaScript runtime
  • Express.js - Web framework
  • SQLite3 - Embedded database
  • Helmet - Security middleware
  • CORS - Cross-origin resource sharing
  • Rate Limiting - API protection

Blockchain

  • Stellar Network - Blockchain platform
  • Soroban - Smart contract platform (Rust)
  • Freighter - Stellar wallet

๐Ÿ“Š API Endpoints

Leaderboard

  • GET /api/leaderboard/global - Global leaderboard
  • GET /api/leaderboard/contest/:contestId - Contest leaderboard
  • GET /api/leaderboard/user/:walletAddress/rank - User rank
  • GET /api/leaderboard/top-performers - Top performers
  • GET /api/leaderboard/top-earners - Top earners

Contests

  • GET /api/contests - All contests
  • GET /api/contests/:id - Contest by ID
  • GET /api/contests/:id/winners - Contest winners
  • GET /api/contests/status/active - Active contests
  • GET /api/contests/status/upcoming - Upcoming contests
  • GET /api/contests/status/completed - Completed contests

Payments

  • GET /api/payments - All payments
  • GET /api/payments/:id - Payment by ID
  • GET /api/payments/wallet/:walletAddress - User payments
  • GET /api/payments/recent/all - Recent payments
  • GET /api/payments/prizes/all - All prizes
  • GET /api/payments/prizes/user/:walletAddress - User prizes

๐Ÿ—บ๏ธ GPS Tracking Features

Real-Time Tracking

  • High-accuracy GPS positioning
  • Live path visualization on map
  • Movement detection algorithms
  • Speed and pace calculation
  • Distance tracking with Haversine formula

Loop Validation

  • Validates start and end points (50m tolerance)
  • Minimum 3 GPS points required
  • Clear feedback messages
  • Prevents invalid submissions

Statistics

  • Real-time timer
  • Distance traveled
  • Current speed
  • Average pace
  • GPS accuracy indicator
  • Movement status

๐Ÿ” Security Features

  • Helmet.js - HTTP security headers
  • Rate Limiting - API request throttling
  • CORS Protection - Controlled cross-origin access
  • Input Validation - Sanitized user inputs
  • Secure Wallet Connection - Freighter integration
  • Environment Variables - Sensitive data protection

๐ŸŽฎ Contest System

Contest Types

  • Distance challenges
  • Time trials
  • Speed competitions
  • Custom fitness goals

Prize Distribution

  • Automated winner selection
  • Instant prize distribution
  • Multi-place rewards (1st, 2nd, 3rd)
  • Transparent payment tracking

Leaderboard Features

  • Real-time rankings
  • Performance metrics
  • Historical data
  • User statistics

๐Ÿšข Deployment

See DEPLOYMENT.md for detailed deployment instructions including:

  • Production environment setup
  • Database configuration
  • Stellar network deployment
  • Smart contract deployment
  • Frontend build and hosting
  • Backend server deployment

๐Ÿงช Development

Available Scripts

Backend

npm start          # Start production server
npm run dev        # Start development server with nodemon
npm run init-db    # Initialize database

Frontend

npm run dev        # Start development server
npm run build      # Build for production
npm run preview    # Preview production build
npm run lint       # Run ESLint

Testing GPS Tracking

Simulate GPS in Chrome DevTools

  1. Open DevTools (F12)
  2. Click Menu (โ‹ฎ) โ†’ More Tools โ†’ Sensors
  3. Under Location, select "Custom location"
  4. Enter coordinates (e.g., Lat: 28.6139, Lon: 77.2090)
  5. Start tracking in the app
  6. Change coordinates to simulate movement
  7. Return to start point to complete loop

๐Ÿค Contributing

We welcome contributions! Please follow these steps:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Development Guidelines

  • Follow existing code style
  • Write clear commit messages
  • Add tests for new features
  • Update documentation as needed
  • Ensure all tests pass

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.


๐Ÿ”ฎ Roadmap

Phase 1 (Current)

  • โœ… GPS tracking system
  • โœ… Stellar wallet integration
  • โœ… Contest system
  • โœ… Leaderboards
  • โœ… Payment processing

Phase 2 (Upcoming)

  • Mobile app (React Native)
  • Social features and friend challenges
  • Advanced analytics dashboard
  • NFT rewards for achievements
  • Wearable device integration

Phase 3 (Future)

  • Multi-chain support
  • DAO governance
  • Marketplace for fitness NFTs
  • Staking and yield farming
  • Virtual races and events

๐Ÿ“ž Support


๐Ÿ™ Acknowledgments

  • Stellar Development Foundation - Blockchain infrastructure
  • OpenStreetMap - Mapping data
  • Leaflet - Mapping library
  • React Team - UI framework
  • Freighter Team - Wallet integration
  • All contributors and testers

๐Ÿ“ˆ Statistics

  • 1,247 Total Runs Recorded
  • 89 Active Users
  • 15.4K KM Tracked
  • 342 Contests Completed

๐ŸŒ Transform Your Fitness Journey with Blockchain ๐Ÿš€

About

A decentralized fitness tracking platform on the Stellar blockchain. Run, compete in contests, and earn crypto rewards.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors