Football Fan Social Platform - Architecture and Implementation

1. Project Overview

This document outlines the architecture and implementation details for a football fan social platform built with Bolt and Supabase. The platform allows users to track live matches, rate matches and players, write reviews, and interact with other users through a social following system.

2. Supabase Database Schema

The following tables will be created in Supabase to store application data:

2.1. Core Tables

-- Users table (extends Supabase auth.users)
CREATE TABLE public.profiles (
    id UUID REFERENCES auth.users PRIMARY KEY,
    username TEXT UNIQUE NOT NULL,
    full_name TEXT,
    avatar_url TEXT,
    bio TEXT,
    created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
    updated_at TIMESTAMP WITH TIME ZONE DEFAULT NOW()
);

-- Matches table (populated from API)
CREATE TABLE public.matches (
    id TEXT PRIMARY KEY,
    league_id TEXT NOT NULL,
    home_team_id TEXT NOT NULL,
    away_team_id TEXT NOT NULL,
    home_team_name TEXT NOT NULL,
    away_team_name TEXT NOT NULL,
    home_team_logo TEXT,
    away_team_logo TEXT,
    match_date TIMESTAMP WITH TIME ZONE NOT NULL,
    status TEXT NOT NULL,
    home_score INTEGER,
    away_score INTEGER,
    match_data JSONB,
    created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
    updated_at TIMESTAMP WITH TIME ZONE DEFAULT NOW()
);

-- Teams table (populated from API)
CREATE TABLE public.teams (
    id TEXT PRIMARY KEY,
    name TEXT NOT NULL,
    logo TEXT,
    country TEXT,
    created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
    updated_at TIMESTAMP WITH TIME ZONE DEFAULT NOW()
);

-- Players table (populated from API)
CREATE TABLE public.players (
    id TEXT PRIMARY KEY,
    name TEXT NOT NULL,
    team_id TEXT REFERENCES public.teams(id),
    position TEXT,
    jersey_number INTEGER,
    player_data JSONB,
    created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
    updated_at TIMESTAMP WITH TIME ZONE DEFAULT NOW()
);

-- Match ratings
CREATE TABLE public.match_ratings (
    id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
    user_id UUID REFERENCES public.profiles(id) NOT NULL,
    match_id TEXT REFERENCES public.matches(id) NOT NULL,
    rating INTEGER NOT NULL CHECK (rating >= 1 AND rating <= 5),
    created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
    updated_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
    UNIQUE(user_id, match_id)
);

-- Player ratings
CREATE TABLE public.player_ratings (
    id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
    user_id UUID REFERENCES public.profiles(id) NOT NULL,
    player_id TEXT REFERENCES public.players(id) NOT NULL,
    match_id TEXT REFERENCES public.matches(id) NOT NULL,
    rating INTEGER NOT NULL CHECK (rating >= 1 AND rating <= 5),
    created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
    updated_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
    UNIQUE(user_id, player_id, match_id)
);

-- Reviews
CREATE TABLE public.reviews (
    id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
    user_id UUID REFERENCES public.profiles(id) NOT NULL,
    match_id TEXT REFERENCES public.matches(id) NOT NULL,
    content TEXT NOT NULL,
    created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
    updated_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
    UNIQUE(user_id, match_id)
);

-- Comments
CREATE TABLE public.comments (
    id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
    user_id UUID REFERENCES public.profiles(id) NOT NULL,
    review_id UUID REFERENCES public.reviews(id) NOT NULL,
    content TEXT NOT NULL,
    created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
    updated_at TIMESTAMP WITH TIME ZONE DEFAULT NOW()
);

-- Likes
CREATE TABLE public.likes (
    id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
    user_id UUID REFERENCES public.profiles(id) NOT NULL,
    review_id UUID REFERENCES public.reviews(id) NOT NULL,
    created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
    UNIQUE(user_id, review_id)
);

-- Follows
CREATE TABLE public.follows (
    id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
    follower_id UUID REFERENCES public.profiles(id) NOT NULL,
    following_id UUID REFERENCES public.profiles(id) NOT NULL,
    created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
    UNIQUE(follower_id, following_id),
    CHECK (follower_id != following_id)
);

-- User settings
CREATE TABLE public.user_settings (
    user_id UUID REFERENCES public.profiles(id) PRIMARY KEY,
    theme TEXT DEFAULT 'light' CHECK (theme IN ('light', 'dark')),
    notification_preferences JSONB DEFAULT '{"match_updates": true, "social_interactions": true}'::jsonb,
    created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
    updated_at TIMESTAMP WITH TIME ZONE DEFAULT NOW()
);

2.2. Row Level Security (RLS) Policies

-- Profiles RLS
ALTER TABLE public.profiles ENABLE ROW LEVEL SECURITY;

CREATE POLICY "Public profiles are viewable by everyone"
    ON public.profiles FOR SELECT
    USING (true);

CREATE POLICY "Users can insert their own profile"
    ON public.profiles FOR INSERT
    WITH CHECK (auth.uid() = id);

CREATE POLICY "Users can update their own profile"
    ON public.profiles FOR UPDATE
    USING (auth.uid() = id);

-- Match Ratings RLS
ALTER TABLE public.match_ratings ENABLE ROW LEVEL SECURITY;

CREATE POLICY "Match ratings are viewable by everyone"
    ON public.match_ratings FOR SELECT
    USING (true);

CREATE POLICY "Users can insert their own match ratings"
    ON public.match_ratings FOR INSERT
    WITH CHECK (auth.uid() = user_id);

CREATE POLICY "Users can update their own match ratings"
    ON public.match_ratings FOR UPDATE
    USING (auth.uid() = user_id);

CREATE POLICY "Users can delete their own match ratings"
    ON public.match_ratings FOR DELETE
    USING (auth.uid() = user_id);

-- Similar RLS policies for player_ratings, reviews, comments, likes, follows, and user_settings
-- (Omitted for brevity but follow the same pattern)

2.3. Database Views

-- View for match ratings with average
CREATE VIEW public.match_ratings_with_avg AS
SELECT 
    m.id as match_id,
    m.home_team_name,
    m.away_team_name,
    m.match_date,
    m.status,
    COUNT(mr.id) as rating_count,
    COALESCE(AVG(mr.rating), 0) as avg_rating
FROM 
    public.matches m
LEFT JOIN 
    public.match_ratings mr ON m.id = mr.match_id
GROUP BY 
    m.id, m.home_team_name, m.away_team_name, m.match_date, m.status;

-- View for player ratings with average
CREATE VIEW public.player_ratings_with_avg AS
SELECT 
    p.id as player_id,
    p.name as player_name,
    m.id as match_id,
    m.home_team_name,
    m.away_team_name,
    COUNT(pr.id) as rating_count,
    COALESCE(AVG(pr.rating), 0) as avg_rating
FROM 
    public.players p
JOIN 
    public.matches m ON true
LEFT JOIN 
    public.player_ratings pr ON p.id = pr.player_id AND m.id = pr.match_id
GROUP BY 
    p.id, p.name, m.id, m.home_team_name, m.away_team_name;

-- View for reviews with likes count
CREATE VIEW public.reviews_with_metadata AS
SELECT 
    r.id as review_id,
    r.user_id,
    p.username,
    p.avatar_url,
    r.match_id,
    m.home_team_name,
    m.away_team_name,
    r.content,
    r.created_at,
    COUNT(DISTINCT l.id) as likes_count,
    COUNT(DISTINCT c.id) as comments_count
FROM 
    public.reviews r
JOIN 
    public.profiles p ON r.user_id = p.id
JOIN 
    public.matches m ON r.match_id = m.id
LEFT JOIN 
    public.likes l ON r.id = l.review_id
LEFT JOIN 
    public.comments c ON r.id = c.review_id
GROUP BY 
    r.id, r.user_id, p.username, p.avatar_url, r.match_id, m.home_team_name, m.away_team_name, r.content, r.created_at;

2.4. Database Triggers

-- Trigger to update the updated_at timestamp
CREATE OR REPLACE FUNCTION update_updated_at_column()
RETURNS TRIGGER AS $$
BEGIN
    NEW.updated_at = NOW();
    RETURN NEW;
END;
$$ LANGUAGE plpgsql;

-- Apply the trigger to all tables with updated_at column
CREATE TRIGGER update_profiles_updated_at
BEFORE UPDATE ON public.profiles
FOR EACH ROW EXECUTE FUNCTION update_updated_at_column();

-- (Similar triggers for other tables)

-- Trigger to create user settings when a new profile is created
CREATE OR REPLACE FUNCTION create_user_settings_on_profile_creation()
RETURNS TRIGGER AS $$
BEGIN
    INSERT INTO public.user_settings (user_id)
    VALUES (NEW.id);
    RETURN NEW;
END;
$$ LANGUAGE plpgsql;

CREATE TRIGGER on_profile_created
AFTER INSERT ON public.profiles
FOR EACH ROW EXECUTE FUNCTION create_user_settings_on_profile_creation();

3. Football API Integration

For this project, we'll use the API-Football by API-Sports, which offers a free tier with limited requests but provides comprehensive football data.

3.1. API Setup

// API configuration
const API_URL = 'https://api-football-v1.p.rapidapi.com/v3';
const API_KEY = 'YOUR_API_KEY'; // Replace with your actual API key

// API headers
const headers = {
    'x-rapidapi-host': 'api-football-v1.p.rapidapi.com',
    'x-rapidapi-key': API_KEY
};

