Skip to content

AnastasiosF/Sports-Buddy

Repository files navigation

๐Ÿƒโ€โ™‚๏ธ Sports Buddy App

Find your perfect sports partner, anytime, anywhere!

Sports Buddy is a comprehensive mobile application that connects sports enthusiasts based on location, skill level, and shared interests. Whether you're looking for a tennis partner, organizing a basketball game, or joining a running group, Sports Buddy makes it easy to discover and connect with like-minded athletes in your area.

TypeScript React Native Expo Node.js PostgreSQL Supabase

โœจ Features

๐ŸŽฏ Core Functionality

  • ๐Ÿ” Secure Authentication - JWT-based auth with automatic token refresh
  • ๐Ÿ“ Location-Based Discovery - Find sports partners and matches nearby using PostGIS
  • ๐Ÿ… Sports & Skill Management - Track 14+ sports with skill level progression
  • โšก Real-Time Invitations - Bidirectional invitation system with instant notifications
  • ๐Ÿ‘ฅ Social Features - Friend system, user reviews, and match ratings
  • ๐Ÿ”„ Match Management - Create, join, leave, and manage sports matches

๐Ÿš€ Advanced Features

  • ๐ŸŽจ Theme System - Light/dark mode with dynamic theming
  • ๐Ÿ›ก๏ธ Row-Level Security - Comprehensive database security policies
  • ๐Ÿ“ฑ Responsive Design - Safe area aware UI for all device types
  • ๐Ÿ” Smart Search - Search by location, creator, sport, or skill level
  • ๐ŸŒ Geospatial Queries - Efficient location-based matching with spatial indexes

๐Ÿ—๏ธ Architecture

Monorepo Structure

sports-buddy-app/
โ”œโ”€โ”€ ๐Ÿ“ฑ mobile/SportsMonkey/        # React Native Expo App
โ”‚   โ”œโ”€โ”€ src/
โ”‚   โ”‚   โ”œโ”€โ”€ ๐ŸŽจ components/         # Reusable UI components
โ”‚   โ”‚   โ”œโ”€โ”€ ๐Ÿ”— contexts/           # React Context (Auth, Theme, etc.)
โ”‚   โ”‚   โ”œโ”€โ”€ ๐Ÿช hooks/              # Custom React hooks
โ”‚   โ”‚   โ”œโ”€โ”€ ๐Ÿงญ navigation/         # React Navigation setup
โ”‚   โ”‚   โ”œโ”€โ”€ ๐Ÿ“ฑ screens/            # App screens and pages
โ”‚   โ”‚   โ”œโ”€โ”€ ๐Ÿ› ๏ธ services/           # API service layer
โ”‚   โ”‚   โ”œโ”€โ”€ ๐ŸŽจ theme/              # Design system and themes
โ”‚   โ”‚   โ”œโ”€โ”€ ๐Ÿ”ค types/              # TypeScript definitions
โ”‚   โ”‚   โ””โ”€โ”€ ๐Ÿ› ๏ธ utils/              # Utility functions
โ”‚   โ””โ”€โ”€ App.tsx
โ”œโ”€โ”€ ๐Ÿ–ฅ๏ธ backend/                    # Express.js API Server
โ”‚   โ”œโ”€โ”€ src/
โ”‚   โ”‚   โ”œโ”€โ”€ โš™๏ธ config/             # Database and app config
โ”‚   โ”‚   โ”œโ”€โ”€ ๐ŸŽฎ controllers/        # API route handlers
โ”‚   โ”‚   โ”œโ”€โ”€ ๐Ÿ›ก๏ธ middleware/         # Security and auth middleware
โ”‚   โ”‚   โ”œโ”€โ”€ ๐Ÿ›ค๏ธ routes/             # API route definitions
โ”‚   โ”‚   โ”œโ”€โ”€ ๐Ÿ“ scripts/            # Database seed scripts
โ”‚   โ”‚   โ”œโ”€โ”€ ๐Ÿ”ค types/              # TypeScript definitions
โ”‚   โ”‚   โ””โ”€โ”€ app.ts                # Express application
โ”œโ”€โ”€ ๐Ÿ”— shared/                     # Shared TypeScript types
โ”‚   โ”œโ”€โ”€ src/
โ”‚   โ”‚   โ”œโ”€โ”€ types.ts              # Common type definitions
โ”‚   โ”‚   โ”œโ”€โ”€ api.ts                # API interfaces
โ”‚   โ”‚   โ”œโ”€โ”€ constants.ts          # Shared constants
โ”‚   โ”‚   โ”œโ”€โ”€ utils.ts              # Utility functions
โ”‚   โ”‚   โ””โ”€โ”€ validation.ts         # Input validation
โ””โ”€โ”€ ๐Ÿ—„๏ธ *.sql                      # Database schema and migrations

