Inspiration

Heat already costs Kenya a huge amount of outdoor work: 1.1 billion potential labour hours were lost in 2024 alone, with 74% of that loss occurring in agriculture.

Around Juja specifically, much of the local economy depends on outdoor work including quarrying, construction, and farming. A study of Kenyan farmers wearing heat sensors found that outdoor Wet Bulb Globe Temperature (WBGT) peaks right in the middle of the working day.

At the same time, water is scarce and often used inefficiently, while Kiambu's climate risk assessment identifies erratic rainfall and low soil moisture as real hazards to farming.

The environmental information that exists is often too coarse to act on. Kenya Met defines heatwaves per town. Agricultural advisories are distributed per ward. But neither necessarily tells one person, at one site, performing one activity, which hours today are risky and when they should move the work.

Meanwhile, we had a real environmental monitoring system already operating at JKUAT: Conduit@Empathy, collecting observations at approximately 15-minute intervals.

It felt wrong not to turn that data into something people could actually use to make decisions about their day.


What it does

Afya Mazingira transforms environmental observations into practical decisions, in both English and Kiswahili.

Right now

Afya Mazingira identifies the current environmental state:

  • Cool & Humid
  • Rapid Warming
  • Hot / High Exposure
  • Cooling / Recovery

These states were learned from more than a year of environmental observations rather than being manually invented.

Next 9 hours

The system forecasts WBGT every 15 minutes for up to 9 hours, together with an uncertainty band.

Those forecasts are evaluated on held-out data that the models did not see during fitting.

What should I do about it?

Users can tell Afya Mazingira what they are planning — such as:

  • Walking
  • Sports
  • Construction
  • Field work
  • Outdoor work
  • Outdoor events

The system evaluates the available time windows, assigns environmental exposure levels, and recommends the best available window for the activity.

Instead of only answering:

"What is the weather?"

Afya Mazingira tries to answer:

"When is the better time for me to do this activity, and why?"

For farms

The agricultural intelligence layer provides environmental guidance for:

  • Irrigation depth
  • Spraying windows
  • Field-work windows
  • Crop heat stress
  • Planting outlook

It combines ground temperature observations with regional rainfall and soil-moisture information.

Beyond JKUAT

The same environmental-intelligence approach can be applied to neighbouring counties using regional reanalysis data.

The application clearly distinguishes regional environmental intelligence from actual ground observations, so modelled regional conditions are never presented as though they came from the physical station.

Additional capabilities

Afya Mazingira also includes:

  • Flood-risk conditions
  • Threshold-based email alerts
  • Printable environmental briefings
  • Historical replay
  • Data-quality monitoring
  • Environmental-state intelligence
  • Activity-aware recommendations
  • AI-powered explanations

The AI layer explains why a recommendation was produced in plain language, in either English or Kiswahili, without being allowed to invent environmental measurements.


How we built it

The core design principle behind Afya Mazingira is:

Deterministic computation first. AI explanation second.

Every environmental measurement, forecast, risk classification, and recommendation is computed in code.

A language model — using Gemini, with fallback support through Groq, OpenAI, and Anthropic — only explains results that the deterministic pipeline has already produced.

A grounding checker rejects responses containing numerical claims that were not present in the verified system output.

Environmental data pipeline

The station's observations are obtained through two independent data feeds for redundancy:

  1. JHUB Africa's Conduit API
  2. The public CHORDS portal used by the same physical monitoring system

This provides two independent upload paths for the underlying observations. If one source is delayed, Afya Mazingira can check whether the other contains a fresher observation.

If neither source is available, the system can fall back to a recorded archive, with synthetic data used only as a final development fallback and always clearly labelled.

Conduit Sentinel

Every observation passes through Conduit Sentinel, our environmental data-quality layer.

Sentinel applies validation rules and sensor audits before observations are allowed to influence user-facing intelligence.

It checks for issues including:

  • Missing observations
  • Stale data
  • Invalid sentinel values
  • Sensor inconsistencies
  • Physically suspicious values
  • Sensor-group degradation

The system then produces an explicit data-quality status instead of silently trusting every incoming value.

Environmental State Engine

We applied k-means clustering to the historical environmental observations and identified four recurring environmental states:

  1. Cool & Humid Stable
  2. Rapid Warming
  3. Hot / High-Radiation Exposure
  4. Cooling / Recovery

This allows Afya Mazingira to interpret the environment as a changing system rather than presenting temperature, humidity, radiation, and wind as unrelated measurements.

Forecasting

A separate ridge regression model is fitted for each 15-minute forecast step out to 9 hours.