// API service
export const footballApiService = {
    // Get live matches
    getLiveMatches: async () => {
        try {
            const response = await fetch(`${API_URL}/fixtures?live=all`, { headers });
            const data = await response.json();
            return data.response;
        } catch (error) {
            console.error('Error fetching live matches:', error);
            throw error;
        }
    },

    // Get match details
    getMatchDetails: async (fixtureId) => {
        try {
            const response = await fetch(`${API_URL}/fixtures?id=${fixtureId}`, { headers });
            const data = await response.json();
            return data.response[0];
        } catch (error) {
            console.error('Error fetching match details:', error);
            throw error;
        }
    },

    // Get match events (goals, cards, etc.)
    getMatchEvents: async (fixtureId) => {
        try {
            const response = await fetch(`${API_URL}/fixtures/events?fixture=${fixtureId}`, { headers });
            const data = await response.json();
            return data.response;
        } catch (error) {
            console.error('Error fetching match events:', error);
            throw error;
        }
    },

    // Get match lineups
    getMatchLineups: async (fixtureId) => {
        try {
            const response = await fetch(`${API_URL}/fixtures/lineups?fixture=${fixtureId}`, { headers });
            const data = await response.json();
            return data.response;
        } catch (error) {
            console.error('Error fetching match lineups:', error);
            throw error;
        }
    },

    // Get match statistics
    getMatchStatistics: async (fixtureId) => {
        try {
            const response = await fetch(`${API_URL}/fixtures/statistics?fixture=${fixtureId}`, { headers });
            const data = await response.json();
            return data.response;
        } catch (error) {
            console.error('Error fetching match statistics:', error);
            throw error;
        }
    },

    // Get league fixtures
    getLeagueFixtures: async (leagueId, season) => {
        try {
            const response = await fetch(`${API_URL}/fixtures?league=${leagueId}&season=${season}`, { headers });
            const data = await response.json();
            return data.response;
        } catch (error) {
            console.error('Error fetching league fixtures:', error);
            throw error;
        }
    },

    // Get team information
    getTeamInfo: async (teamId) => {
        try {
            const response = await fetch(`${API_URL}/teams?id=${teamId}`, { headers });
            const data = await response.json();
            return data.response[0];
        } catch (error) {
            console.error('Error fetching team info:', error);
            throw error;
        }
    },

    // Get player information
    getPlayerInfo: async (playerId) => {
        try {
            const response = await fetch(`${API_URL}/players?id=${playerId}`, { headers });
            const data = await response.json();
            return data.response[0];
        } catch (error) {
            console.error('Error fetching player info:', error);
            throw error;
        }
    }
};

3.2. Data Synchronization with Supabase

import { supabase } from './supabaseClient';
import { footballApiService } from './footballApiService';

// Service to sync API data with Supabase
export const dataSyncService = {
    // Sync live matches with Supabase
    syncLiveMatches: async () => {
        try {
            // Fetch live matches from API
            const liveMatches = await footballApiService.getLiveMatches();
            
            // Process and insert/update matches in Supabase
            for (const match of liveMatches) {
                const fixture = match.fixture;
                const teams = match.teams;
                const goals = match.goals;
                
                // Check if match exists in database
                const { data: existingMatch } = await supabase
                    .from('matches')
                    .select('*')
                    .eq('id', fixture.id)
                    .single();
                
                const matchData = {
                    id: fixture.id.toString(),
                    league_id: match.league.id.toString(),
                    home_team_id: teams.home.id.toString(),
                    away_team_id: teams.away.id.toString(),
                    home_team_name: teams.home.name,
                    away_team_name: teams.away.name,
                    home_team_logo: teams.home.logo,
                    away_team_logo: teams.away.logo,
                    match_date: fixture.date,
                    status: fixture.status.short,
                    home_score: goals.home,
                    away_score: goals.away,
                    match_data: match
                };
                
                if (existingMatch) {
                    // Update existing match
                    await supabase
                        .from('matches')
                        .update(matchData)
                        .eq('id', fixture.id.toString());
                } else {
                    // Insert new match
                    await supabase
                        .from('matches')
                        .insert(matchData);
                    
                    // Also ensure teams exist in the database
                    await syncTeam(teams.home.id);
                    await syncTeam(teams.away.id);
                }
                
                // Sync lineups for this match
                await syncMatchLineups(fixture.id);
            }
            
            return { success: true };
        } catch (error) {
            console.error('Error syncing live matches:', error);
            return { success: false, error };
        }
    },
    
    // Sync upcoming matches for specific leagues
    syncUpcomingMatches: async (leagueIds, season) => {
        try {
            for (const leagueId of leagueIds) {
                const fixtures = await footballApiService.getLeagueFixtures(leagueId, season);
                
                // Process fixtures similar to live matches
                // (Implementation similar to syncLiveMatches)
            }
            
            return { success: true };
        } catch (error) {
            console.error('Error syncing upcoming matches:', error);
            return { success: false, error };
        }
    }
};

// Helper function to sync team data
async function syncTeam(teamId) {
    try {
        // Check if team exists
        const { data: existingTeam } = await supabase
            .from('teams')
            .select('*')
            .eq('id', teamId.toString())
            .single();
        
        if (!existingTeam) {
            // Fetch team data from API
            const teamData = await footballApiService.getTeamInfo(teamId);
            
            // Insert team into database
            await supabase
                .from('teams')
                .insert({
                    id: teamId.toString(),
                    name: teamData.team.name,
                    logo: teamData.team.logo,
                    country: teamData.team.country
                });
        }
    } catch (error) {
        console.error('Error syncing team:', error);
    }
}

// Helper function to sync match lineups and players
async function syncMatchLineups(fixtureId) {
    try {
        const lineups = await footballApiService.getMatchLineups(fixtureId);
        
        for (const lineup of lineups) {
            const teamId = lineup.team.id;
            
            // Process starting XI
            for (const player of lineup.startXI) {
                await syncPlayer(player.player.id, teamId);
            }
            
            // Process substitutes
            for (const player of lineup.substitutes) {
                await syncPlayer(player.player.id, teamId);
            }
        }
    } catch (error) {
        console.error('Error syncing match lineups:', error);
    }
}

// Helper function to sync player data
async function syncPlayer(playerId, teamId) {
    try {
        // Check if player exists
        const { data: existingPlayer } = await supabase
            .from('players')
            .select('*')
            .eq('id', playerId.toString())
            .single();
        
        if (!existingPlayer) {
            // Fetch player data from API
            const playerData = await footballApiService.getPlayerInfo(playerId);
            
            if (playerData && playerData.player) {
                // Insert player into database
                await supabase
                    .from('players')
                    .insert({
                        id: playerId.toString(),
                        name: playerData.player.name,
                        team_id: teamId.toString(),
                        position: playerData.statistics[0]?.games?.position || null,
                        jersey_number: playerData.statistics[0]?.games?.number || null,
                        player_data: playerData
                    });
            }
        }
    } catch (error) {
        console.error('Error syncing player:', error);
    }
}

4. Bolt Frontend Implementation

Now let's implement the frontend using Bolt. We'll create the main screens and components needed for the application.

4.1. Supabase Client Setup

// supabaseClient.js
import { createClient } from '@supabase/supabase-js';

const supabaseUrl = 'YOUR_SUPABASE_URL';
const supabaseAnonKey = 'YOUR_SUPABASE_ANON_KEY';

export const supabase = createClient(supabaseUrl, supabaseAnonKey);

4.2. Authentication Components

// AuthScreen.js
import React, { useState } from 'react';
import { View, Text, TextInput, TouchableOpacity, StyleSheet, Image, Alert } from 'react-native';
import { supabase } from '../supabaseClient';

export default function AuthScreen({ navigation }) {
    const [email, setEmail] = useState('');
    const [password, setPassword] = useState('');
    const [username, setUsername] = useState('');
    const [isLogin, setIsLogin] = useState(true);
    const [loading, setLoading] = useState(false);

    async function signInWithEmail() {
        setLoading(true);
        const { error } = await supabase.auth.signInWithPassword({
            email,
            password,
        });

        if (error) {
            Alert.alert('Error', error.message);
        }
        setLoading(false);
    }

    async function signUpWithEmail() {
        setLoading(true);
        
        // Check if username is available
        const { data: existingUser } = await supabase
            .from('profiles')
            .select('username')
            .eq('username', username)
            .single();
            
        if (existingUser) {
            Alert.alert('Error', 'Username already taken');
            setLoading(false);
            return;
        }
        
        // Create user
        const { data, error } = await supabase.auth.signUp({
            email,
            password,
        });

        if (error) {
            Alert.alert('Error', error.message);
        } else if (data?.user) {
            // Create profile
            const { error: profileError } = await supabase
                .from('profiles')
                .insert([
                    { 
                        id: data.user.id,
                        username,
                        full_name: '',
                        avatar_url: '',
                    },
                ]);
                
            if (profileError) {
                Alert.alert('Error', 'Failed to create profile');
            }
        }
        
        setLoading(false);
    }

    async function signInWithGoogle() {
        const { error } = await supabase.auth.signInWithOAuth({
            provider: 'google',
        });
        
        if (error) {
            Alert.alert('Error', error.message);
        }
    }

    return (
        
            
                
                Football Fan Hub
            
            
            
                {!isLogin && (
                    
                )}
                
                
                
                
                
                
                    
                        {loading ? 'Loading...' : isLogin ? 'Sign In' : 'Sign Up'}
                    
                
                
                
                    Continue with Google
                
                
                 setIsLogin(!isLogin)}
                >
                    
                        {isLogin ? "Don't have an account? Sign Up" : "Already have an account? Sign In"}
                    
                
            
        
    );
}

