Amfor-Cast is a self-learning weather intelligence platform that gets smarter with every user interaction. It compares 8 forecast models, learns which one to trust for each location, and provides route-aware weather planning with adaptive model selection.
# On the Pi via SSH:
$ ./release.py status
Output dir: /opt/amfor-cast/output
22 HTML files, last updated: 2026-08-11 13:05:00
Backup: /opt/amfor-cast/backup
22 HTML files, snapshot: 2026-08-11 07:05:00
Prod: amfor-cast:/home/amforcas/public_html/
Nonprod: amfor-cast:/home/amforcas/nonprod.amfor-cast.com/
$ ./release.py deploy-test
ββ git pull β
ββ generating reports...
(run-and-publish.py output)
ββ rsync β nonprod.amfor-cast.com β
β Deployed to nonprod! Verify at: https://nonprod.amfor-cast.com
$ ./release.py promote
Source: /opt/amfor-cast/output (22 HTML files)
Target: amfor-cast:/home/amforcas/public_html/
? Promote this content to PRODUCTION? [y/N] y
ββ backing up current production β (20260811_130500)
ββ rsync β amfor-cast.com β
β Production updated! Live at: https://amfor-cast.com
$ ./release.py rollback
Available backups:
1. 20260811_130500 (22 files) β latest
2. 20260811_070100 (22 files)
? Rollback PRODUCTION to this backup? [y/N] y
ββ restoring backup β output dir β
ββ rsync β amfor-cast.com β
β Production rolled back to 20260811_070100!
Database: amforcas_forecasts on tarhely.com MariaDB. Credentials in config.ini (not in git).
JSON dual-write active until 2026-08-18, then JSON removed.
-- Core tables (implemented) stations -- fixed + route-discovered locations forecasts -- daily model snapshot headers (date, city, model) forecast_hours -- hourly data points per forecast (~384 per model) evaluations -- forecast vs actual MAE scores rankings -- computed model rankings per city/param/horizon -- Route feedback (implemented) route_logs -- route requests with all-model forecasts -- Future tables headache_events -- replaces headaches.txt (date, severity, city, notes) users -- user accounts (v1.2) user_cities -- saved favorite cities per user user_routes -- saved routes per user
Get the new architecture running with all existing features.
| Feature | Details |
|---|---|
| β Done β Pi runs hourly, syncs to tarhely.com | |
β
Done β config.ini + shared/config_loader.py | |
β
Done β MySQL on tarhely.com, shared/db.py, scripts wired | |
| β Done β Pi β tarhely.com via SSH key | |
| β All working on new infra | |
| β Done β All pages use shared base styles, CSS vars, centered logo, consistent header | |
β
Done β nonprod.amfor-cast.com + amfor-cast.com, --nonprod flag in run-and-publish.py | |
β
Done β release.py: deploy-test, promote, rollback, status | |
| β Done β Flask + Flask-Limiter, 10 req/min on /api/log-route, systemd service | |
| β Dropped β using Tailscale for admin + PHP proxy on tarhely.com for public API |
Make the route planner production-grade.
| Feature | Details |
|---|---|
| Multi-route comparison | Compare 2-3 alternative routes side by side (see section 7) |
| Optimal departure time | Try multiple departure times, find driest/calmest window |
| Road condition warnings | Ice risk (dew point near temp + temp < 3Β°C), fog risk, visibility |
| Weather alerts on route | Rain zones highlighted, strong wind segments, storm warnings |
| Mobile-first responsive | Route planner optimized for phone screens |
| Self-learning from routes | Feedback loop fully operational (Pi API receives + evaluates) |
Personalization and saved preferences.
| Feature | Details |
|---|---|
| User registration/login | Simple email+password (see section 6 for auth approach) |
| Saved favorite cities | User picks cities β personal dashboard shows their forecasts |
| Saved routes | "My commute" β one-click re-run with current departure time |
| Personal headache log | Log events via UI instead of editing a text file |
| Personal risk alerts | Dashboard highlights when saved cities have high risk |
| Feature | Details |
|---|---|
| Push notifications | Email or browser push when high risk detected on saved cities/routes |
| Historical route replay | "What was the weather last time I drove this?" |
| Seasonal model adaptation | Rankings adjust by month β winter models vs summer models |
| AMFOR forecast model | Own ML-based forecast that blends NWP models β see section 14 |
| Feature | Details |
|---|---|
| PWA / offline mode | Cache last forecast for offline viewing |
| Native mobile app (Android + iOS) | See section 13 β dedicated mobile app plan |
| Widget / embed | Embeddable forecast widget for other sites |
| Multi-language expansion | Beyond EN/HU β DE, SK, RO for neighbors |
Decision needed: Roll your own auth or use a service?
| Approach | Pros | Cons |
|---|---|---|
| Flask + bcrypt (DIY) | Full control, no external dependency, free, works offline, educational | Security risk if done wrong (CSRF, session fixation, password storage). You maintain it forever. |
| Auth0 (free tier) | Battle-tested security, social login (Google), MFA, 7,000 users free | External dependency, vendor lock-in, requires internet, JS SDK adds weight |
| Supabase Auth (free tier) | Postgres-backed, self-hostable if needed, good JS client, 50k MAU free | Another service to depend on, overkill for simple login |
| HTTP Basic Auth + Pi | Dead simple, built into every browser, no JS needed | Ugly UX, can't "log out" easily, no registration flow |
My recommendation: Flask + bcrypt for MVP.
flask-login + flask-bcrypt β well-tested patterns, not raw cryptoDecision needed: Where does the computation happen?
| Approach | Pros | Cons |
|---|---|---|
| Client-side (JS) | No server load, works without API, instant for user, simpler backend | Slower on mobile (8 models Γ 2 routes Γ 10 waypoints = 160 API calls), may hit Open-Meteo rate limits, burns user's data |
| Server-side (Pi) | Fast (Pi has good internet), can cache/batch API calls, rate limit controlled, saves user bandwidth | Pi must be reachable, adds API endpoint complexity, latency depends on tunnel speed |
| Hybrid | Client fetches routes (OSRM), Pi fetches weather in batch. Best of both. | Most complex to implement, two-step flow |
My recommendation: Hybrid approach.
POST /api/route-weather with coords + departure timeWhy hybrid wins: 2 routes Γ 8 models Γ 10 waypoints = 160 Open-Meteo calls. Client-side this takes 30+ seconds on mobile. Pi does it in 5 seconds with batch requests. Also: Pi can cache repeated coords (same highway segment requested by multiple users = one API call).
| Data type | Retention | Reason |
|---|---|---|
| Forecast snapshots (raw) | 90 days | Only needed for scoring. After 90d, only aggregated scores matter. |
| Scores (per evaluation) | 1 year | Seasonal patterns need a full year to emerge. |
| Model rankings (aggregated) | Forever (tiny) | ~1KB per recalculation, historical rankings show trends. |
| Route logs (raw) | 90 days | After evaluation, only the scores matter. |
| Actuals (measured weather) | 2 years | Useful for headache analysis, climate trends. |
| User data | Until account deleted | GDPR-friendly: user can export + delete. |
| Headache events | Forever | Medical diary β never auto-delete. |
# Weekly cleanup cron on Pi:
0 3 * * 0 sqlite3 /opt/amfor-cast/data/amfor-cast.db "
DELETE FROM forecasts WHERE issued_date < date('now', '-90 days');
DELETE FROM route_waypoints WHERE created_at < date('now', '-90 days');
VACUUM;
"
| What | Where | Frequency | How |
|---|---|---|---|
| SQLite DB | GitLab (private repo) or Backblaze B2 | Daily | sqlite3 .backup β compress β upload |
| Config + secrets | Encrypted file on GitLab | On change | Manual commit (age-encrypted) |
| Full Pi SD image | External drive | Monthly | dd image of SD card |
# Daily DB backup cron: 0 4 * * * cd /opt/amfor-cast && \ sqlite3 data/amfor-cast.db ".backup /tmp/amfor-backup.db" && \ gzip -f /tmp/amfor-backup.db && \ rclone copy /tmp/amfor-backup.db.gz remote:amfor-backups/$(date +%Y-%m-%d).db.gz && \ find /tmp/amfor-backup* -delete
Recovery time: If Pi SSD dies, you can be back online in ~1 hour: flash new SD, install packages, clone repo, restore DB from backup, done.
| Milestone | Duration | Status |
|---|---|---|
| MVP Pi + MySQL + dual env + deployment | 3-4 sessions | β Complete |
| v1.2 User management + saved cities | 2-3 sessions | β Complete (auth, cities, admin panel) |
| v1.1 Route planner pro + mobile | 2-3 sessions | π² Next (multi-route, departure time, road conditions) |
| v2.0 AMFOR model + notifications | 3-4 sessions | π² Oct 2026+ (needs 60+ days of data) |
Current state of the project β everything carries forward into the new architecture:
--skip-validator / --only-validator cron splitsys.executable subprocess fix β child scripts always use venv Python in cronamfor-cast.com (prod) + nonprod.amfor-cast.com (staging)release.py: deploy-test, promote (with backup), rollback, statusDecisions to make before starting MVP:
app.X and test.X?Timing: After v2.0 is stable and PWA is proven. The PWA (v2.0) is the stepping stone β if it covers 90% of mobile use cases, a native app may not be needed at all.
| Approach | Effort | Result | Best for |
|---|---|---|---|
| PWA (Progressive Web App) | Low β you already have the web app | Installable from browser, works offline, push notifications, home screen icon | If 90% of native UX is enough. No App Store needed. |
| React Native / Expo | Medium β single JS codebase for both platforms | True native feel, App Store listing, background location access | If you want App Store presence and native maps/GPS integration |
| Flutter | Medium β Dart, single codebase | Very smooth UI, both platforms from one code, hot reload | If you want best-in-class UI polish, willing to learn Dart |
| Kotlin (Android) + Swift (iOS) | High β two separate codebases | Best performance, full platform access, ultimate native feel | Only if you have a team or want to specialize per platform |
Recommended path:
| Feature | PWA | Native app |
|---|---|---|
| Install from browser | β | β (App Store only) |
| Offline forecast cache | β | β |
| Push notifications | β (Android), β οΈ (iOS limited) | β Full |
| Background GPS tracking | β | β (auto-detect route start) |
| Widget on home screen | β | β (show current forecast glanceable) |
| Haptic feedback | β | β |
| App Store discoverability | β | β |
| Apple Watch / Wear OS | β | β (departure time on wrist) |
| Siri/Google Assistant | β | β ("Hey Siri, what's my commute weather?") |
Key insight: Building the Pi API properly for the web app (v1.1-v1.2) means the mobile app is just a different UI on top of the same backend. No new server work needed β only a new client.
| Platform | Cost | Requirement |
|---|---|---|
| Google Play | $25 one-time | Google Developer account, signed APK/AAB |
| Apple App Store | $99/year | Apple Developer account, Mac needed for final build |
| Alternative (Android) | Free | Direct APK download from your website (sideload) |
Cost-saving tip: Start Android-only (β¬25 one-time), distribute as direct APK from your website. Add iOS + App Store only if there's real demand. Expo/EAS can build iOS without owning a Mac ($99/year for Apple account still needed).
Vision: Build a custom machine-learning forecast model ("AMFOR") that learns from all NWP models' systematic errors and produces forecasts that outperform any individual input model for Hungarian locations. This is NOT a numerical weather model β it's a statistical post-processing system that corrects and blends existing NWP forecasts using local verification data.
The key insight: every day, today's forecasts become tomorrow's training data. A forecast made on Aug 10 for Aug 12 becomes a labeled example once Aug 12's actual measurements arrive. The database already collects exactly this data β forecasts vs actuals for 8 models Γ 9 cities Γ 16 horizons.
Instead of just picking the historically best model (current approach), we can learn a function that maps all models' predictions + context β corrected forecast. This captures:
| Phase | What | When | Complexity |
|---|---|---|---|
| Phase 1 | Weighted Ensemble β inverse-MAE weights per model/city/horizon | Now (data exists) | ~50 lines Python, no ML library needed |
| Phase 2 | Feature Engineering β build training dataset from historical forecasts + actuals | Sep 2026 (60+ days of data) | SQL query + pandas DataFrame builder |
| Phase 3 | LightGBM Training β train model on PC/Colab, deploy ~1MB model file to Pi | Oct 2026 (90+ days) | LightGBM/XGBoost, standard ML workflow |
| Phase 4 | Live Inference β AMFOR appears as a model in forecast pages, competes in rankings | Oct-Nov 2026 | Inference script + integration with render pipeline |
Can ship immediately. Uses existing evaluation data. No external libraries needed.
Instead of "pick the single best model", compute a weighted average:
# For each city/horizon/parameter: weight_i = (1 / MAE_i) / sum(1 / MAE_j for all models j) # AMFOR forecast: amfor_temp = sum(weight_i * model_i_forecast for all models)
Weights recompute daily from the rolling 30-day evaluation window (same data that drives current rankings). The system already has everything needed β it's purely a new output step.
Expected improvement: 5-15% MAE reduction over best-single-model, because even the #2/#3 models contribute useful signal that pure selection throws away.
Build a training dataset where each row is one forecast event that has been verified:
| Feature | Source | Type |
|---|---|---|
| ECMWF temperature forecast | forecast_hours table | float |
| ICON temperature forecast | forecast_hours table | float |
| GFS temperature forecast | forecast_hours table | float |
| AROME temperature forecast | forecast_hours table | float |
| CMA / JMA / GEM forecasts | forecast_hours table | float |
| Model spread (max - min) | computed | float |
| Model agreement (std dev) | computed | float |
| Cloud cover (all models) | forecast_hours table | float |
| Wind speed (all models) | forecast_hours table | float |
| Surface pressure (all models) | forecast_hours table | float |
| Recent ECMWF bias (7-day rolling MAE) | evaluations table | float |
| Recent ICON bias | evaluations table | float |
| Recent GFS bias | evaluations table | float |
| Forecast horizon (hours) | computed | int |
| Hour of day (target time) | computed | int (0-23) |
| Day of year | computed | int (1-366) |
| Latitude / Longitude | cities table | float |
| TARGET: observed temperature (from Archive API verification) | ||
Same structure repeats for precipitation (classification: rain/no-rain) and pressure.
Key decisions:
.txt file (~1 MB).scp'd to Pi.
# Training pseudocode (runs on PC, not Pi)
import lightgbm as lgb
import pandas as pd
# Build features from DB
df = build_training_dataset() # SQL β pandas
X = df.drop(columns=["observed_temp"])
y = df["observed_temp"]
# Time-based train/test split
train = df[df["date"] < "2026-10-15"]
test = df[df["date"] >= "2026-10-15"]
model = lgb.LGBMRegressor(
n_estimators=500,
learning_rate=0.05,
num_leaves=31,
min_child_samples=20,
)
model.fit(X_train, y_train)
model.booster_.save_model("amfor_temp_model.txt")
# β scp amfor_temp_model.txt pi:/opt/amfor-cast/models/
After save-forecast.py saves the NWP forecasts to DB, a new script runs inference:
# amfor-predict.py (runs on Pi, microseconds per prediction) import lightgbm as lgb model = lgb.Booster(model_file="/opt/amfor-cast/models/amfor_temp_model.txt") features = build_features_for_today(city, horizon) amfor_forecast = model.predict([features])[0] # Save as another "model" in the forecast DB insert_forecast(snapshot_time, today, city, "AMFOR", amfor_data)
The AMFOR forecast then appears in:
This is NOT a numerical weather prediction model. We are not:
We are building a statistical post-processing system (MOS-like) that learns local corrections on top of existing NWP output. This is exactly what national meteorological services do, and it works remarkably well.
| Timeframe | Data collected | Training rows (approx) | Capability |
|---|---|---|---|
| Aug 2026 (now) | 7 days Γ 9 cities Γ 8 models | ~10k | Not enough β keep collecting |
| Sep 2026 | 30 days | ~50k | Weighted ensemble viable |
| Oct 2026 | 60 days | ~100k | First LightGBM training possible |
| Dec 2026 | 150 days | ~250k | Seasonal patterns emerging |
| Aug 2027 | 365 days | ~600k | Full annual cycle, robust model |
| Item | Status |
|---|---|
| Forecast data collection (8 models, hourly) | β Running since Aug 7 |
| Verification engine (MAE per model/city/horizon) | β Running daily |
| MySQL storage for all forecast + evaluation data | β Operational |
| 60+ days of collected data | β³ ~Oct 2026 |
| LightGBM installed on training machine | π² pip install lightgbm |
| Feature builder script | π² To build (Phase 2) |
| Training pipeline script | π² To build (Phase 3) |
| Inference script for Pi | π² To build (Phase 4) |