๐Ÿ”ง Technology Stack

Backend Stack

  • ๐ŸŸข Node.js + TypeScript - Modern JavaScript runtime with type safety
  • โšก Express.js - Fast, unopinionated web framework
  • ๐Ÿ›ก๏ธ Security Middleware - Helmet, CORS, rate limiting, authentication
  • ๐Ÿ“Š Supabase - PostgreSQL database with real-time subscriptions
  • ๐ŸŒ PostGIS - Spatial extension for location-based queries
  • ๐Ÿ” JWT Authentication - Secure token-based authentication

Mobile Stack

  • ๐Ÿ“ฑ React Native + Expo - Cross-platform mobile development
  • ๐ŸŽจ React Native Elements (RNE) - Consistent UI component library
  • ๐Ÿงญ React Navigation v6 - Native navigation with type safety
  • ๐Ÿ”— Context API - State management for auth, theme, and data
  • ๐Ÿ’พ AsyncStorage - Persistent local storage
  • ๐Ÿ”ง TypeScript - Full type safety across the application

Database & Infrastructure

  • ๐Ÿ˜ PostgreSQL - Robust relational database with JSON support
  • ๐ŸŒ PostGIS - Advanced geospatial capabilities
  • ๐Ÿ” Row-Level Security - Fine-grained access control
  • ๐Ÿ“ˆ Spatial Indexing - Optimized location-based queries
  • โšก Real-time Subscriptions - Live data updates

๐Ÿ” Security Architecture

Multi-Layer Protection

Mobile App (No DB Credentials)
     โ†“ JWT Tokens
Express API (Rate Limited + Authenticated)
     โ†“ Service Role Key
Supabase (Row-Level Security + Policies)
     โ†“ Secure Queries
PostgreSQL Database

Security Features

  • ๐Ÿ”‘ JWT Token Management - Automatic refresh and secure storage
  • ๐Ÿ›ก๏ธ API Rate Limiting - Protection against abuse and spam
  • ๐Ÿ”’ Row-Level Security - Database-level access control
  • ๐Ÿ› ๏ธ Input Validation - Server-side validation for all inputs
  • ๐Ÿ” Resource Ownership - Users can only access their own data
  • ๐ŸŒ CORS Protection - Secure cross-origin resource sharing

๐Ÿ’ซ Core Features Deep Dive

๐ŸŽฏ Match Invitation System

Our sophisticated invitation system supports both directions of match participation:

๐Ÿ“ค Direct Invitations (Creator โ†’ Players)

  1. Search & Invite - Match creators search for users and send invitations
  2. Real-time Notifications - Invited users receive instant notification banners
  3. Quick Actions - Accept or decline invitations with one tap
  4. Status Tracking - Real-time updates on invitation status

๐Ÿ™‹ Join Requests (Player โ†’ Creator)

  1. Request to Join - Players can request to join open matches
  2. Creator Approval - Match creators receive and manage join requests
  3. Notification System - Both parties receive status updates
  4. Automatic Matching - System handles capacity and skill level matching