const styles = StyleSheet.create({
    container: {
        flex: 1,
        backgroundColor: '#efebe4',
        padding: 20,
    },
    header: {
        alignItems: 'center',
        marginVertical: 40,
    },
    logo: {
        width: 100,
        height: 100,
    },
    title: {
        fontSize: 24,
        fontWeight: 'bold',
        color: '#344652',
        marginTop: 10,
    },
    form: {
        backgroundColor: 'white',
        borderRadius: 10,
        padding: 20,
        shadowColor: '#000',
        shadowOffset: { width: 0, height: 2 },
        shadowOpacity: 0.1,
        shadowRadius: 4,
        elevation: 2,
    },
    input: {
        backgroundColor: '#f5f5f5',
        borderRadius: 5,
        padding: 15,
        marginBottom: 15,
        fontSize: 16,
    },
    button: {
        backgroundColor: '#ffb143',
        borderRadius: 5,
        padding: 15,
        alignItems: 'center',
        marginBottom: 15,
    },
    googleButton: {
        backgroundColor: '#344652',
        borderRadius: 5,
        padding: 15,
        alignItems: 'center',
        marginBottom: 15,
    },
    buttonText: {
        color: 'white',
        fontSize: 16,
        fontWeight: 'bold',
    },
    switchButton: {
        alignItems: 'center',
        marginTop: 10,
    },
    switchButtonText: {
        color: '#344652',
        fontSize: 14,
    },
});

4.3. Main Navigation Setup

// App.js
import React, { useState, useEffect } from 'react';
import { NavigationContainer } from '@react-navigation/native';
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
import { createStackNavigator } from '@react-navigation/stack';
import { supabase } from './supabaseClient';
import { StatusBar } from 'react-native';
import { Ionicons } from '@expo/vector-icons';

// Screens
import AuthScreen from './screens/AuthScreen';
import HomeScreen from './screens/HomeScreen';
import LiveMatchesScreen from './screens/LiveMatchesScreen';
import MatchDetailScreen from './screens/MatchDetailScreen';
import ProfileScreen from './screens/ProfileScreen';
import SettingsScreen from './screens/SettingsScreen';
import UserProfileScreen from './screens/UserProfileScreen';
import ReviewDetailScreen from './screens/ReviewDetailScreen';

const Stack = createStackNavigator();
const Tab = createBottomTabNavigator();

// Main tab navigator
function MainTabs() {
    return (
         ({
                tabBarIcon: ({ focused, color, size }) => {
                    let iconName;

                    if (route.name === 'Home') {
                        iconName = focused ? 'home' : 'home-outline';
                    } else if (route.name === 'Live') {
                        iconName = focused ? 'football' : 'football-outline';
                    } else if (route.name === 'Profile') {
                        iconName = focused ? 'person' : 'person-outline';
                    } else if (route.name === 'Settings') {
                        iconName = focused ? 'settings' : 'settings-outline';
                    }

                    return ;
                },
                tabBarActiveTintColor: '#ffb143',
                tabBarInactiveTintColor: '#344652',
                tabBarStyle: {
                    backgroundColor: '#efebe4',
                    borderTopWidth: 0,
                    elevation: 0,
                    shadowOpacity: 0,
                },
                headerStyle: {
                    backgroundColor: '#efebe4',
                    elevation: 0,
                    shadowOpacity: 0,
                },
                headerTitleStyle: {
                    color: '#344652',
                    fontWeight: 'bold',
                },
            })}
        >
            
            
            
            
        
    );
}

export default function App() {
    const [session, setSession] = useState(null);
    const [loading, setLoading] = useState(true);

    useEffect(() => {
        // Listen for auth changes
        const { data: authListener } = supabase.auth.onAuthStateChange(
            (event, session) => {
                setSession(session);
                setLoading(false);
            }
        );

        // Check current session
        supabase.auth.getSession().then(({ data: { session } }) => {
            setSession(session);
            setLoading(false);
        });

        return () => {
            authListener?.subscription.unsubscribe();
        };
    }, []);

    if (loading) {
        return null; // Or a loading screen
    }

    return (
        
            
            
                {!session ? (
                    
                ) : (
                    <>
                        
                         ({ 
                                title: `${route.params.homeTeam} vs ${route.params.awayTeam}` 
                            })}
                        />
                         ({ title: route.params.username })}
                        />
                        
                    
                )}
            
        
    );
}

4.4. Home Screen

// HomeScreen.js
import React, { useState, useEffect } from 'react';
import { View, Text, FlatList, TouchableOpacity, StyleSheet, RefreshControl, Image } from 'react-native';
import { supabase } from '../supabaseClient';
import { dataSyncService } from '../services/dataSyncService';
import MatchCard from '../components/MatchCard';
import ReviewCard from '../components/ReviewCard';

export default function HomeScreen({ navigation }) {
    const [upcomingMatches, setUpcomingMatches] = useState([]);
    const [recentReviews, setRecentReviews] = useState([]);
    const [refreshing, setRefreshing] = useState(false);
    const [profile, setProfile] = useState(null);

    useEffect(() => {
        fetchData();
        fetchProfile();
    }, []);

    async function fetchProfile() {
        const { data: { user } } = await supabase.auth.getUser();
        if (user) {
            const { data } = await supabase
                .from('profiles')
                .select('*')
                .eq('id', user.id)
                .single();
            setProfile(data);
        }
    }

    async function fetchData() {
        setRefreshing(true);
        
        // Fetch upcoming matches
        const { data: matches } = await supabase
            .from('matches')
            .select('*')
            .eq('status', 'NS') // Not Started
            .order('match_date', { ascending: true })
            .limit(5);
        
        setUpcomingMatches(matches || []);
        
        // Fetch recent reviews
        const { data: reviews } = await supabase
            .from('reviews_with_metadata')
            .select('*')
            .order('created_at', { ascending: false })
            .limit(10);
        
        setRecentReviews(reviews || []);
        
        setRefreshing(false);
    }

    async function syncData() {
        setRefreshing(true);
        await dataSyncService.syncLiveMatches();
        await dataSyncService.syncUpcomingMatches([1, 2, 3], '2023'); // Example league IDs
        await fetchData();
        setRefreshing(false);
    }

    return (
        
            {profile && (
                
                    Welcome back, {profile.username}!
                
            )}
            
             'main'}
                renderItem={() => (
                    
                        
                            
                                Upcoming Matches
                                 navigation.navigate('Live')}>
                                    See All
                                
                            
                            
                            {upcomingMatches.length > 0 ? (
                                 item.id.toString()}
                                    renderItem={({ item }) => (
                                         navigation.navigate('MatchDetail', {
                                                matchId: item.id,
                                                homeTeam: item.home_team_name,
                                                awayTeam: item.away_team_name
                                            })}
                                        />
                                    )}
                                    showsHorizontalScrollIndicator={false}
                                    style={styles.horizontalList}
                                />
                            ) : (
                                
                                    No upcoming matches
                                
                            )}
                        
                        
                        
                            
                                Recent Reviews
                            
                            
                            {recentReviews.length > 0 ? (
                                recentReviews.map((review) => (
                                     navigation.navigate('ReviewDetail', { reviewId: review.review_id })}
                                        onUserPress={() => navigation.navigate('UserProfile', { 
                                            userId: review.user_id,
                                            username: review.username
                                        })}
                                    />
                                ))
                            ) : (
                                
                                    No reviews yet
                                
                            )}
                        
                    
                )}
                refreshControl={
                    
                }
            />
        
    );
}

const styles = StyleSheet.create({
    container: {
        flex: 1,
        backgroundColor: '#efebe4',
    },
    welcomeSection: {
        padding: 15,
        backgroundColor: '#344652',
        marginBottom: 10,
    },
    welcomeText: {
        color: 'white',
        fontSize: 18,
        fontWeight: 'bold',
    },
    section: {
        marginBottom: 20,
        padding: 15,
    },
    sectionHeader: {
        flexDirection: 'row',
        justifyContent: 'space-between',
        alignItems: 'center',
        marginBottom: 10,
    },
    sectionTitle: {
        fontSize: 18,
        fontWeight: 'bold',
        color: '#344652',
    },
    seeAllText: {
        color: '#ffb143',
        fontWeight: 'bold',
    },
    horizontalList: {
        marginLeft: -5,
    },
    emptyState: {
        padding: 20,
        alignItems: 'center',
        backgroundColor: 'white',
        borderRadius: 10,
        marginVertical: 10,
    },
    emptyStateText: {
        color: '#344652',
        fontSize: 16,
    },
});

4.5. Live Matches Screen

// LiveMatchesScreen.js
import React, { useState, useEffect } from 'react';
import { View, Text, FlatList, StyleSheet, RefreshControl, TouchableOpacity } from 'react-native';
import { supabase } from '../supabaseClient';
import { dataSyncService } from '../services/dataSyncService';
import LiveMatchCard from '../components/LiveMatchCard';

