About Lumin

Inspiration

Last year, a Category 4 typhoon in the South China Sea delayed 47 container ships by an average of 6.3 days. One pharmaceutical shipment worth $3.2M lost its entire cold chain — vaccines spoiled, contracts broken, patients waiting. The logistics team found out from a news alert, 14 hours after the storm made landfall. We asked: what if an AI agent caught it the moment it formed, rescheduled the shipment automatically, and told the client before they even checked the weather?

That question became Lumin.

What We Built

Lumin is a 7-step autonomous agent pipeline that ingests a shipment, detects weather threats, extracts storm entities via NLP, grounds risk assessment in a historical knowledge base, generates LLM-powered recommendations, auto-reschedules deliveries on Google Calendar, and notifies clients by email — all in under five seconds. The frontend is a real-time WebSocket dashboard with a multi-factor risk scoring model.

Mathematical Risk Model

The risk score (0–100) is a weighted multi-factor model independent of the LLM's reasoning:

$$ R = \underbrace{\min\left(35,\ \frac{v}{220} \cdot 35\right)}{\text{Storm Intensity}} + \underbrace{f(d)}{\text{Proximity}} + \underbrace{\sigma(p, c)}{\text{Cargo Sensitivity}} + \underbrace{\tau(t) + \rho(r)}{\text{Route Exposure}} $$

Where $f(d)$ is a step function decaying with distance from the storm, $\sigma(p, c)$ weights packaging type and cargo value, and $\tau(t), \rho(r)$ score transport method and delivery priority. The final score is clamped to $[1, 100]$ and modulated by the user's risk tolerance:

$$ R_{\text{final}} = \begin{cases} \min(100,\ R \cdot 1.15) & \text{Conservative} \ R & \text{Balanced} \ \max(1,\ R \cdot 0.85) & \text{Aggressive} \end{cases} $$

Tech Stack

Layer Technology
Backend FastAPI (Python), Uvicorn
Database ClickHouse Cloud (real-time analytical queries)
NLP Pioneer (gliner2-base-v1) for entity extraction
LLM TrueFoundry → Claude Sonnet, OpenRouter fallback
Observability Langfuse (tracing, token counting, latency)
Calendar Google Calendar OAuth2 (cancel + create events)
Notifications SMTP (Gmail) HTML email, Twilio SMS, Composio Slack
Frontend Next.js 15, TypeScript, Tailwind CSS, WebSockets
Knowledge Base Local markdown files (Senso) — hurricane/typhoon/monsoon patterns

Challenges We Faced

LLM reliability at speed. Calling an LLM adds 15–20 seconds of latency. We solved this by computing a mathematical risk score independently from four deterministic factors — storm intensity, proximity, cargo sensitivity, and route exposure — so the dashboard renders instantly while the LLM enriches the recommendation text asynchronously.

Google Calendar OAuth2 race conditions. When the agent cancels an event and creates a new one in rapid succession, Google's API occasionally returns stale state. We added retry logic and a status: "cancelled" mutation instead of deletion, so users see the crossed-out original date alongside the new event — a much better UX than the event just disappearing.

ClickHouse schema for spatiotemporal queries. Querying "find all storms within 300km of this 3,000nm shipping route" required careful indexing on latitude, longitude, and timestamp. We landed on a materialized view pattern that pre-computes route-waypoint bounding boxes, reducing query time from 800ms to 12ms.

Making seven API calls feel like one. The agent pipeline calls ClickHouse, Pioneer, Senso, TrueFoundry, Google Calendar, SMTP, and Langfuse. Orchestrating these with proper error boundaries — where one failure doesn't kill the pipeline — took careful async/await chains with per-step fallbacks.

What We Learned

  • Mathematical grounding beats pure LLM. Judges and users trust a risk score with transparent arithmetic more than a black-box confidence number. Our four-factor model gave the LLM something to anchor on, and the results were more consistent across product types.
  • Observability isn't optional. Langfuse tracing was the difference between "the LLM gave a weird answer" and "the prompt had a truncated entity name from Pioneer failing silently." Every integration needs a trace.
  • Calendar UX matters. Cancelling an event (crossed out) versus deleting it (gone) was a small decision with outsized impact during demo. Logistics teams rely on audit trails — they need to see what changed and why.
  • Fail gracefully, never silently. Every API call in the pipeline has a fallback. Pioneer fails? Regex extraction. TrueFoundry fails? OpenRouter. Google Calendar fails? Still send the email. The pipeline never crashes.
Share this project:

Updates