GitHunt
MA

MahmoudNamNam/FC-Barcelona-Reports

FC Barcelona Reports: An interactive web application to analyze and visualize FC Barcelona's match data. Built with Streamlit, it scrapes match data from WhoScored, stores it in MongoDB, and presents insights through interactive visualizations like pass networks, shot maps, and player statistics.

Barcelona Logo

FC Barcelona Reports

Overview

This project provides a web application for analyzing and visualizing FC Barcelona's match data. The application is built with Streamlit, scrapes match data from WhoScored, processes and stores it in MongoDB, and displays it in a streamlined dashboard.
screenshot-fcbmatchreport-streamlit-app-1733617811709

Features

  • Data Scraping: Scrapes FC Barcelona's match data from WhoScored.

  • MongoDB Storage: Stores all match, team, player, and event data in MongoDB.

  • Data Visualization: Interactive visualizations including:

    • Pass networks
    • Shot maps
    • Match momentum
    • Team statistics
    • Player Statistics: Detailed stats for each player, including goals, assists, pass accuracy, and more.
    • Competition Summary: Summary statistics for each competition, such as total matches played, wins, goals scored, and key performance metrics.
  • Streamlit Interface: Simple and interactive web dashboard for viewing and analyzing match data.

Prerequisites

  • Python 3.7+
  • MongoDB instance
  • Chrome WebDriver (for Selenium)

Installation

  1. Clone the repository:

    git clone https://github.com/MahmoudNamNam/FC-Barcelona-Reports
    cd FC-Barcelona-Reports
  2. Set up environment variables:

    • Create a .env file in the project root and add your MongoDB URI:

      MONGO_URI="your_mongodb_connection_string"
  3. Install dependencies:

    pip install -r requirements.txt

Usage

1. Data Scraping

To scrape data and add it to your MongoDB, run:

python scraper.py
  • This script only scrapes new matches not already in the database.

2. Start the Streamlit App

To launch the dashboard, run:

streamlit run dashboard.py

Project Structure

  • scraper.py: Web scraping script that fetches match data from WhoScored.
  • data_loader.py: Loads data from MongoDB into DataFrames.
  • dashboard.py: Streamlit app for displaying match data.
  • visualizations.py: Functions for visualizations used in the app.
  • utilities.py: Helper functions and utilities for data processing and analysis.
  • config.toml: Configuration for Streamlit app styling.
  • .env: Environment variables.

Requirements

Dependencies listed in requirements.txt:

  • pandas
  • numpy
  • selenium
  • pymongo
  • beautifulsoup4
  • streamlit
  • mplsoccer
  • matplotlib
  • python-dotenv

Notes

  • Environment Variables: Ensure .env is added to .gitignore to keep credentials secure.
  • Chrome WebDriver: Ensure compatibility with your Chrome version. You may need to update the webdriver.Chrome() configuration in scraper.py based on your setup.

Future Enhancements

  • Add support for other teams or leagues.
  • Include more advanced visualizations and analytics.
  • Enable user authentication to save and share custom reports.