export default function LiveMatchesScreen({ navigation }) {
    const [liveMatches, setLiveMatches] = useState([]);
    const [upcomingMatches, setUpcomingMatches] = useState([]);
    const [refreshing, setRefreshing] = useState(false);
    const [activeTab, setActiveTab] = useState('live');

    useEffect(() => {
        fetchMatches();
        
        // Set up interval to refresh live matches
        const interval = setInterval(() => {
            if (activeTab === 'live') {
                fetchLiveMatches();
            }
        }, 60000); // Refresh every minute
        
        return () => clearInterval(interval);
    }, [activeTab]);

    async function fetchMatches() {
        setRefreshing(true);
        await fetchLiveMatches();
        await fetchUpcomingMatches();
        setRefreshing(false);
    }

    async function fetchLiveMatches() {
        // Sync with API first
        await dataSyncService.syncLiveMatches();
        
        // Then fetch from Supabase
        const { data } = await supabase
            .from('matches')
            .select('*')
            .in('status', ['1H', '2H', 'HT', 'ET', 'P', 'BT']) // Live match statuses
            .order('match_date', { ascending: true });
        
        setLiveMatches(data || []);
    }

    async function fetchUpcomingMatches() {
        const today = new Date();
        const tomorrow = new Date(today);
        tomorrow.setDate(tomorrow.getDate() + 1);
        tomorrow.setHours(23, 59, 59, 999);
        
        const { data } = await supabase
            .from('matches')
            .select('*')
            .eq('status', 'NS') // Not Started
            .lt('match_date', tomorrow.toISOString())
            .gt('match_date', today.toISOString())
            .order('match_date', { ascending: true });
        
        setUpcomingMatches(data || []);
    }

    function renderMatchList() {
        const data = activeTab === 'live' ? liveMatches : upcomingMatches;
        
        if (data.length === 0) {
            return (
                
                    
                        {activeTab === 'live' 
                            ? 'No live matches at the moment' 
                            : 'No upcoming matches today'}
                    
                
            );
        }
        
        return (
             item.id.toString()}
                renderItem={({ item }) => (
                     navigation.navigate('MatchDetail', {
                            matchId: item.id,
                            homeTeam: item.home_team_name,
                            awayTeam: item.away_team_name,
                            isLive: activeTab === 'live'
                        })}
                    />
                )}
                contentContainerStyle={styles.listContent}
            />
        );
    }

    return (
        
            
                 setActiveTab('live')}
                >
                    Live Now
                
                
                 setActiveTab('upcoming')}
                >
                    Today
                
            
            
            
                {renderMatchList()}
            
            
            
        
    );
}

const styles = StyleSheet.create({
    container: {
        flex: 1,
        backgroundColor: '#efebe4',
    },
    tabContainer: {
        flexDirection: 'row',
        backgroundColor: 'white',
        marginHorizontal: 15,
        marginTop: 15,
        borderRadius: 10,
        overflow: 'hidden',
    },
    tab: {
        flex: 1,
        paddingVertical: 12,
        alignItems: 'center',
    },
    activeTab: {
        backgroundColor: '#ffb143',
    },
    tabText: {
        color: '#344652',
        fontWeight: 'bold',
    },
    activeTabText: {
        color: 'white',
    },
    content: {
        flex: 1,
        marginTop: 15,
    },
    listContent: {
        padding: 15,
    },
    emptyState: {
        flex: 1,
        justifyContent: 'center',
        alignItems: 'center',
        padding: 20,
    },
    emptyStateText: {
        color: '#344652',
        fontSize: 16,
        textAlign: 'center',
    },
});

4.6. Match Detail Screen

// MatchDetailScreen.js
import React, { useState, useEffect, useRef } from 'react';
import { 
    View, 
    Text, 
    ScrollView, 
    StyleSheet, 
    TouchableOpacity, 
    TextInput,
    Image,
    ActivityIndicator,
    Alert
} from 'react-native';
import { supabase } from '../supabaseClient';
import { footballApiService } from '../services/footballApiService';
import { Ionicons } from '@expo/vector-icons';
import StarRating from '../components/StarRating';
import PlayerRatingCard from '../components/PlayerRatingCard';
import ReviewList from '../components/ReviewList';

export default function MatchDetailScreen({ route, navigation }) {
    const { matchId, isLive = false } = route.params;
    const [match, setMatch] = useState(null);
    const [events, setEvents] = useState([]);
    const [lineups, setLineups] = useState([]);
    const [statistics, setStatistics] = useState([]);
    const [loading, setLoading] = useState(true);
    const [activeTab, setActiveTab] = useState('timeline');
    const [userRating, setUserRating] = useState(0);
    const [reviewContent, setReviewContent] = useState('');
    const [submitting, setSubmitting] = useState(false);
    const [userReview, setUserReview] = useState(null);
    const [reviews, setReviews] = useState([]);
    const [refreshInterval, setRefreshInterval] = useState(null);
    const scrollViewRef = useRef();

    useEffect(() => {
        fetchMatchData();
        
        // Set up refresh interval for live matches
        if (isLive) {
            const interval = setInterval(() => {
                fetchMatchData(false);
            }, 60000); // Refresh every minute
            setRefreshInterval(interval);
        }
        
        return () => {
            if (refreshInterval) {
                clearInterval(refreshInterval);
            }
        };
    }, [matchId, isLive]);

    async function fetchMatchData(showLoading = true) {
        if (showLoading) setLoading(true);
        
        // Fetch match details from Supabase
        const { data: matchData } = await supabase
            .from('matches')
            .select('*')
            .eq('id', matchId)
            .single();
        
        setMatch(matchData);
        
        // Fetch match events from API
        const eventsData = await footballApiService.getMatchEvents(matchId);
        setEvents(eventsData || []);
        
        // Fetch lineups from API
        const lineupsData = await footballApiService.getMatchLineups(matchId);
        setLineups(lineupsData || []);
        
        // Fetch statistics from API
        const statsData = await footballApiService.getMatchStatistics(matchId);
        setStatistics(statsData || []);
        
        // Fetch user's rating for this match
        const { data: { user } } = await supabase.auth.getUser();
        if (user) {
            const { data: ratingData } = await supabase
                .from('match_ratings')
                .select('*')
                .eq('user_id', user.id)
                .eq('match_id', matchId)
                .single();
            
            if (ratingData) {
                setUserRating(ratingData.rating);
            }
            
            // Fetch user's review for this match
            const { data: reviewData } = await supabase
                .from('reviews')
                .select('*')
                .eq('user_id', user.id)
                .eq('match_id', matchId)
                .single();
            
            if (reviewData) {
                setUserReview(reviewData);
                setReviewContent(reviewData.content);
            }
        }
        
        // Fetch all reviews for this match
        const { data: reviewsData } = await supabase
            .from('reviews_with_metadata')
            .select('*')
            .eq('match_id', matchId)
            .order('created_at', { ascending: false });
        
        setReviews(reviewsData || []);
        
        if (showLoading) setLoading(false);
    }

    async function handleRateMatch(rating) {
        const { data: { user } } = await supabase.auth.getUser();
        if (!user) {
            Alert.alert('Error', 'You must be logged in to rate matches');
            return;
        }
        
        // Check if match is finished
        if (match.status === 'NS') {
            Alert.alert('Error', 'You cannot rate a match that has not started yet');
            return;
        }
        
        setUserRating(rating);
        
        // Check if user has already rated this match
        const { data: existingRating } = await supabase
            .from('match_ratings')
            .select('*')
            .eq('user_id', user.id)
            .eq('match_id', matchId)
            .single();
        
        if (existingRating) {
            // Update existing rating
            await supabase
                .from('match_ratings')
                .update({ rating })
                .eq('id', existingRating.id);
        } else {
            // Insert new rating
            await supabase
                .from('match_ratings')
                .insert([
                    {
                        user_id: user.id,
                        match_id: matchId,
                        rating
                    }
                ]);
        }
    }

    async function handleSubmitReview() {
        if (!reviewContent.trim()) {
            Alert.alert('Error', 'Review content cannot be empty');
            return;
        }
        
        const { data: { user } } = await supabase.auth.getUser();
        if (!user) {
            Alert.alert('Error', 'You must be logged in to submit a review');
            return;
        }
        
        setSubmitting(true);
        
        try {
            if (userReview) {
                // Update existing review
                await supabase
                    .from('reviews')
                    .update({ content: reviewContent })
                    .eq('id', userReview.id);
            } else {
                // Insert new review
                const { data, error } = await supabase
                    .from('reviews')
                    .insert([
                        {
                            user_id: user.id,
                            match_id: matchId,
                            content: reviewContent
                        }
                    ]);
                
                if (error) throw error;
            }
            
            // Refresh reviews
            await fetchMatchData(false);
            Alert.alert('Success', 'Your review has been submitted');
        } catch (error) {
            Alert.alert('Error', error.message);
        } finally {
            setSubmitting(false);
        }
    }

    function renderTimeline() {
        if (events.length === 0) {
            return (
                
                    No events available
                
            );
        }
        
        // Sort events by time
        const sortedEvents = [...events].sort((a, b) => a.time.elapsed - b.time.elapsed);
        
        return (
            
                {sortedEvents.map((event, index) => (
                    
                        
                        
                            {event.time.elapsed}'
                        
                        
                            
                                {event.team.name} - {event.player.name}
                                {event.assist && event.assist.name && ` (Assist: ${event.assist.name})`}
                            
                            {event.type}
                        
                    
                ))}
            
        );
    }

    function renderLineups() {
        if (lineups.length === 0) {
            return (
                
                    No lineup information available
                
            );
        }
        
        return (
            
                {lineups.map((team, index) => (
                    
                        
                            
                            {team.team.name}
                        
                        
                        Starting XI
                        {team.startXI.map((player, playerIndex) => (
                            
                        ))}
                        
                        Substitutes
                        {team.substitutes.map((player, playerIndex) => (
                            
                        ))}
                    
                ))}
            
        );
    }

    function renderStatistics() {
        if (statistics.length === 0) {
            return (
                
                    No statistics available
                
            );
        }
        
        // Assuming statistics[0] is home team and statistics[1] is away team
        const homeStats = statistics[0];
        const awayStats = statistics[1];
        
        return (
            
                
                    {homeStats.team.name}
                    Statistic
                    {awayStats.team.name}
                
                
                {homeStats.statistics.map((stat, index) => (
                    
                        {stat.value || 0}
                        {stat.type}
                        {awayStats.statistics[index].value || 0}
                    
                ))}
            
        );
    }

    function renderReviews() {
        return (
            
                
                    Your Review
                    
                    
                        
                            {submitting ? 'Submitting...' : userReview ? 'Update Review' : 'Submit Review'}
                        
                    
                
                
                 navigation.navigate('UserProfile', { userId, username })}
                    onReviewPress={(reviewId) => navigation.navigate('ReviewDetail', { reviewId })}
                />
            
        );
    }

    if (loading) {
        return (
            
                
            
        );
    }

    return (
        
            
                
                    
                        
                        {match.home_team_name}
                    
                    
                    
                        
                            {match.home_score !== null ? match.home_score : '-'}
                            {' - '}
                            {match.away_score !== null ? match.away_score : '-'}
                        
                        
                            {match.status === 'NS' ? 'Not Started' : 
                             match.status === 'FT' ? 'Full Time' : 
                             match.status === 'HT' ? 'Half Time' : 
                             match.status === '1H' ? '1st Half' : 
                             match.status === '2H' ? '2nd Half' : match.status}
                        
                    
                    
                    
                        
                        {match.away_team_name}
                    
                
                
                
                    Rate this match:
                    
                    {(match.status === 'NS' || isLive) && (
                        
                            Rating will be available after the match ends
                        
                    )}
                
                
                
                     {
                            setActiveTab('timeline');
                            scrollViewRef.current?.scrollTo({ y: 0, animated: true });
                        }}
                    >
                        
                            Timeline
                        
                    
                    
                     {
                            setActiveTab('lineups');
                            scrollViewRef.current?.scrollTo({ y: 0, animated: true });
                        }}
                    >
                        
                            Lineups
                        
                    
                    
                     {
                            setActiveTab('stats');
                            scrollViewRef.current?.scrollTo({ y: 0, animated: true });
                        }}
                    >
                        
                            Stats
                        
                    
                    
                     {
                            setActiveTab('reviews');
                            scrollViewRef.current?.scrollTo({ y: 0, animated: true });
                        }}
                    >
                        
                            Reviews
                        
                    
                
                
                
                    {activeTab === 'timeline' && renderTimeline()}
                    {activeTab === 'lineups' && renderLineups()}
                    {activeTab === 'stats' && renderStatistics()}
                    {activeTab === 'reviews' && renderReviews()}
                
            
        
    );
}

