This is a submission for the Hacktoberfest Weekend Challenge: Build for a Friend
What I Built
I built KTCL CommuteShield for my engineering classmate and close friend, Tejas.
Every weekday morning, Tejas commutes across Goa from Margao to our engineering campus at Farmagudi. Like thousands of students in the state, he relies on a Kadamba Transport Corporation (KTCL) RFID smart card to tap through depot turnstiles and board the student shuttle.
The Hidden Trap: Offline Depot Batch Synchronization
KTCL smart card infrastructure relies on an offline batch synchronization architecture. The handheld ticket machines and depot turnstiles do not maintain a persistent real-time internet connection to bank servers. Instead, balances are reconciled across bus depot gates on a nightly schedule.
The central server closes its batch queue promptly at 11:59 PM IST.
If a commuter recharges their card online at 12:05 AM, the money leaves their bank account, but the balance fails to sync to the depot turnstile until the following evening's batch. When Tejas taps his card at 7:30 AM the next morning, the turnstile buzzer sounds, the gate stays locked, and his transit pass is declined.
The Real-World Problem: The Wadi Turf Football Dilemma
Tejas loves sports and frequently plays evening football matches at Wadi turf near Ponda after late laboratory sessions.
These extracurricular detours add unpredictable extra transit legs:
- Morning: Margao Depot โ Farmagudi Campus
- Afternoon: Farmagudi Campus โ Wadi Turf
- Evening: Wadi Turf โ Margao Depot
An unplanned evening match burns through his card balance without him realizing it. With only โน18 left on Friday night, he goes to sleep assuming he can tap through. Next morning at 7:30 AM, he gets stranded at the Margao terminal, watching the college bus pull away without him right before critical morning examinations.
Why Naive Alerts Fail
A simple threshold rule (like "alert whenever balance is under โน50") quickly gets ignored. On a light Tuesday with only one lecture, โน20 is completely safe. Spamming Tejas with daily warnings induces notification fatigue, causing him to silence alertsโleading to disaster when an actual emergency occurs.
What KTCL CommuteShield Does
KTCL CommuteShield runs locally on Tejas's laptop every evening at 8:00 PM IST (nearly 4 hours ahead of the depot sync deadline).
The agent strictly divides responsibilities:
- Live Portal Scraping: Queries the official KTCL portal to extract the verified current card balance.
- Context Calendar Ingestion: Inspects tomorrow's scheduled lectures, lab exams, and evening sports activities.
- Real-Time Highway Grounding via SerpApi: Searches live Google Search transit feeds for Goa highway floodings, NH66 bridge construction, and Kadamba route advisories.
- Bayesian Tabular Inference via Prior Labs TabPFN: Passes a calibrated 7-dimensional feature vector into TabPFN to compute an exact stranded risk probability (P_stranded) and projected shortfall.
- Proactive Telegram Alert: If genuine risk exists (Stranded Risk โฅ 60%), it sends an actionable alert to Tejas's phone before midnight with the exact minimum recharge amount needed. On safe days, it maintains complete silence.
Demonstration Privacy Note: To demonstrate live portal balance scraping on screen safely without exposing Tejas's private card credentials, our live demos query my own registered physical KTCL transit card (
ST25****1313, registered to Kanak S Waradkar). Tejas's actual timetable, football schedule, and Telegram handle drive the risk engine.
What Tejas Said
I handed KTCL CommuteShield to Tejas to safeguard his daily transit. Here is his feedback:
"The 11:59 PM depot cutoff stranded me twice last semester during monsoon examinations. CommuteShield pinged my Telegram at 8:15 PM on Friday warning me about the Wadi turf detour and gave me the exact recharge figure. That alert saved me from standing stranded at Margao depot at 7:30 AM."
Demo
Watch the complete technical walkthrough and multi-scenario demonstration on YouTube:
Multi-Scenario Demonstration
CommuteShield runs both headlessly in the background and interactively through an automated terminal CLI.
1. Live Safe Assessment (Anti-Fatigue Smart Silence)
When Tejas's card balance covers his upcoming transit, TabPFN determines that the commute is safe (Stranded Risk: 8.1%). The agent suppresses all mobile notifications, eliminating notification fatigue:
python cli.py run
โญโโโโโโโโโโโโโโโโ ๐ก๏ธ KTCL CommuteShield - Commute Clear & Safe โโโโโโโโโโโโโโโโโฎ
โ Commuter Friend Tejas โ
โ Card Balance โน321.50 (Live Portal) โ
โ Stranded Probability SAFE: 8.1% โ
โ Projected Shortfall โน0.00 โ
โ Recommended Top-Up โน0 (Sufficient) โ
โ Goa Transit Intel NORMAL (SerpApi Live Google Search) โ
โ Inference Model Prior Labs TabPFN (In-Context Bayesian Inference) โ
โ Depot Sync Cutoff 11:59 PM IST Tonight โ
โฐโโโโโโโโโโ Powered by Prior Labs TabPFN & SerpApi Transit Grounding โโโโโโโโโโโฏ
โ Anti-Fatigue Filter Active: Zero Telegram alert spam (Risk 8.1% < 60% threshold)
2. Friday Football Trap: Emergency Alert Trigger
When Tejas has only โน18.00 remaining and a scheduled football match at Wadi turf, TabPFN recognizes the multi-leg detour risk:
python cli.py run --balance 18.0 --turf 1
โญโโโโโโโโโโโโโ ๐จ KTCL CommuteShield - Proactive Emergency Alert โโโโโโโโโโโโโโโฎ
โ Commuter Friend Tejas โ
โ Card Balance โน18.00 (Cached Record) โ
โ Stranded Probability CRITICAL RISK: 82.7% โ
โ Projected Shortfall โน64.50 โ
โ Recommended Top-Up โน100 โ
โ Goa Transit Intel NORMAL (SerpApi Live Google Search) โ
โ Inference Model Prior Labs TabPFN (In-Context Bayesian Inference) โ
โ Risk Factors unplanned football match at Wadi turf (+โน30 fare) โ
โ Depot Sync Cutoff 11:59 PM IST Tonight โ
โฐโโโโโโโโโโ Powered by Prior Labs TabPFN & SerpApi Transit Grounding โโโโโโโโโโโฏ
โ Live Telegram Alert Dispatched -> @ktcl_commuteshield_bot
Instantly, Tejas receives an actionable mobile notification on Telegram from @ktcl_commuteshield_bot with the exact steps to take before the midnight cutoff:
3. Real-Time Transit Disruption Grounding via SerpApi
When seasonal monsoon flooding or bridge work impacts NH66, CommuteShield queries SerpApi for live road conditions:
python cli.py transit
SerpApi parses organic search results, identifies active detour advisories, and dynamically elevates the fare multiplier from 1.0x to 1.35x.
4. Automated Multi-Scenario Simulation
To contrast TabPFN against primitive threshold logic across realistic edge cases, run:
python cli.py simulate
- Scenario 1 (Friday Football Trap): โน18 balance + Wadi turf โ CRITICAL RISK (82.7%) โ Emergency alert sent.
- Scenario 2 (Tuesday Safe Lecture): โน25 balance + 1 lecture โ SAFE (23.5%) โ Telegram spam suppressed.
- Scenario 3 (Monsoon Highway Detour): โน45 balance + NH66 flood diversion โ Shortfall detected โ Top-up prompt dispatched.
Code
The complete source code is open source and hosted on GitHub:
๐ก๏ธ KTCL CommuteShield โ Open-Source AI Bus Card Exhaustion & Stranded Risk Forecaster
An autonomous, privacy-preserving transit safety agent pairing Prior Labs TabPFN Bayesian tabular foundation models with SerpApi real-time Google Search transit intelligence to prevent college students from getting stranded at bus turnstiles.
๐บ Video Demo โข ๐ Quickstart โข ๐ Architecture โข ๐ TabPFN Foundation Model โข ๐ SerpApi Grounding โข ๐งช Testing
๐ The Human Story & Problem
Built for a Friend: Tejas
Tejas is an engineering classmate in Goa who commutes daily between Margao and our engineering campus at Farmagudi. Like thousands of students across Goa, he relies on a Kadamba Transport Corporation Ltd (KTCL) RFID smart card to tap through depot turnstiles and board the college transit bus.
The Hidden Trap: Offline Depot Batch Synchronization (11:59 PM IST Cutoff)
- Offline Handheld Terminals: KTCL buses and depot turnstiles use offline electronic ticketing machines (ETMs)โฆ
๐ Repository Link: https://github.com/Labreo/KTCL-CommuteShield
Architecture Overview
ktcl-commuteshield/
โโโ cli.py # Rich terminal CLI with interactive evaluation
โโโ commuteshield/
โ โโโ tabpfn_model.py # Prior Labs TabPFN Bayesian tabular inference engine
โ โโโ serpapi_tool.py # SerpApi real-time Google Search transit grounding
โ โโโ scraper.py # Authenticated, masked KTCL portal balance scraper
โ โโโ agent.py # CommuteShield orchestrator & decision logic
โ โโโ notifier.py # Telegram, Twilio WhatsApp, & desktop dispatchers
โ โโโ config.py # Configuration & privacy-preserving masking
โ โโโ data/
โ โโโ friend_commute_history.csv # Tejas's 60-day transit calibration logs
โโโ tests/ # Comprehensive 14-test pytest validation suite
โโโ pyproject.toml # Python 3.12 project metadata
โโโ requirements.txt # Minimal dependencies: tabpfn, serpapi, rich, requests
How I Built It
CommuteShield links three open modules into an automated evening agent built directly around open-source AI:
1. Open-Weight Foundation Model (Prior Labs TabPFN)
Personal commuter histories present a classic machine learning bottleneck: small tabular sample sizes. A student's commute history typically consists of 40 to 80 rows of transit logs. Traditional gradient-boosted trees (XGBoost, LightGBM) and deep neural networks severely overfit on datasets this small, requiring extensive cross-validation and hyperparameter tuning.
Prior Labs TabPFN solves this fundamentally.
TabPFN is a foundation model pre-trained on synthetic tabular datasets to perform in-context Bayesian inference in a single forward pass. It acts as a prior over structural tabular functions, requiring zero gradient descent steps, zero training epochs, and zero hyperparameter tuning.
Running locally on consumer hardware, TabPFN evaluates a 7-dimensional feature vector:
-
day_of_week: Day index (MondayโSaturday patterns) -
current_balance: Live scraped or recorded card balance in INR -
scheduled_trips: Daily class count (lectures + laboratory sessions) -
turf_match: Boolean indicator for evening Wadi turf football -
days_since_recharge: Elapsed days since last monetary top-up -
disruption_multiplier: Real-time highway disruption factor from SerpApi (1.0xโ1.35x) -
daily_burn: Exponential moving average of daily transit expenditure
TabPFN ingests Tejas's historical 60-row commute ledger alongside today's conditions to yield a mathematically calibrated stranded probability (P_stranded) and projected shortfall.
2. Live Transit Intelligence Grounding via SerpApi
Goa bus corridors regularly encounter seasonal monsoon flooding, Zuari bridge congestion, and NH66 road work. If buses are diverted through longer bypass routes, fare tiers increase.
CommuteShield uses SerpApi to query Google Search for real-time transit bulletins across Kadamba routes and Goa traffic advisories. The tool evaluates search snippets for diversion keywords (flood, waterlogging, diversion, NH66, delay). When disruptions are detected, the agent raises the fare multiplier from 1.0x to 1.35x, feeding the elevated cost directly into TabPFN's Bayesian inference vector.
3. Edge Agent Harness & Automated Dispatch
CommuteShield is orchestrated by a lightweight Python agent harness designed to run headlessly as an evening cron job.
If TabPFN detects critical risk (Stranded Risk โฅ 60% or an expected cash shortfall), the agent formats an emergency alert and dispatches it through the Telegram Bot API (@ktcl_commuteshield_bot) and Twilio WhatsApp. The alert provides the exact top-up recommendation (e.g. โน100) and explicitly warns about the 11:59 PM IST depot synchronization cutoff.
Why Does Open Innovation Matter?
Open-weight AI makes CommuteShield trustworthy, reliable, and accessible for student commuters:
- Student Location Sovereignty & Privacy: Daily commute logs document deeply personal lifestyle habitsโhome departures, campus timetables, evening sports locations, and transit timestamps. Pushing student travel tables to closed commercial LLM APIs exposes personal telemetry to remote servers. Open-weight TabPFN runs 100% locally on Tejas's laptop, ensuring sensitive movement patterns never leave the machine.
- Deterministic Arithmetic Grounding vs. Generative Hallucinations: Generative large language models frequently hallucinate currency calculations and risk bounds. TabPFN delivers calibrated mathematical probabilities across structured tabular features, preventing false alarms and missed recharges.
- Zero Marginal Operating Cost: The entire inference stack runs on standard consumer CPU hardware in under 200 milliseconds. Students can run CommuteShield every day indefinitely without paying recurring cloud token fees.
-
Resilient Offline Edge Execution: During monsoon weather when local Wi-Fi drops, CommuteShield evaluates risk offline using local model weights (
tabpfn-v3.5-20260909.safetensors), local transit history, and timetable files.
My Agent Session
Prize Categories
1. Best Use of TabPFN (Featured Category โ $200 USD)
KTCL CommuteShield is built directly around Prior Labs TabPFN, the tabular foundation model. TabPFN performs in-context Bayesian inference on Tejas's 60-day commute history in a single forward pass, evaluating 7 calibrated transit features to predict stranded probabilities and cash shortfalls without overfitting on small personal tabular datasets.
2. Best Use of SerpApi (Partner Category โ $100 USD)
SerpApi grounds our agent with real-time Goa road advisories, weather notices, and Kadamba transit updates via live Google Search, allowing CommuteShield to dynamically adjust fare expectations when NH66 highway floodings or bridge diversions occur.
3. Best Use of ElevenLabs (Partner Category โ $100 USD)
ElevenLabs powers the clear, pacing-optimized voice narration for our multi-scenario video walkthrough (https://youtu.be/XJ_Dj1pCouI), translating complex technical conceptsโsuch as offline depot batch synchronization and tabular Bayesian inferenceโinto an engaging presentation.







Top comments (0)