# Laravel Sports News Aggregator

## Overview

This is a comprehensive sports news aggregation and match scheduling application built with **Laravel**. It features automated content scraping from SkySports, AI-powered content rewriting using Google Gemini, live match data from Streami, and specific SEO optimizations including sitemap generation and pseudo-article search results.

---

## Features

*   **Automated Article Scraping**: Fetches the latest sports news from SkySports across multiple categories (Football, F1, Cricket, etc.).
*   **AI Content Rewriting**: Uses Google Gemini API to rewrite scraped articles, generating unique titles, content, and SEO metadata.
*   **Live Match Schedule**: Displays a daily schedule of matches with live status updates, team badges, and "Watch" links.
*   **Dynamic SEO**:
    *   Custom meta titles/descriptions for match pages based on selected sport.
    *   Search results pages formatted as "articles" (Fake H1, Intro, Author) to improve indexing.
    *   Automated Sitemap generation for Posts, Matches, Sports Categories, and Keyword-based pages.
*   **Keyword Landing Pages**: Automatically generates SEO-friendly landing pages (`/news/{slug}`) from a list of keywords in `public/keywords/*.txt`.

---

## Requirements

*   **PHP**: ^8.1
*   **Laravel**: ^10.0
*   **Composer**
*   **Database**: MySQL / MariaDB

---

## Installation

1.  **Clone the Repository**
    ```bash
    git clone https://github.com/your-repo/laravel-sports.git
    cd laravel-sports
    ```

2.  **Install Dependencies**
    ```bash
    composer install
    npm install && npm run build
    ```

3.  **Environment Setup**
    *   Copy `.env.example` to `.env`.
    *   Configure your database credentials.
    *   Add your API keys:
        ```dotenv
        GEMINI_API_KEY=your_gemini_key_here
        # Other scraper configurations if needed
        ```

4.  **Database Migration**
    ```bash
    php artisan migrate
    ```

5.  **Serve Application**
    ```bash
    php artisan serve
    ```

---

## Key Commands & Usage

### 1. Scrapers

*   **Scrape Matches**: Fetches the latest match schedule from Streami.
    ```bash
    php artisan scrape:matches
    ```
    *Scheduled to run every 4 hours.*

*   **Scrape Articles (Sitemap Logic)**: Scrapes the latest 20 articles for *every* sport category defined in the system.
    ```bash
    php artisan scrape:sitemap-articles
    ```
    *Scheduled to run every 3 hours.*

*   **Scrape SkySports (Manual)**: More granular control over scraping specific categories.
    ```bash
    php artisan scrape:skysports --pages=1 --ai
    ```

### 2. Sitemaps

The application generates dynamic sitemaps at:

*   `/sitemap.xml`: Main index.
*   `/sitemap-main.xml`: Homepage and static categories.
*   `/sitemap-matches.xml`: Match pages.
*   `/sitemap-sports-articles.xml`: Links to latest articles per sport.
*   `/sitemap-keywords-{file}.xml`: Generated from txt files in `public/keywords/`.

### 3. Keyword Landing Pages

To create bulk SEO landing pages:
1.  Create a text file in `public/keywords/` (e.g., `football-trends.txt`).
2.  Add keywords, one per line.
3.  The system automatically:
    *   Adds them to the sitemap.
    *   Makes them accessible at `/news/keyword-slug`.
    *   Renders them as an "Article" with a custom intro and relevant search results.

---

## Scheduling

To ensure data stays fresh, ensure the Laravel scheduler is running on your server:

```cron
* * * * * cd /path-to-project && php artisan schedule:run >> /dev/null 2>&1
```

This will trigger:
*   `scrape:matches` (Every 4 hours)
*   `scrape:sitemap-articles` (Every 3 hours)

---

## Folder Structure Highlights

*   `app/Console/Commands`: Custom scraper commands.
*   `app/Http/Controllers/SportController.php`: Main logic for Home, Matches, Search/News.
*   `app/Http/Controllers/AssetController.php`: Sitemap generation logic.
*   `app/Services`:
    *   `SkySportsService`: Interaction with SkySports website.
    *   `StreamiService`: Match data fetching.
    *   `GeminiService`: AI content generation.
    *   `ImageScraperService`: Yandex image scraping logic.