const styles = StyleSheet.create({
    container: {
        flex: 1,
        backgroundColor: '#efebe4',
    },
    loadingContainer: {
        flex: 1,
        justifyContent: 'center',
        alignItems: 'center',
    },
    matchHeader: {
        flexDirection: 'row',
        justifyContent: 'space-between',
        alignItems: 'center',
        backgroundColor: 'white',
        padding: 15,
        marginBottom: 10,
    },
    teamContainer: {
        alignItems: 'center',
        flex: 1,
    },
    teamLogo: {
        width: 50,
        height: 50,
        marginBottom: 5,
    },
    teamName: {
        fontSize: 14,
        fontWeight: 'bold',
        color: '#344652',
        textAlign: 'center',
    },
    scoreContainer: {
        alignItems: 'center',
        paddingHorizontal: 10,
    },
    scoreText: {
        fontSize: 24,
        fontWeight: 'bold',
        color: '#344652',
    },
    matchStatus: {
        fontSize: 12,
        color: '#ffb143',
        marginTop: 5,
    },
    ratingContainer: {
        backgroundColor: 'white',
        padding: 15,
        alignItems: 'center',
        marginBottom: 10,
    },
    ratingLabel: {
        fontSize: 16,
        color: '#344652',
        marginBottom: 10,
    },
    ratingDisabledText: {
        fontSize: 12,
        color: '#888',
        marginTop: 5,
        fontStyle: 'italic',
    },
    tabContainer: {
        flexDirection: 'row',
        backgroundColor: 'white',
        marginBottom: 10,
    },
    tab: {
        flex: 1,
        paddingVertical: 12,
        alignItems: 'center',
    },
    activeTab: {
        borderBottomWidth: 2,
        borderBottomColor: '#ffb143',
    },
    tabText: {
        color: '#344652',
        fontWeight: 'bold',
    },
    activeTabText: {
        color: '#ffb143',
    },
    tabContent: {
        backgroundColor: 'white',
        padding: 15,
        marginBottom: 20,
    },
    emptyState: {
        padding: 20,
        alignItems: 'center',
    },
    emptyStateText: {
        color: '#888',
        fontSize: 16,
    },
    // Timeline styles
    timelineContainer: {
        paddingVertical: 10,
    },
    timelineEvent: {
        flexDirection: 'row',
        marginBottom: 15,
        position: 'relative',
    },
    timelineDot: {
        width: 10,
        height: 10,
        borderRadius: 5,
        backgroundColor: '#ffb143',
        marginTop: 5,
    },
    timelineTime: {
        width: 40,
        marginLeft: 10,
    },
    timelineTimeText: {
        fontWeight: 'bold',
        color: '#344652',
    },
    timelineContent: {
        flex: 1,
        marginLeft: 10,
    },
    timelineEventText: {
        fontSize: 14,
        color: '#344652',
    },
    timelineEventType: {
        fontSize: 12,
        color: '#888',
        marginTop: 2,
    },
    // Lineups styles
    lineupsContainer: {
        paddingVertical: 10,
    },
    teamLineup: {
        marginBottom: 20,
    },
    teamHeader: {
        flexDirection: 'row',
        alignItems: 'center',
        marginBottom: 10,
    },
    lineupSectionTitle: {
        fontSize: 16,
        fontWeight: 'bold',
        color: '#344652',
        marginTop: 10,
        marginBottom: 5,
    },
    // Stats styles
    statsContainer: {
        paddingVertical: 10,
    },
    statsHeader: {
        flexDirection: 'row',
        justifyContent: 'space-between',
        marginBottom: 15,
        paddingBottom: 10,
        borderBottomWidth: 1,
        borderBottomColor: '#d9d2c6',
    },
    statsTeamName: {
        fontSize: 14,
        fontWeight: 'bold',
        color: '#344652',
        flex: 1,
        textAlign: 'center',
    },
    statsLabel: {
        fontSize: 14,
        fontWeight: 'bold',
        color: '#344652',
        flex: 1,
        textAlign: 'center',
    },
    statRow: {
        flexDirection: 'row',
        justifyContent: 'space-between',
        marginBottom: 10,
    },
    statName: {
        fontSize: 14,
        color: '#344652',
        flex: 1,
        textAlign: 'center',
    },
    statValue: {
        fontSize: 14,
        color: '#344652',
        fontWeight: 'bold',
        flex: 1,
        textAlign: 'center',
    },
    // Reviews styles
    reviewsContainer: {
        paddingVertical: 10,
    },
    reviewInputContainer: {
        marginBottom: 20,
        padding: 15,
        backgroundColor: '#f5f5f5',
        borderRadius: 10,
    },
    reviewInputLabel: {
        fontSize: 16,
        fontWeight: 'bold',
        color: '#344652',
        marginBottom: 10,
    },
    reviewInput: {
        backgroundColor: 'white',
        borderRadius: 5,
        padding: 10,
        minHeight: 100,
        textAlignVertical: 'top',
        marginBottom: 10,
    },
    submitButton: {
        backgroundColor: '#ffb143',
        borderRadius: 5,
        padding: 12,
        alignItems: 'center',
    },
    submitButtonText: {
        color: 'white',
        fontWeight: 'bold',
    },
});

4.7. Profile Screen

// ProfileScreen.js
import React, { useState, useEffect } from 'react';
import { 
    View, 
    Text, 
    StyleSheet, 
    Image, 
    TouchableOpacity, 
    FlatList,
    RefreshControl,
    Alert
} from 'react-native';
import { supabase } from '../supabaseClient';
import { Ionicons } from '@expo/vector-icons';
import ReviewCard from '../components/ReviewCard';