The forecasting pipeline uses 25 engineered features, including:

  • Current environmental levels
  • Hourly changes
  • Rolling means
  • Time-of-day encodings
  • Day-of-year encodings

The models are backtested against held-out months that were not used during model fitting.

Their performance is also compared against a naive persistence baseline:

"Assume nothing changes."

This means forecast performance is measured rather than simply assumed.

Technology stack

Afya Mazingira is built with:

  • Next.js 16
  • React 19
  • TypeScript
  • Tailwind CSS 4
  • PostgreSQL
  • Drizzle ORM
  • Neon
  • Recharts
  • Leaflet
  • Vercel
  • Resend

A daily Vercel Cron job supports automated environmental alerts and email delivery.


Challenges we ran into

One of the biggest challenges was discovering that data freshness cannot simply be assumed.

The station API can lag significantly behind the actual observation period. During the hackathon, we encountered exactly this situation while building the system.

That forced us to reconsider what the word "live" actually means.

Rather than hiding the problem, we redesigned Afya Mazingira so that every relevant interface exposes the age and quality of the underlying data. The application never displays a bare LIVE badge without first checking whether the observations are actually fresh.

We then identified an additional source for observations from the same monitoring system through the public CHORDS / 3D-PAWS infrastructure.

Afya Mazingira can therefore check both feeds and use the freshest valid observation available rather than depending entirely on a single API.

Keeping AI grounded

Another major challenge was making the generative-AI layer trustworthy.

At one stage, a newly introduced forecast horizon had not yet been added to the grounding checker's allow-list.

The AI produced a correct explanation containing that forecast, but the grounding layer rejected it because the number was not yet recognised as an authorised value.

The system then returned the deterministic fallback explanation instead.

Although this exposed an implementation issue, it also demonstrated exactly why we built the grounding system so strictly.

As Afya Mazingira grows, the AI layer must remain subordinate to verified environmental computation — not the other way around.


Accomplishments that we're proud of

We're especially proud that Afya Mazingira's forecasting system is evaluated rather than merely presented as plausible.

On held-out test data, the forecasting system beats a naive "no change" persistence baseline by approximately:

  • 13% at 15 minutes
  • 72% at 9 hours

These are measured test-set results rather than marketing claims.

We're also proud of Conduit Sentinel.

During sensor-quality analysis, Sentinel detected that the station's firmware-computed WBGT was physically inconsistent with the wet-bulb temperature in more than 60% of observations.

Rather than silently accepting the derived value, the pipeline detects the issue and corrects its treatment before the affected data reaches user-facing recommendations.

Finally, we're proud that Afya Mazingira is designed to degrade honestly.

If the ground station becomes stale or unavailable, the application does not pretend that an old observation is current.

Instead, users see the data status clearly, and the system can gracefully fall back to available regional environmental information rather than presenting a fabricated measurement or simply failing.


What we learned

We learned that "live" is a claim that has to be continuously verified, not a label that can be applied once and forgotten.

We also learned that environmental AI becomes much more trustworthy when the architecture follows a strict rule:

Computation decides. AI explains.

The deterministic system produces the measurements, forecasts, classifications, and recommendations. Generative AI communicates those results in language people can understand.

We also learned the value of data-source redundancy.

Finding an additional independent data path for the monitoring system improved reliability more than increasingly complicated fallback logic around a single source ever could.

Most importantly, we learned that environmental data becomes significantly more useful when we stop asking users to interpret numbers and instead help them answer practical questions:

What is changing?

What does it mean for me?

What should I do?

When should I do it?


What's next for Afya Mazingira

Our next step is to calibrate the station's light measurements against physical irradiance so that Afya Mazingira can calculate full-sun WBGT, rather than relying primarily on shade-based thermal exposure estimates.

We also want to expand the platform to additional 3D-PAWS monitoring stations reporting through the CHORDS infrastructure across Kenya.

As the observation archive grows, we plan to introduce monthly model retraining and evaluation, publishing updated performance metrics after every model cycle.

Other planned improvements include:

  • Real CHIRPS point extraction for rainfall instead of the current ERA5-Land substitute
  • Expanded satellite and Earth-observation integration
  • Improved soil-moisture intelligence
  • More robust flood-susceptibility modelling
  • GPS and location-based environmental intelligence
  • Multi-location monitoring for organisations
  • Additional ground-station integration
  • Improved forecast calibration and uncertainty estimation

Finally, we want to make Afya Mazingira useful to people who may never open a web dashboard.

That means delivering actionable environmental intelligence through SMS and WhatsApp alerts, beginning with agricultural and outdoor-work use cases.

Our long-term goal is simple:

Turn environmental data into environmental intelligence and environmental intelligence into early action.

Built With

Share this project:

Updates

Submission history