๐ŸŒ Location-Based Discovery

  • ๐ŸŽฏ Proximity Matching - Find matches within customizable radius (1-50km)
  • ๐Ÿ“ Real-time Location - Optional location sharing for enhanced matching
  • ๐Ÿ—บ๏ธ Interactive Maps - View match locations with tap-to-navigate
  • ๐Ÿ” Smart Filtering - Filter by sport, skill level, time, and distance

๐Ÿ‘ฅ Social Features

  • ๐Ÿ‘ค User Profiles - Comprehensive profiles with sports preferences
  • โญ Review System - Rate and review other players after matches
  • ๐Ÿค Friend System - Send/accept friend requests and build networks
  • ๐Ÿ’ฌ Match Chat - In-app messaging for confirmed match participants

๐ŸŽจ Design System

  • ๐ŸŒ“ Theme Support - Light and dark modes with system preference detection
  • ๐Ÿ“ฑ Responsive UI - Safe area aware design for all device types
  • ๐ŸŽจ Consistent Styling - Design tokens for spacing, colors, and typography
  • โ™ฟ Accessibility - Screen reader support and accessibility best practices

๐Ÿš€ Quick Start

Prerequisites

  • Node.js 18+ and npm
  • Expo CLI (npm install -g @expo/cli)
  • Supabase account and project
  • iOS Simulator (Mac) or Android Studio (development)

โšก One-Command Setup

# Clone and setup entire project
git clone <repository-url>
cd sports-buddy-app

# Install all dependencies
npm run setup:all

# Configure environment (see detailed setup below)
# Then start development
npm run dev:all

๐Ÿ› ๏ธ Detailed Setup

๐Ÿ–ฅ๏ธ Backend Setup

# 1. Navigate to backend
cd backend

# 2. Install dependencies
npm install

# 3. Configure environment
cp .env.example .env

Environment Configuration (.env):

# Server Configuration
PORT=3000
NODE_ENV=development

# Supabase Configuration
SUPABASE_URL=https://your-project.supabase.co
SUPABASE_ANON_KEY=your_anon_key_here
SUPABASE_SERVICE_ROLE_KEY=your_service_role_key_here

# Security Configuration (Optional)
JWT_SECRET=your_jwt_secret_here
API_RATE_LIMIT=1000
AUTH_RATE_LIMIT=10
# 4. Set up database
npm run db:setup  # Runs FINAL_DATABASE_SCHEMA.sql

# 5. Start development server
npm run dev

๐Ÿ“ฑ Mobile App Setup

# 1. Navigate to mobile app
cd mobile/SportsMonkey

# 2. Install dependencies
npm install

# 3. Configure Supabase
# Update src/config/index.ts with your Supabase credentials

# 4. Start Expo development server
npm start

Mobile Configuration (src/config/index.ts):

export const config = {
  supabase: {
    url: 'https://your-project.supabase.co',
    anonKey: 'your_anon_key_here',
  },
  api: {
    baseUrl: 'http://localhost:3000', // or your deployed API URL
  },
};

๐Ÿ”— Shared Types Setup

# Build shared types (required for development)
cd shared
npm install
npm run build

๐Ÿ“š API Reference

๐Ÿ” Authentication Endpoints

POST   /api/auth/signup       # Create new user account
POST   /api/auth/signin       # Sign in user  
POST   /api/auth/signout      # Sign out user
POST   /api/auth/refresh      # Refresh JWT token
GET    /health                # API health check

๐Ÿ‘ค Profile Management

GET    /api/profiles/me       # Get current user profile
PUT    /api/profiles/me       # Update current user profile
GET    /api/profiles/:id      # Get specific user profile
GET    /api/profiles/search   # Search users by location/sport
POST   /api/profiles/sports   # Add sport to user profile
PUT    /api/profiles/sports/:id # Update user sport preferences
DELETE /api/profiles/sports/:id # Remove sport from profile