export default function ProfileScreen({ navigation }) {
    const [profile, setProfile] = useState(null);
    const [reviews, setReviews] = useState([]);
    const [followers, setFollowers] = useState([]);
    const [following, setFollowing] = useState([]);
    const [activeTab, setActiveTab] = useState('reviews');
    const [refreshing, setRefreshing] = useState(false);

    useEffect(() => {
        fetchProfile();
    }, []);

    async function fetchProfile() {
        setRefreshing(true);
        
        const { data: { user } } = await supabase.auth.getUser();
        if (user) {
            // Fetch profile
            const { data: profileData } = await supabase
                .from('profiles')
                .select('*')
                .eq('id', user.id)
                .single();
            
            setProfile(profileData);
            
            // Fetch reviews
            const { data: reviewsData } = await supabase
                .from('reviews_with_metadata')
                .select('*')
                .eq('user_id', user.id)
                .order('created_at', { ascending: false });
            
            setReviews(reviewsData || []);
            
            // Fetch followers
            const { data: followersData } = await supabase
                .from('follows')
                .select('follower_id, profiles!follows_follower_id_fkey(id, username, avatar_url)')
                .eq('following_id', user.id);
            
            setFollowers(followersData || []);
            
            // Fetch following
            const { data: followingData } = await supabase
                .from('follows')
                .select('following_id, profiles!follows_following_id_fkey(id, username, avatar_url)')
                .eq('follower_id', user.id);
            
            setFollowing(followingData || []);
        }
        
        setRefreshing(false);
    }

    function renderReviews() {
        if (reviews.length === 0) {
            return (
                
                    You haven't written any reviews yet
                
            );
        }
        
        return (
             item.review_id}
                renderItem={({ item }) => (
                     navigation.navigate('ReviewDetail', { reviewId: item.review_id })}
                    />
                )}
                contentContainerStyle={styles.listContent}
            />
        );
    }

    function renderFollowers() {
        if (followers.length === 0) {
            return (
                
                    You don't have any followers yet
                
            );
        }
        
        return (
             item.follower_id}
                renderItem={({ item }) => (
                     navigation.navigate('UserProfile', { 
                            userId: item.follower_id,
                            username: item.profiles.username
                        })}
                    >
                        
                        {item.profiles.username}
                    
                )}
                contentContainerStyle={styles.listContent}
            />
        );
    }

    function renderFollowing() {
        if (following.length === 0) {
            return (
                
                    You're not following anyone yet
                
            );
        }
        
        return (
             item.following_id}
                renderItem={({ item }) => (
                     navigation.navigate('UserProfile', { 
                            userId: item.following_id,
                            username: item.profiles.username
                        })}
                    >
                        
                        {item.profiles.username}
                    
                )}
                contentContainerStyle={styles.listContent}
            />
        );
    }

    if (!profile) {
        return (
            
                Loading profile...
            
        );
    }

    return (
        
            
                
                
                {profile.username}
                
                {profile.bio && (
                    {profile.bio}
                )}
                
                
                    
                        {reviews.length}
                        Reviews
                    
                    
                    
                        {followers.length}
                        Followers
                    
                    
                    
                        {following.length}
                        Following
                    
                
                
                 navigation.navigate('Settings')}
                >
                    Edit Profile
                
            
            
            
                 setActiveTab('reviews')}
                >
                    
                        Reviews
                    
                
                
                 setActiveTab('followers')}
                >
                    
                        Followers
                    
                
                
                 setActiveTab('following')}
                >
                    
                        Following
                    
                
            
            
            
                {activeTab === 'reviews' && renderReviews()}
                {activeTab === 'followers' && renderFollowers()}
                {activeTab === 'following' && renderFollowing()}
            
            
            
        
    );
}

const styles = StyleSheet.create({
    container: {
        flex: 1,
        backgroundColor: '#efebe4',
    },
    loadingContainer: {
        flex: 1,
        justifyContent: 'center',
        alignItems: 'center',
    },
    profileHeader: {
        backgroundColor: 'white',
        padding: 20,
        alignItems: 'center',
    },
    profileAvatar: {
        width: 100,
        height: 100,
        borderRadius: 50,
        marginBottom: 10,
    },
    profileName: {
        fontSize: 20,
        fontWeight: 'bold',
        color: '#344652',
        marginBottom: 5,
    },
    profileBio: {
        fontSize: 14,
        color: '#666',
        textAlign: 'center',
        marginBottom: 15,
    },
    statsContainer: {
        flexDirection: 'row',
        justifyContent: 'space-around',
        width: '100%',
        marginVertical: 15,
    },
    statItem: {
        alignItems: 'center',
    },
    statValue: {
        fontSize: 18,
        fontWeight: 'bold',
        color: '#344652',
    },
    statLabel: {
        fontSize: 12,
        color: '#666',
    },
    editButton: {
        backgroundColor: '#ffb143',
        paddingVertical: 8,
        paddingHorizontal: 20,
        borderRadius: 20,
    },
    editButtonText: {
        color: 'white',
        fontWeight: 'bold',
    },
    tabContainer: {
        flexDirection: 'row',
        backgroundColor: 'white',
        marginTop: 10,
    },
    tab: {
        flex: 1,
        paddingVertical: 12,
        alignItems: 'center',
    },
    activeTab: {
        borderBottomWidth: 2,
        borderBottomColor: '#ffb143',
    },
    tabText: {
        color: '#344652',
        fontWeight: 'bold',
    },
    activeTabText: {
        color: '#ffb143',
    },
    content: {
        flex: 1,
        marginTop: 10,
    },
    listContent: {
        padding: 15,
    },
    emptyState: {
        flex: 1,
        justifyContent: 'center',
        alignItems: 'center',
        padding: 20,
    },
    emptyStateText: {
        color: '#666',
        fontSize: 16,
        textAlign: 'center',
    },
    userItem: {
        flexDirection: 'row',
        alignItems: 'center',
        backgroundColor: 'white',
        padding: 15,
        borderRadius: 10,
        marginBottom: 10,
    },
    userAvatar: {
        width: 50,
        height: 50,
        borderRadius: 25,
        marginRight: 15,
    },
    userName: {
        fontSize: 16,
        fontWeight: 'bold',
        color: '#344652',
    },
});

4.8. Settings Screen

// SettingsScreen.js
import React, { useState, useEffect } from 'react';
import { 
    View, 
    Text, 
    StyleSheet, 
    TouchableOpacity, 
    Switch, 
    TextInput,
    ScrollView,
    Alert,
    Image
} from 'react-native';
import { supabase } from '../supabaseClient';
import { Ionicons } from '@expo/vector-icons';
import * as ImagePicker from 'expo-image-picker';

export default function SettingsScreen({ navigation }) {
    const [profile, setProfile] = useState(null);
    const [settings, setSettings] = useState(null);
    const [username, setUsername] = useState('');
    const [fullName, setFullName] = useState('');
    const [bio, setBio] = useState('');
    const [email, setEmail] = useState('');
    const [darkMode, setDarkMode] = useState(false);
    const [matchNotifications, setMatchNotifications] = useState(true);
    const [socialNotifications, setSocialNotifications] = useState(true);
    const [loading, setLoading] = useState(false);
    const [avatarUrl, setAvatarUrl] = useState(null);

    useEffect(() => {
        fetchUserData();
    }, []);

    async function fetchUserData() {
        const { data: { user } } = await supabase.auth.getUser();
        if (user) {
            // Fetch profile
            const { data: profileData } = await supabase
                .from('profiles')
                .select('*')
                .eq('id', user.id)
                .single();
            
            if (profileData) {
                setProfile(profileData);
                setUsername(profileData.username || '');
                setFullName(profileData.full_name || '');
                setBio(profileData.bio || '');
                setAvatarUrl(profileData.avatar_url);
            }
            
            // Fetch user settings
            const { data: settingsData } = await supabase
                .from('user_settings')
                .select('*')
                .eq('user_id', user.id)
                .single();
            
            if (settingsData) {
                setSettings(settingsData);
                setDarkMode(settingsData.theme === 'dark');
                setMatchNotifications(settingsData.notification_preferences?.match_updates || true);
                setSocialNotifications(settingsData.notification_preferences?.social_interactions || true);
            }
            
            // Fetch email
            setEmail(user.email);
        }
    }

    async function updateProfile() {
        setLoading(true);
        
        const { data: { user } } = await supabase.auth.getUser();
        if (!user) {
            Alert.alert('Error', 'User not found');
            setLoading(false);
            return;
        }
        
        // Check if username is taken (if changed)
        if (username !== profile.username) {
            const { data: existingUser } = await supabase
                .from('profiles')
                .select('username')
                .eq('username', username)
                .neq('id', user.id)
                .single();
                
            if (existingUser) {
                Alert.alert('Error', 'Username already taken');
                setLoading(false);
                return;
            }
        }
        
        // Update profile
        const { error: profileError } = await supabase
            .from('profiles')
            .update({
                username,
                full_name: fullName,
                bio,
                avatar_url: avatarUrl,
                updated_at: new Date()
            })
            .eq('id', user.id);
            
        if (profileError) {
            Alert.alert('Error', profileError.message);
            setLoading(false);
            return;
        }
        
        // Update settings
        const { error: settingsError } = await supabase
            .from('user_settings')
            .update({
                theme: darkMode ? 'dark' : 'light',
                notification_preferences: {
                    match_updates: matchNotifications,
                    social_interactions: socialNotifications
                },
                updated_at: new Date()
            })
            .eq('user_id', user.id);
            
        if (settingsError) {
            Alert.alert('Error', settingsError.message);
        } else {
            Alert.alert('Success', 'Profile updated successfully');
        }
        
        setLoading(false);
    }

    async function handleLogout() {
        const { error } = await supabase.auth.signOut();
        
        if (error) {
            Alert.alert('Error', error.message);
        }
    }

    async function handleDeleteAccount() {
        Alert.alert(
            'Delete Account',
            'Are you sure you want to delete your account? This action cannot be undone.',
            [
                {
                    text: 'Cancel',
                    style: 'cancel'
                },
                {
                    text: 'Delete',
                    style: 'destructive',
                    onPress: async () => {
                        setLoading(true);
                        
                        // In a real app, you would call a Supabase function to delete the user
                        // For this example, we'll just sign out
                        const { error } = await supabase.auth.signOut();
                        
                        if (error) {
                            Alert.alert('Error', error.message);
                        }
                        
                        setLoading(false);
                    }
                }
            ]
        );
    }

    async function pickImage() {
        const result = await ImagePicker.launchImageLibraryAsync({
            mediaTypes: ImagePicker.MediaTypeOptions.Images,
            allowsEditing: true,
            aspect: [1, 1],
            quality: 0.8,
        });
        
        if (!result.cancelled && result.assets && result.assets[0].uri) {
            // In a real app, you would upload this to storage
            // For this example, we'll just use the URI
            setAvatarUrl(result.assets[0].uri);
        }
    }

    if (!profile || !settings) {
        return (
            
                Loading settings...
            
        );
    }

    return (
        
            
                Profile
                
                
                    
                    
                        Change Photo
                    
                
                
                
                    Username
                    
                
                
                
                    Full Name
                    
                
                
                
                    Bio
                    
                
                
                
                    Email
                    
                    Email cannot be changed
                
            
            
            
                Appearance
                
                
                    Dark Mode
                    
                
            
            
            
                Notifications
                
                
                    Match Updates
                    
                
                
                
                    Social Interactions
                    
                
            
            
            
                
                    
                        {loading ? 'Saving...' : 'Save Changes'}
                    
                
                
                
                    Logout
                
                
                
                    Delete Account
                
            
        
    );
}

