The FIA F1 Docs Bot is an automated tool designed to fetch the latest Formula 1 decision documents from the FIA website and post them on a Threads account with AI summarization.
IMPORTANT NOTICE: This project is not affiliated with, endorsed by, or in any way officially connected to the Fédération Internationale de l'Automobile (FIA), Formula 1, Formula One Management (FOM), or any of their subsidiaries or affiliates. This is an independent, unofficial project created for informational purposes only. All product and company names are the registered trademarks of their original owners. The use of any trade name or trademark is for identification and reference purposes only and does not imply any association with the trademark holder of their product brand.
This bot aims to make FIA F1 decision documents more accessible by automatically posting them to a Threads account with AI summarization. It's designed for F1 fans and professionals who want quick access to official FIA communications.
- Automated Scraping: Periodically scrapes the FIA website for the latest decision documents under the active Grand Prix.
- Automated Posting: Posts documents to Threads as image posts or carousels (up to 20 pages).
- AI Summarization: Uses Google Gemini (via Vertex AI) with model fallback to generate concise summaries.
- URL Shortening: Shortens document URLs to fit within Threads character limits.
- Recalled Document Detection: Detects recalled documents and posts text-only notices.
- Concurrent Processing: Worker pool processes up to 5 documents concurrently.
- Health Check: HTTP endpoint on port 6060 for monitoring.
- Automatic Token Refresh: Background goroutine refreshes Threads access token every 24 hours.
- Graceful Shutdown: Handles SIGINT/SIGTERM with proper cleanup.
- Docker Support: Multi-stage Docker build for easy deployment.
- Scraping: The bot scrapes the FIA website at a configurable interval (default 30s) for new decision documents under the currently active Grand Prix.
- Duplicate Check: New documents are checked against PostgreSQL to skip already-processed ones.
- Recall Check: Documents with "Recalled" in the title get a text-only notice posted instead.
- PDF Download & Verification: PDFs are downloaded and verified (valid PDF signature, >1KB file size).
- AI Summary: The PDF is sent to Google Gemini via Vertex AI for a 40-60 word summary. If summarization fails, posting continues without a summary.
- Image Conversion: PDF pages are converted to images using MuPDF (via go-fitz).
- Image Upload: Images are uploaded to a Picsur instance to get public URLs.
- URL Shortening: Document URLs are shortened to fit within character limits.
- Posting: The bot posts to Threads — single image post for 1-page documents, carousel for multi-page (up to 20).
- Cleanup: Temporary files are deleted and garbage collection is forced after processing.
- Docker and Docker Compose (for containerized deployment)
- Go 1.25+ (for local development)
- MuPDF system libraries (for PDF-to-image conversion)
- Threads API access (see Limitations section)
- Google Gemini API key (via Vertex AI)
- Picsur instance for image hosting (self-hosted or third-party)
- URL shortener service for document links
- PostgreSQL database
This bot uses the Threads Go client library to interact with the Threads API, providing a clean and efficient way to post content to Threads without handling raw HTTP requests.
- Pull the Docker image from Docker Hub:
docker pull ptirth/fia-f1-docs-bot:latest
-
Pull the Docker image from GitHub Container Registry:
docker pull ghcr.io/tirthpatell/fia-f1-docs-bot:latest
-
Create a
.envfile with the following variables:FIA_URL=https://www.fia.com/documents/championships/fia-formula-one-world-championship-14/season/season-2026-2072 SCRAPE_INTERVAL=300 # Threads API Configuration (required for Threads Go client) THREADS_USER_ID=your_threads_user_id_here THREADS_ACCESS_TOKEN=your_threads_access_token_here THREADS_CLIENT_ID=your_threads_client_id_here THREADS_CLIENT_SECRET=your_threads_client_secret_here THREADS_REDIRECT_URI=your_threads_redirect_uri_here # AI and External Services GEMINI_API_KEY=your_google_gemini_api_key_here PICSUR_API=your_picsur_api_key_here PICSUR_URL=https://picsur.example.com SHORTENER_API_KEY=your_shortener_api_key_here SHORTENER_URL=https://shortener.example.com # PostgreSQL Configuration DB_HOST=localhost DB_PORT=5432 DB_USER=postgres DB_PASSWORD=your_secure_password DB_NAME=fiadocs DB_SSL_MODE=disable -
Run the container:
docker run -d \ --name fia-f1-docs-bot \ --env-file .env \ -p 6060:6060 \ ptirth/fia-f1-docs-bot:latest
Or using Docker Compose:
services: bot: image: ptirth/fia-f1-docs-bot:latest # or ghcr.io/tirthpatell/fia-f1-docs-bot:latest env_file: - .env restart: unless-stopped ports: - "6060:6060" # Health check endpoint
The bot uses PostgreSQL to store information about processed documents, ensuring persistence across container restarts and deployments. Tables are automatically created and migrated on startup.
Docker images are automatically built and published to both Docker Hub and GitHub Container Registry on:
- Pushes to
main - Tag pushes (e.g.,
v1.0.0)
Required GitHub Secrets:
DOCKER_USERNAME: Your Docker Hub usernameDOCKER_TOKEN: Your Docker Hub access tokenGITHUB_TOKEN: Automatically provided for GHCR authentication
Pull requests are automatically reviewed by Claude Code for code quality, correctness, and security issues. This runs on PR creation and subsequent pushes.
Required GitHub Secret:
ANTHROPIC_API_KEY: Your Anthropic API key
For manual builds outside of CI, use the script in scripts/:
./scripts/build-and-publish.shThis requires a scripts/.env file with DOCKER_USER and DOCKER_REPO set (see scripts/.env.example).
-
Clone the repository:
git clone https://github.com/tirthpatell/fia-f1-docs-bot.git cd fia-f1-docs-bot/bot -
Install dependencies:
go mod download
-
Configure the bot:
- Create a
.envfile in thebot/directory with the necessary environment variables (see Docker setup for required variables).
- Create a
-
Build the project:
go build -o bot ./cmd/svc/main.go
-
Run the bot:
./bot
The bot is configured using environment variables, loaded from a .env file via Viper.
| Variable | Required | Default | Description |
|---|---|---|---|
FIA_URL |
No | 2025 season URL | FIA documents page URL |
SCRAPE_INTERVAL |
No | 30 |
Scraping interval in seconds |
DOCUMENTS_TO_FETCH |
No | 15 |
Number of recent documents to check each cycle |
THREADS_ACCESS_TOKEN |
Yes | Threads API access token | |
THREADS_USER_ID |
Yes | Threads user ID | |
THREADS_CLIENT_ID |
Yes | Threads OAuth client ID | |
THREADS_CLIENT_SECRET |
Yes | Threads OAuth client secret | |
THREADS_REDIRECT_URI |
Yes | Threads OAuth redirect URI | |
GEMINI_API_KEY |
Yes | Google Gemini API key | |
GEMINI_MODELS |
No | gemini-3.1-flash-lite:thinking,gemini-2.5-flash-lite |
Comma-separated Gemini models in fallback order; append :thinking to enable thinking for a model |
PICSUR_API |
Yes | Picsur API key | |
PICSUR_URL |
Yes | Picsur instance URL | |
PICSUR_UPLOAD_URL |
No | PICSUR_URL |
Address the bot uploads to (e.g. a LAN address when Picsur runs on the same host); image links still use PICSUR_URL |
SHORTENER_API_KEY |
Yes | URL shortener API key | |
SHORTENER_URL |
Yes | URL shortener base URL | |
DB_HOST |
Yes | PostgreSQL host | |
DB_PORT |
No | 5432 |
PostgreSQL port |
DB_USER |
Yes | PostgreSQL user | |
DB_PASSWORD |
Yes | PostgreSQL password | |
DB_NAME |
Yes | PostgreSQL database name | |
DB_SSL_MODE |
No | disable |
PostgreSQL SSL mode |
LOG_LEVEL |
No | info |
Log level (debug, info, warn, error) |
LOG_ADD_SOURCE |
No | false |
Include source location in logs |
ENVIRONMENT |
No | production |
Environment name |
VERSION |
No | unknown |
Application version |
Contributions are welcome! Here's how you can contribute to the project:
- Fork the repository
- Create a new branch:
git checkout -b feature-branch-name - Make your changes and commit them:
git commit -m 'Add some feature' - Push to the branch:
git push origin feature-branch-name - Submit a pull request
This project uses several key dependencies:
- Threads Go Client: Go client library for interacting with the Threads API
- Colly: Web scraping framework for Go
- Google GenAI: Go client for Google Gemini via Vertex AI
- go-fitz: MuPDF wrapper for PDF-to-image conversion
- Viper: Configuration management
- lib/pq: PostgreSQL driver for Go
If you discover any security-related issues, please email [fiaf1docs-gh@threadsutil.cc] instead of using the issue tracker. All security vulnerabilities will be promptly addressed.
- This bot relies on the Threads API, which may have rate limits or require special access. Ensure you have the necessary permissions before deploying.
- The bot's functionality is dependent on the structure of the FIA website. Changes to their website may require updates to the scraping logic.
- PDF-to-image conversion requires MuPDF system libraries (
libmupdf-devfor building,mupdfandmupdf-toolsat runtime).
This project is licensed under the MIT License. See the LICENSE file for details.