Serverless Formula 1 analytics dashboard on AWS S3 + API Gateway + Lambda (frontend-only hosting, backend via HTTP) Published as part of the Cloud Computing Module at Advanced Diploma in Data Science offered by National Innovation Centre - NIBM in collaboration with Coventry University
F1 DataLens is a lightweight analytics UI that calls the API-SPORTS Formula-1 endpoints through an AWS Lambda function exposed by API Gateway, and renders standings, race info, driver comparisons, and circuit profiles. The site is hosted as a static website on S3.
⚠️ Note: This dashboard is currently optimized for desktop browsers and is not mobile-friendly.
- Live Demo
- Features
- Architecture
- Project Structure
- Prerequisites
- Quickstart (Local)
- Deploy to AWS
- Configuration
- Security
- Cost & Limits
- Monitoring
- Troubleshooting
- Roadmap
- License
- Overview: season KPIs (races, drivers, teams, points sum), latest & next race cards.
- Season Analysis: race calendar table, Podium Comparison by Drivers & Point comaprision by Constructors
- Driver Comparison: pick up to 2 drivers and compare key stats with clean progress bars.
- Circuit Profiler: browse circuits used in the selected season and their statistics.
- Resilient UI: guards against missing fields, graceful loading/error states.
- Dark/Light theme toggle with persistence.
Browser (S3 static site: HTML/CSS/JS)
└── fetch() ───────────────► API Gateway (HTTP/REST)
└── Lambda (Python)
└── Calls API-SPORTS F1 endpoints
(via RapidAPI key)
- Frontend: single-page app (
frontend/index.html) served from S3 static website hosting. - Backend:
backend/lambda_function.py(Python) behind API Gateway. The Lambda injects API key headers and aggregates data when necessary. - CloudFront: For HTTPS and caching.
/frontend
└── index.html # single-page app (Bootstrap + Chart.js + vanilla JS)
/backend
└── lambda_function.py # Python Lambda handler (proxy to API-SPORTS F1)
README.md
- AWS account with S3, Lambda, API Gateway permissions
- RapidAPI (API-SPORTS Formula-1) — plan used here: $15/month, 7,500 requests/day
- Python 3.10+ (for local packaging of Lambda if needed)
- A modern browser
You can open the frontend directly in a browser for layout testing. API calls will only work if CORS allows your origin (or if you point the page to a Lambda Function URL during testing).
- Clone repo
git clone https://github.com/<you>/f1-datalens.git
cd f1-datalens- Open the UI
# Option A: open the static file
open frontend/index.html # macOS (or double click)
# Option B: run a tiny HTTP server (recommended)
cd frontend
python -m http.server 5173
# visit http://localhost:5173- Configure API base in
index.html(see Configuration below).
- Create bucket, enable Static website hosting.
- Upload
frontend/index.html. - Set Index document =
index.html(and optional Error document =index.html). - Bucket policy for public read (or put CloudFront in front).
- Create function (Python 3.10/3.12), set handler to
lambda_function.lambda_handler. - Upload zipped
backend/lambda_function.py. - Env vars (example):
RAPIDAPI_HOST = v1.formula-1.api-sports.ioRAPIDAPI_KEY = <your-rapidapi-key>
- Timeout: 10–15s, Memory: 256 MB.
- Create HTTP API (or REST API) and integrate with Lambda.
- Route:
GET /top-tracks(and other routes you expose). - CORS: allow your S3 website origin (or
*while testing). - Deploy and note the invoke URL.
- In
frontend/index.html, point to your API GW / Lambda Function URL (see Configuration). - Test from the S3 website endpoint.
In frontend/index.html, set the API config near the top of the script:
// API Configuration
const API_BASE_URL = 'https://v1.formula-1.api-sports.io'; // or your API Gateway/Lambda URL
const API_KEY = 'YOUR_RAPIDAPI_KEY'; // if you call RapidAPI directly (NOT recommended in browser)Recommended: keep API keys only in Lambda. In that case, change the API_BASE_URL to your API Gateway or Lambda Function URL, and remove the key from the browser code. Add CORS on the backend and return JSON to the frontend.
- Do not expose API keys in the browser. Prefer the Lambda proxy pattern.
- Least-privilege IAM for Lambda execution role.
- If you add a VPC later for other data sources, ensure NAT for outbound Internet.
- Frontend hosting on S3 is pennies per month.
- Backend: Lambda + API Gateway charges are modest for student-scale traffic.
- RapidAPI plan used: $15/month with 7,500 requests/day (sufficient for classroom use).
- Optimizations:
- Cache responses in the browser (localStorage) or add a small in-memory cache in Lambda.
- Avoid fetching on every tab switch; reuse previously loaded data (the code already memoizes some calls).
- Limit driver comparison to 2 drivers (already enforced) to avoid unnecessary calls.
- CloudWatch Logs for Lambda (errors, invocations, duration).
- API Gateway metrics (4XX/5XX, latency).
- S3 access logs (optional).
- CORS errors in browser but
curlworks → enable CORS in API Gateway or return headers from Lambda:Access-Control-Allow-Origin: https://<your-s3-site>Access-Control-Allow-Methods: GET,OPTIONS
- Lambda timeout → increase to 10–15s and confirm it has outbound Internet (no VPC or NAT present).
- S3 403/404 → check bucket policy and Index document =
index.html. - Images/logos missing → this version intentionally uses text-first standings to avoid logo lookups.
MIT © 2025 Navodhya Fernando | Sandrea Raj | Hashini Handapangoda