Skip to content

Latest commit

 

History

History
114 lines (86 loc) · 3.42 KB

File metadata and controls

114 lines (86 loc) · 3.42 KB

F1 CLI Toolkit 🏎️

A suite of high-performance Command Line Interface (CLI) tools written in C for Formula 1 data analysis.

🌟 Motivation & Learning Journey

This toolkit was created as a personal challenge to push my limits in C and explore the "black box" of web-based data interaction. While modern frameworks abstract away the complexity of networking, I wanted to understand the foundational layers:

  • Low-level Networking: Interacting with the OpenF1 API using libcurl to handle HTTP protocols manually.
  • Manual Memory Management: Orchestrating dynamic memory allocation (malloc/realloc) and ensuring zero memory leaks during complex JSON parsing.
  • Data Architecture: Implementing and traversing JSON structures using cJSON to bridge the gap between web data and C structs
  • Backend Insights: Gaining a first-hand look at how data flows from a server to a low-level client.

🛠️ Included Tools

1. F1 Driver Lookup (f1_lookup)

A quick tool to retrieve detailed information about any driver by their racing number.

  • Features: Fetches full name, team, and country code.
  • Usage: Input a driver number (e.g., 44 for Lewis Hamilton) to get an instant profile.

2. Driver Performance Analyzer (f1_analyzer)

Analyzes a driver's performance across an entire season using ASCII visualization.

  • Features: Fetches all race results for a specific year and driver number.
  • Visualization: Generates an ASCII bar chart representing finishing positions (longer bars = better results).

3. Grand Prix Explorer (f1_explorer)

A comprehensive tool to explore historical race results.

  • Features: Lists all GPs in a season, allows the user to select one, and displays the full race classification.
  • Logic: Performs complex nested API calls to match driver keys with finishing positions.

🚀 Getting Started

Prerequisites

You will need a C compiler (GCC/Clang) and the following libraries installed:

  • libcurl: For HTTP requests.
  • cJSON: Included in the repository.

Installing libcurl (Ubuntu/Debian)

sudo apt-get install libcurl4-openssl-dev

Installing libcurl (Windows - MSYS2)

pacman -S mingw-w64-x86_64-curl

🔨 Building the Tools

We use a Makefile to simplify the compilation process. Run the following command in the root directory:

make

To build a specific tool:

make f1_lookup
make f1_analyzer
make f1_explorer

To clean up binary files:

make clean

📊 Sample Outputs

1. Driver Lookup

Enter driver number: 44

Driver Info
-------------------------
Number : 44
Name   : Lewis HAMILTON
Team   : Mercedes
Country: GBR

2. Driver Performance Analyzer

Driver Analyzer - Final Race Results
------------------------------------
United Kingdom  | P1  | ####################
Hungary         | P3  | ##################
Belgium         | P1  | ####################

3. Grand Prix Explorer

Race Sessions for 2024
---------------------------------
1 - Bahrain (2024-02-29T11:30:00)
2 - Saudi Arabia (2024-03-07T13:30:00)
...
Select a GP by number: 1

Bahrain GP Results
--------------------------------------------------


P1  - Max VERSTAPPEN (#1)
P2  - Sergio PEREZ (#11)
P3  - Carlos SAINZ (#55)

Author: Tolga Demir Last Updated: March 2026

⭐ Give it a star if you appreciate the beauty of low-level systems programming!