๐Ÿƒโ€โ™‚๏ธ Sports Data

GET    /api/sports            # Get all available sports
GET    /api/sports/:id        # Get specific sport details
GET    /api/sports/popular    # Get sports popularity statistics

โšฝ Match Management

GET    /api/matches           # Get matches with filtering
POST   /api/matches           # Create new match
GET    /api/matches/:id       # Get specific match details
PUT    /api/matches/:id       # Update match (creator only)
DELETE /api/matches/:id       # Delete match (creator only)
GET    /api/matches/user      # Get user's matches (created & joined)

๐ŸŽฏ Invitation System

POST   /api/matches/:id/join      # Request to join match
POST   /api/matches/:id/leave     # Leave match
POST   /api/matches/:id/invite    # Invite user to match (creator only)
POST   /api/matches/:id/respond   # Respond to invitation (accept/decline)

GET    /api/matches/invitations/received  # Get pending invitations
GET    /api/matches/requests/received     # Get join requests (creator only)
POST   /api/matches/requests/:id/accept   # Accept join request
POST   /api/matches/requests/:id/decline  # Decline join request

๐Ÿ‘ฅ Friends System

GET    /api/friends           # Get user's friends list
GET    /api/friends/requests  # Get pending friend requests
POST   /api/friends/request   # Send friend request
POST   /api/friends/:id/accept   # Accept friend request
POST   /api/friends/:id/decline  # Decline friend request
DELETE /api/friends/:id        # Remove friend

๐Ÿ“ Location Services

GET    /api/location/nearby   # Get nearby users/matches
POST   /api/location/update   # Update user location
GET    /api/location/search   # Search by location name

๐Ÿ—„๏ธ Database Schema

Core Tables

  • profiles - User profiles with location data (PostGIS)
  • sports - Available sports (14 included by default)
  • user_sports - User-sport preferences with skill levels
  • matches - Sports matches with geospatial data
  • match_participants - Invitation/join request management
  • user_connections - Friend system relationships
  • messages - Match-based messaging
  • user_reviews - Player ratings and reviews

Key Features

  • PostGIS Integration - Spatial queries and location indexing
  • Row-Level Security - Comprehensive access control policies
  • Automatic Triggers - updated_at timestamp management
  • Performance Indexes - 20+ optimized indexes for common queries
  • Data Integrity - Foreign keys, constraints, and business logic

Available Sports

Tennis, Basketball, Football/Soccer, Volleyball, Badminton, Table Tennis, Running, Cycling, Swimming, Golf, Baseball, Hockey, Cricket, Rugby

๐Ÿ“ฑ Mobile App Features

๐ŸŽจ UI/UX Components

  • Themed Components - Light/dark mode support
  • Safe Area Design - Works with notches and dynamic islands
  • Interactive Notifications - Real-time invitation banners
  • Smart Navigation - Context-aware navigation flows
  • Responsive Cards - Match and user profile cards
  • Location Integration - Native map integration

๐Ÿ”„ State Management

  • Auth Context - User authentication state
  • Theme Context - UI theme and preferences
  • Location Context - User location management
  • Match Invitations Context - Real-time invitation handling
  • Friends Context - Social connections management

๐Ÿ“ฒ Navigation Structure

App Navigator
โ”œโ”€โ”€ Auth Stack (Unauthenticated)
โ”‚   โ”œโ”€โ”€ Login Screen
โ”‚   โ”œโ”€โ”€ Register Screen
โ”‚   โ””โ”€โ”€ Loading Screen
โ””โ”€โ”€ Main Stack (Authenticated)
    โ”œโ”€โ”€ Tab Navigator
    โ”‚   โ”œโ”€โ”€ Dashboard
    โ”‚   โ”œโ”€โ”€ Nearby Matches
    โ”‚   โ”œโ”€โ”€ Profile
    โ”‚   โ””โ”€โ”€ Friends
    โ”œโ”€โ”€ Create Match
    โ”œโ”€โ”€ Match Details
    โ”œโ”€โ”€ User Search
    โ””โ”€โ”€ Match Search