const styles = StyleSheet.create({
    container: {
        flex: 1,
        backgroundColor: '#efebe4',
    },
    loadingContainer: {
        flex: 1,
        justifyContent: 'center',
        alignItems: 'center',
    },
    section: {
        backgroundColor: 'white',
        marginVertical: 10,
        padding: 15,
    },
    sectionTitle: {
        fontSize: 18,
        fontWeight: 'bold',
        color: '#344652',
        marginBottom: 15,
    },
    avatarContainer: {
        alignItems: 'center',
        marginBottom: 20,
    },
    avatar: {
        width: 100,
        height: 100,
        borderRadius: 50,
        marginBottom: 10,
    },
    changeAvatarButton: {
        backgroundColor: '#344652',
        paddingVertical: 8,
        paddingHorizontal: 15,
        borderRadius: 20,
    },
    changeAvatarText: {
        color: 'white',
        fontWeight: 'bold',
    },
    inputContainer: {
        marginBottom: 15,
    },
    inputLabel: {
        fontSize: 14,
        color: '#344652',
        marginBottom: 5,
    },
    input: {
        backgroundColor: '#f5f5f5',
        borderRadius: 5,
        padding: 12,
        fontSize: 16,
    },
    bioInput: {
        minHeight: 100,
        textAlignVertical: 'top',
    },
    helperText: {
        fontSize: 12,
        color: '#888',
        marginTop: 5,
    },
    settingItem: {
        flexDirection: 'row',
        justifyContent: 'space-between',
        alignItems: 'center',
        paddingVertical: 10,
    },
    settingLabel: {
        fontSize: 16,
        color: '#344652',
    },
    buttonContainer: {
        padding: 15,
        marginBottom: 30,
    },
    saveButton: {
        backgroundColor: '#ffb143',
        borderRadius: 5,
        padding: 15,
        alignItems: 'center',
        marginBottom: 15,
    },
    saveButtonText: {
        color: 'white',
        fontWeight: 'bold',
        fontSize: 16,
    },
    logoutButton: {
        backgroundColor: '#344652',
        borderRadius: 5,
        padding: 15,
        alignItems: 'center',
        marginBottom: 15,
    },
    logoutButtonText: {
        color: 'white',
        fontWeight: 'bold',
        fontSize: 16,
    },
    deleteButton: {
        backgroundColor: '#f5f5f5',
        borderRadius: 5,
        padding: 15,
        alignItems: 'center',
    },
    deleteButtonText: {
        color: '#d9534f',
        fontWeight: 'bold',
        fontSize: 16,
    },
});

4.9. Reusable Components

// components/MatchCard.js
import React from 'react';
import { View, Text, StyleSheet, TouchableOpacity, Image } from 'react-native';

export default function MatchCard({ match, onPress }) {
    // Format date
    const matchDate = new Date(match.match_date);
    const formattedDate = matchDate.toLocaleDateString('en-US', {
        month: 'short',
        day: 'numeric'
    });
    const formattedTime = matchDate.toLocaleTimeString('en-US', {
        hour: '2-digit',
        minute: '2-digit'
    });

    return (
        
            {formattedDate} • {formattedTime}
            
            
                
                    
                    {match.home_team_name}
                
                
                
                    
                        {match.status !== 'NS' && match.home_score !== null ? match.home_score : '-'}
                        {' vs '}
                        {match.status !== 'NS' && match.away_score !== null ? match.away_score : '-'}
                    
                
                
                
                    
                    {match.away_team_name}
                
            
            
            
                {match.status === 'NS' ? 'Upcoming' : 
                 match.status === 'FT' ? 'Finished' : 
                 match.status === '1H' ? '1st Half' :
                 match.status === '2H' ? '2nd Half' :
                 match.status === 'HT' ? 'Half Time' : match.status}
            
        
    );
}

const styles = StyleSheet.create({
    card: {
        backgroundColor: 'white',
        borderRadius: 10,
        padding: 15,
        marginRight: 15,
        marginBottom: 10,
        width: 250,
        shadowColor: '#000',
        shadowOffset: { width: 0, height: 1 },
        shadowOpacity: 0.1,
        shadowRadius: 2,
        elevation: 2,
    },
    dateText: {
        fontSize: 12,
        color: '#888',
        marginBottom: 10,
    },
    teamsContainer: {
        flexDirection: 'row',
        justifyContent: 'space-between',
        alignItems: 'center',
        marginBottom: 10,
    },
    teamContainer: {
        alignItems: 'center',
        width: '35%',
    },
    teamLogo: {
        width: 40,
        height: 40,
        marginBottom: 5,
    },
    teamName: {
        fontSize: 12,
        color: '#344652',
        textAlign: 'center',
    },
    scoreContainer: {
        width: '30%',
        alignItems: 'center',
    },
    scoreText: {
        fontSize: 16,
        fontWeight: 'bold',
        color: '#344652',
    },
    statusText: {
        fontSize: 12,
        color: '#ffb143',
        textAlign: 'center',
    },
});

// components/LiveMatchCard.js
import React from 'react';
import { View, Text, StyleSheet, TouchableOpacity, Image } from 'react-native';

export default function LiveMatchCard({ match, onPress }) {
    // Format date
    const matchDate = new Date(match.match_date);
    const formattedTime = matchDate.toLocaleTimeString('en-US', {
        hour: '2-digit',
        minute: '2-digit'
    });

    const isLive = ['1H', '2H', 'HT', 'ET', 'P', 'BT'].includes(match.status);

    return (
        
            
                {isLive && (
                    
                        
                        LIVE
                    
                )}
                {formattedTime}
            
            
            
                
                    
                    {match.home_team_name}
                    
                        {match.status !== 'NS' && match.home_score !== null ? match.home_score : '-'}
                    
                
                
                
                    
                    {match.away_team_name}
                    
                        {match.status !== 'NS' && match.away_score !== null ? match.away_score : '-'}
                    
                
            
            
            
                {match.status === 'NS' ? 'Not Started' : 
                 match.status === 'FT' ? 'Full Time' : 
                 match.status === '1H' ? '1st Half' :
                 match.status === '2H' ? '2nd Half' :
                 match.status === 'HT' ? 'Half Time' : match.status}
            
        
    );
}

const styles = StyleSheet.create({
    card: {
        backgroundColor: 'white',
        borderRadius: 10,
        padding: 15,
        marginBottom: 10,
        shadowColor: '#000',
        shadowOffset: { width: 0, height: 1 },
        shadowOpacity: 0.1,
        shadowRadius: 2,
        elevation: 2,
    },
    header: {
        flexDirection: 'row',
        justifyContent: 'space-between',
        alignItems: 'center',
        marginBottom: 10,
    },
    liveIndicator: {
        flexDirection: 'row',
        alignItems: 'center',
        backgroundColor: '#f0f0f0',
        paddingHorizontal: 8,
        paddingVertical: 4,
        borderRadius: 12,
    },
    liveDot: {
        width: 8,
        height: 8,
        borderRadius: 4,
        backgroundColor: '#ff4d4d',
        marginRight: 5,
    },
    liveText: {
        fontSize: 12,
        fontWeight: 'bold',
        color: '#ff4d4d',
    },
    timeText: {
        fontSize: 12,
        color: '#888',
    },
    teamsContainer: {
        marginBottom: 10,
    },
    teamRow: {
        flexDirection: 'row',
        alignItems: 'center',
        marginBottom: 10,
    },
    teamLogo: {
        width: 30,
        height: 30,
        marginRight: 10,
    },
    teamName: {
        flex: 1,
        fontSize: 16,
        color: '#344652',
    },
    scoreText: {
        fontSize: 18,
        fontWeight: 'bold',
        color: '#344652',
        width: 30,
        textAlign: 'center',
    },
    statusText: {
        fontSize: 12,
        color: '#ffb143',
        textAlign: 'right',
    },
});

