FUT.AI, derived from 'Futbol' or Soccer, is a robust full-stack web application designed to bring soccer enthusiasts the latest from La Liga. It combines data from various APIs, presents weather conditions for the games, and AI-generates insightful articles about the matches using. Our service-oriented architecture ensures scalability and robust data management through microservices, each tailored for specific functions.
- Real-time Soccer Match Information: Fetches latest fixtures, team details, live scores, and more from La Liga.
- Weather Updates: Provides real-time weather conditions for the cities where the matches are held.
- Dynamic Article Generation: Utilizes OpenAI GPT 3.5 to generate narrative articles based on match results and weather conditions.
- Interactive Web Interface: Sleek and user-friendly interface displaying fixtures, allowing users to select favorite teams, and accessing generated articles.
FUT.AI is structured into several directories, each representing a microservice with its own Dockerfile and Kubernetes configuration for service deployment and management.
- FootballAPI: Integrates with API-FOOTBALL from RAPIDAPI to gather and store data about game fixtures, team details, and scores in Supabase.
- WeatherAPI: Uses WeatherAPI.com to fetch and update weather conditions for match locations in the same Supabase table.
- ArticleGenerator: Employs OpenAI GPT 3.5 to generate and store articles based on data from FootballAPI and WeatherAPI.
- Website: Built with React + Vite and JoyUI, features:
- Fixtures Page: Displays upcoming games using sleek UI cards.
- Favorite Teams Page: Allows selection and management of favorite La Liga teams.
- Blog Page: Shows articles generated for selected favorite teams.
- Kubernetes: Manages services, deployments, and cron jobs. Includes Config Maps and Secrets for secure API key storage.
Before setting up the project, ensure you have the following software and accounts set up:
- Docker: Download Docker
- Kubernetes: Install Google Cloud CLI and follow the instructions to set up a Kubernetes cluster on Google Kubernetes Engine (GKE). Setting up a GKE cluster
- Supabase account: Create a Supabase account
For managing different Kubernetes clusters, including the transition from a local environment (like Docker Desktop) to Google Kubernetes Engine (GKE), follow these steps to set up and switch context to the GKE cluster:
-
Install gcloud CLI
Download and install the Google Cloud CLI. After installation, if prompted with choices, use Ctrl-C to exit the prompt. Make sure to restart your Visual Studio Code or other IDEs to update the path environment variables after installation.
# Visit the official page to download and install gcloud CLI https://cloud.google.com/sdk/docs/install -
Log into Google with IAM
Authenticate your Google account with the following command:
gcloud auth login
Enter the email associated with your Google account that has been registered with Google via the Identity and Access Management (IAM) for our GKE cluster.
-
Get the GKE context
Install the necessary GKE authentication plugin:
gcloud components install gke-gcloud-auth-plugin
Then, fetch the credentials for the GKE cluster:
gcloud container clusters get-credentials autopilot-cluster-1 --region us-central1 --project horizontal-ray-375222
This command configures
kubectlto use the credentials for the specified GKE cluster.
-
List available contexts:
kubectl config get-contexts
-
Check the current context:
kubectl config current-context
-
Switch to the GKE cluster context:
kubectl config set-context gke_horizontal-ray-375222_us-central1_autopilot-cluster-1
-
Verify connection to the GKE cluster:
kubectl get nodes
If the command displays the nodes of the GKE cluster, you have successfully connected and can now use
kubectlandhelmto manage the cluster.
To organize your resources within the GKE cluster, create a namespace:
kubectl create namespace <your-namespace-name>Switch namespace from default to <your-namespace-name>
kubectl config set-context --current --namespace=<your-namespace-name>Replace <your-namespace-name> with your preferred name for the namespace.
After completing the development of our Full Stack App, we began Dockerizing our application. Each microservice (excluding the Kubernetes directory) was equipped with its own Dockerfile. However, we encountered our first major challenge when we realized the need for multi-architecture Docker images to accommodate different hardware architectures.
# Creating a new Docker builder
docker buildx create --name mybuilder --use
docker buildx inspect --bootstrap
# Building and pushing multi-architecture images
docker buildx build --platform linux/amd64,linux/arm64 -t yourusername/football-api:v1 --push .This approach ensured compatibility across different server architectures, which is essential for deploying on GKE.
For each microservice, we created Service.yaml and Deployment.yaml files. These Kubernetes configurations leverage Docker images and integrate environmental configurations through Kubernetes Secrets and ConfigMaps, enhancing security and manageability of sensitive data.
ConfigMaps and Secrets were set up to securely store and provide configuration data and API keys to our services. This separation of sensitive information from our application code is critical for maintaining the security and integrity of our application in a production environment.
This section outlines the steps for deploying code using Kubernetes.
-
Apply your Kubernetes configuration Deploy your configuration files located in the Kubernetes directory.
kubectl apply -f Kubernetes/
-
Verify the deployment Check the status of all components (pods, services, deployments, etc.) to ensure everything is running as expected.
kubectl get all
-
Check Ingress configurations Verify the Ingress to ensure it is set up correctly and review the associated IP addresses and hosts.
kubectl get ingress -o wide
-
View the application Access the application by visiting the IP address provided in your Ingress configurations, that exposes Port
80of the cluster. In this case:- Go to
34.36.57.193
- Go to
We implemented two CronJobs to automate our services:
- GetFixtures CronJob: Updates football match fixtures and associated data daily.
- GenerateArticles CronJob: Generates and stores articles based on the latest matches and weather conditions.
Our CI/CD pipeline automates the deployment process, ensuring quick and secure updates with each push to the main branch. Here's a brief overview of each step:
- Trigger: Activates automatically on push to
main. - Checkout: Pulls the latest code from the repository.
- Setup Buildx: Configures Docker Buildx for multi-architecture support (amd64 and arm64).
- Docker Login: Authenticates to Docker Hub using secure GitHub Secrets.
Build and Push Steps for Each Service:
- ArticleGenerator:
docker buildx build --platform linux/amd64,linux/arm64 -t yourusername/article-generator:v1 --push . - FootballAPI:
docker buildx build --platform linux/amd64,linux/arm64 -t yourusername/football-api:v1 --push . - WeatherAPI:
docker buildx build --platform linux/amd64,linux/arm64 -t yourusername/weather-api:v1 --push . - Website:
docker buildx build --platform linux/amd64,linux/arm64 -t yourusername/website:v1 --push .
Each component is built and pushed to Docker Hub, ensuring that our services are always up-to-date and available for deployment.
Create a new Python script named futai.py. This script will handle parsing command line arguments and include the functionality to open a web browser to the ingress address.
import sys
import webbrowser
def open_browser(address):
""" Opens the default web browser to the specified address. """
webbrowser.open(address)
def main():
# Check the command line arguments
if len(sys.argv) > 1:
command = sys.argv[1]
if command == 'run':
# Ingress address for your application
ingress_address = 'http://34.36.57.193'
open_browser(ingress_address)
else:
print(f"Unknown command {command}")
else:
print("Usage: futai <command>")
print("Commands:")
print(" run Opens the application in the web browser.")
if __name__ == "__main__":
main()To run the script from the command line easily, you can make it executable and add a shebang line at the top of the script.
Add a shebang line at the start of your futai.py:
#!/usr/bin/env python3Make the script executable:
chmod +x futai.pyMove the script to a directory in your PATH (optional, for ease of use):
sudo mv futai.py /usr/local/bin/futaiNow, you can use the CLI tool by simply typing:
futai runThis command should open the default web browser to the ingress address of your application.
Follow these steps to set up the FUT.AI project on your local machine for development and testing purposes:
-
Clone the repository
git clone https://github.com/akhargha/FUT.AI
-
Navigate to the project directory
cd FUT.AI -
ArticleGenerator setup Navigate to the
ArticleGeneratordirectory and install the necessary dependencies.cd ArticleGenerator pip install -r requirements.txt virtualenv venv source venv/bin/activate export OPENAI_API_KEY='your_openai_api_key_here' export SUPABASE_KEY='your_supabase_key_here' python ArticleApp.py
-
FootballAPI setup Setup for the
FootballAPIand its sub-directoryaddFixtures.cd FootballAPI cd addFixtures pip install -r requirements.txt virtualenv venv source venv/bin/activate export RAPID_API_KEY='your_rapid_api_key_here' export SUPABASE_KEY='your_supabase_key_here' python addFixtures.py
-
WeatherAPI setup Configure the
WeatherAPIservice by following these steps.cd WeatherAPI pip install -r requirements.txt virtualenv venv source venv/bin/activate export SUPABASE_KEY='your_supabase_key_here' python forecastWeather.py
-
Website setup Set up the front-end website component.
cd website npm install # Setup an .env file with your Supabase credentials echo "VITE_SUPABASE_URL='your_supabase_url_here'" > .env echo "VITE_SUPABASE_KEY='your_supabase_key_here'" >> .env npm run dev
Please replace your_openai_api_key_here, your_supabase_key_here, and other placeholder keys with your actual API keys and credentials.
The project has been developed using the following languages and frameworks:
- Language: Python, Java and Javascript
- Framework: Flask, NodeJS
- AI Tool: OpenAI GPT 3.5
- Database: Supabase
The project is currently being developed by:
- Shivanshu Dwivedi
- Anupam Khargaria
- Shashwath Sunkum
This project is mentored by Professor Jonathan Johnson, Trinity College.