๐Ÿงช Development & Testing

Development Commands

# Backend Development
cd backend
npm run dev          # Start with nodemon hot reload
npm run build        # Compile TypeScript
npm run type-check   # Check types without compilation
npm run lint         # ESLint checking

# Mobile Development  
cd mobile/SportsMonkey
npm start           # Start Expo dev server
npm run android     # Run on Android
npm run ios         # Run on iOS Simulator
npm run type-check  # TypeScript checking
npm run lint        # ESLint checking

# Shared Types
cd shared
npm run build       # Build shared types
npm run dev         # Watch mode for development

Testing Strategy

  • Unit Tests - Jest for business logic testing
  • Integration Tests - API endpoint testing with Supertest
  • E2E Tests - Detox for mobile app testing
  • Type Safety - Comprehensive TypeScript coverage
  • Manual Testing - Device testing on iOS and Android

๐Ÿšข Deployment

Backend Deployment

  • Production: Deploy to Railway, Heroku, or AWS
  • Database: Managed Supabase PostgreSQL
  • Environment: Production environment variables
  • Monitoring: Health checks and error tracking

Mobile Deployment

  • iOS: App Store via Expo Application Services (EAS)
  • Android: Google Play Store via EAS
  • OTA Updates: Expo Over-The-Air updates for React Native code

๐Ÿ† Development Status

โœ… Completed Features

  • ๐Ÿ” Authentication System - JWT-based with auto-refresh
  • ๐Ÿ“ฑ Core Mobile App - Complete UI with navigation
  • ๐Ÿ—„๏ธ Database Schema - Production-ready with RLS policies
  • ๐ŸŽฏ Invitation System - Bidirectional invites and requests
  • ๐ŸŽจ Theme System - Light/dark mode with design tokens
  • ๐Ÿ“ Location Services - PostGIS-based proximity matching
  • ๐Ÿ‘ฅ Social Features - Friends, reviews, and messaging foundation
  • ๐Ÿ›ก๏ธ Security Implementation - Rate limiting, validation, and protection

๐Ÿšง In Development

  • ๐Ÿ’ฌ Real-time Messaging - Live chat for match participants
  • ๐Ÿ“Š Analytics Dashboard - Match statistics and insights
  • ๐Ÿ”” Push Notifications - Native mobile notifications
  • ๐Ÿ—บ๏ธ Interactive Maps - Enhanced location visualization

๐Ÿ“‹ Planned Features

  • โšก Performance Optimization - Caching and query optimization
  • ๐Ÿ” Advanced Search - AI-powered match recommendations
  • ๐Ÿ“ฑ Offline Support - Offline-first architecture
  • ๐ŸŽฎ Gamification - Achievement system and leaderboards
  • ๐Ÿ”— Social Integration - Share matches on social platforms

๐Ÿค Contributing

Development Guidelines

  1. Fork the repository and create feature branches
  2. Follow TypeScript - Strict type checking required
  3. Test your changes - Unit and integration tests
  4. Update documentation - Keep README and code comments current
  5. Security first - Never expose credentials or sensitive data

Code Style

  • ESLint + Prettier for consistent formatting
  • Conventional Commits for clear git history
  • Component naming - PascalCase for React components
  • File organization - Feature-based folder structure

Pull Request Process

  1. Create feature branch from main
  2. Implement changes with tests
  3. Update documentation if needed
  4. Submit PR with clear description
  5. Address review feedback

๐Ÿ“„ License

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

๐Ÿ“ž Support

  • Documentation: Check DEVELOPMENT.md for development guidance
  • Issues: Create GitHub issues for bugs and feature requests
  • Architecture: Review API_ARCHITECTURE.md for technical details

Built with โค๏ธ for the sports community

About

No description, website, or topics provided.

Resources

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published