// components/StarRating.js
import React from 'react';
import { View, StyleSheet, TouchableOpacity } from 'react-native';
import { Ionicons } from '@expo/vector-icons';

export default function StarRating({ rating, onRatingChange, disabled = false, size = 30 }) {
    const stars = [1, 2, 3, 4, 5];
    
    return (
        
            {stars.map((star) => (
                 !disabled && onRatingChange(star)}
                    disabled={disabled}
                    style={styles.starButton}
                >
                    = star ? 'star' : 'star-outline'}
                        size={size}
                        color={rating >= star ? '#ffb143' : '#d9d2c6'}
                    />
                
            ))}
        
    );
}

const styles = StyleSheet.create({
    container: {
        flexDirection: 'row',
    },
    starButton: {
        padding: 5,
    },
});

// components/PlayerRatingCard.js
import React, { useState, useEffect } from 'react';
import { View, Text, StyleSheet, TouchableOpacity, Alert } from 'react-native';
import { supabase } from '../supabaseClient';
import StarRating from './StarRating';

export default function PlayerRatingCard({ player, position, number, matchId, disabled = false }) {
    const [rating, setRating] = useState(0);
    const [avgRating, setAvgRating] = useState(0);
    const [ratingCount, setRatingCount] = useState(0);
    
    useEffect(() => {
        fetchRatings();
    }, []);
    
    async function fetchRatings() {
        // Fetch user's rating for this player
        const { data: { user } } = await supabase.auth.getUser();
        if (user) {
            const { data: userRating } = await supabase
                .from('player_ratings')
                .select('rating')
                .eq('user_id', user.id)
                .eq('player_id', player.id)
                .eq('match_id', matchId)
                .single();
                
            if (userRating) {
                setRating(userRating.rating);
            }
        }
        
        // Fetch average rating
        const { data: ratings } = await supabase
            .from('player_ratings')
            .select('rating')
            .eq('player_id', player.id)
            .eq('match_id', matchId);
            
        if (ratings && ratings.length > 0) {
            const sum = ratings.reduce((acc, curr) => acc + curr.rating, 0);
            setAvgRating(sum / ratings.length);
            setRatingCount(ratings.length);
        }
    }
    
    async function handleRatePlayer(newRating) {
        if (disabled) return;
        
        const { data: { user } } = await supabase.auth.getUser();
        if (!user) {
            Alert.alert('Error', 'You must be logged in to rate players');
            return;
        }
        
        setRating(newRating);
        
        // Check if user has already rated this player
        const { data: existingRating } = await supabase
            .from('player_ratings')
            .select('*')
            .eq('user_id', user.id)
            .eq('player_id', player.id)
            .eq('match_id', matchId)
            .single();
            
        if (existingRating) {
            // Update existing rating
            await supabase
                .from('player_ratings')
                .update({ rating: newRating })
                .eq('id', existingRating.id);
        } else {
            // Insert new rating
            await supabase
                .from('player_ratings')
                .insert([
                    {
                        user_id: user.id,
                        player_id: player.id,
                        match_id: matchId,
                        rating: newRating
                    }
                ]);
        }
        
        // Refresh ratings
        fetchRatings();
    }
    
    return (
        
            
                {number || '-'}
                
                    {player.name}
                    {position || 'Unknown'}
                
            
            
            
                
                {ratingCount > 0 && (
                    
                        Avg: {avgRating.toFixed(1)} ({ratingCount})
                    
                )}
            
        
    );
}

const styles = StyleSheet.create({
    container: {
        flexDirection: 'row',
        justifyContent: 'space-between',
        alignItems: 'center',
        paddingVertical: 10,
        borderBottomWidth: 1,
        borderBottomColor: '#f0f0f0',
    },
    playerInfo: {
        flexDirection: 'row',
        alignItems: 'center',
        flex: 1,
    },
    playerNumber: {
        width: 25,
        fontSize: 14,
        fontWeight: 'bold',
        color: '#344652',
    },
    playerDetails: {
        flex: 1,
    },
    playerName: {
        fontSize: 14,
        fontWeight: 'bold',
        color: '#344652',
    },
    playerPosition: {
        fontSize: 12,
        color: '#888',
    },
    ratingContainer: {
        alignItems: 'flex-end',
    },
    avgRating: {
        fontSize: 10,
        color: '#888',
        marginTop: 2,
    },
});

// components/ReviewCard.js
import React from 'react';
import { View, Text, StyleSheet, TouchableOpacity, Image } from 'react-native';
import { Ionicons } from '@expo/vector-icons';

export default function ReviewCard({ review, onPress, onUserPress }) {
    // Format date
    const reviewDate = new Date(review.created_at);
    const formattedDate = reviewDate.toLocaleDateString('en-US', {
        year: 'numeric',
        month: 'short',
        day: 'numeric'
    });
    
    return (
        
            
                 onUserPress && onUserPress(review.user_id, review.username)}
                >
                    
                    {review.username}
                
                {formattedDate}
            
            
            
                
                    {review.home_team_name} vs {review.away_team_name}
                
            
            
            
                {review.content}
            
            
            
                
                    
                    {review.likes_count}
                
                
                
                    
                    {review.comments_count}
                
            
        
    );
}

const styles = StyleSheet.create({
    container: {
        backgroundColor: 'white',
        borderRadius: 10,
        padding: 15,
        marginBottom: 15,
        shadowColor: '#000',
        shadowOffset: { width: 0, height: 1 },
        shadowOpacity: 0.1,
        shadowRadius: 2,
        elevation: 2,
    },
    header: {
        flexDirection: 'row',
        justifyContent: 'space-between',
        alignItems: 'center',
        marginBottom: 10,
    },
    userInfo: {
        flexDirection: 'row',
        alignItems: 'center',
    },
    avatar: {
        width: 30,
        height: 30,
        borderRadius: 15,
        marginRight: 10,
    },
    username: {
        fontSize: 14,
        fontWeight: 'bold',
        color: '#344652',
    },
    date: {
        fontSize: 12,
        color: '#888',
    },
    matchInfo: {
        marginBottom: 10,
    },
    matchTitle: {
        fontSize: 16,
        fontWeight: 'bold',
        color: '#344652',
    },
    content: {
        fontSize: 14,
        color: '#344652',
        marginBottom: 10,
    },
    footer: {
        flexDirection: 'row',
        borderTopWidth: 1,
        borderTopColor: '#f0f0f0',
        paddingTop: 10,
    },
    stat: {
        flexDirection: 'row',
        alignItems: 'center',
        marginRight: 15,
    },
    statText: {
        fontSize: 14,
        color: '#344652',
        marginLeft: 5,
    },
});

// components/ReviewList.js
import React from 'react';
import { View, Text, StyleSheet, FlatList } from 'react-native';
import ReviewCard from './ReviewCard';

export default function ReviewList({ reviews, onUserPress, onReviewPress }) {
    if (reviews.length === 0) {
        return (
            
                No reviews yet
            
        );
    }
    
    return (
        
            All Reviews
            
            {reviews.map((review) => (
                 onReviewPress(review.review_id)}
                    onUserPress={onUserPress}
                />
            ))}
        
    );
}

const styles = StyleSheet.create({
    container: {
        marginTop: 20,
    },
    title: {
        fontSize: 18,
        fontWeight: 'bold',
        color: '#344652',
        marginBottom: 15,
    },
    emptyState: {
        padding: 20,
        alignItems: 'center',
    },
    emptyStateText: {
        color: '#888',
        fontSize: 16,
    },
});

5. Implementation Notes

5.1. API Selection

For this project, we've chosen API-Football by API-Sports, which offers:

To use this API, you'll need to:

  1. Sign up at RapidAPI
  2. Subscribe to the API-Football API
  3. Get your API key and replace 'YOUR_API_KEY' in the code

5.2. Data Synchronization Strategy

The application uses a hybrid approach for data management:

The dataSyncService handles synchronization between the API and Supabase, ensuring data consistency.

5.3. Authentication Flow

The application uses Supabase Auth for authentication with the following flow:

  1. User signs up/in via email/password or OAuth (Google)
  2. On successful authentication, a profile is created in the profiles table
  3. User settings are automatically created via a database trigger
  4. The app listens for auth state changes to update the UI accordingly

5.4. Security Considerations

The application implements several security measures:

5.5. Performance Optimization

To ensure good performance, the application implements:

6. Deployment Instructions

6.1. Supabase Setup

  1. Create a new Supabase project at supabase.com
  2. Execute the SQL scripts provided in Section 2 to create the database schema
  3. Configure authentication providers (email/password and Google OAuth)
  4. Get your Supabase URL and anon key for the client

6.2. API Setup

  1. Sign up for API-Football at RapidAPI
  2. Subscribe to a plan (free tier available)
  3. Get your API key

6.3. Environment Configuration

Create a .env file with the following variables:

SUPABASE_URL=your_supabase_url
SUPABASE_ANON_KEY=your_supabase_anon_key
API_FOOTBALL_KEY=your_api_football_key

6.4. Building and Running the App

  1. Install dependencies: npm install
  2. Start the development server: npm start
  3. Run on iOS: npm run ios
  4. Run on Android: npm run android

7. Future Enhancements

Potential improvements for future versions: