🚀 LogiFlow AI: Intelligent logistics powered by TiDB Serverless vector search & multi-step AI agents. Predictive maintenance, route optimization & emergency response — all automated! 🤖📦
A fully agentic, end-to-end workflow that chains data ingestion, vector + full‑text search, LLM reasoning, and external tool calls — orchestrated over TiDB Serverless on TiDB Cloud.
What to build (with emojis)
- 🎯 Goal: A working logistics platform where an AI agent analyzes fleet signals (telematics, maintenance logs, driver notes), predicts risks, plans routes, and triggers actions — all in one automated flow.
- 🧱 Building blocks chained:
- 📥 Ingest & Index Data: Stream PDFs, logs, IoT telemetry; embed and store vectors + raw docs in TiDB Serverless.
- 🔎 Search Your Data: Hybrid vector + keyword search to find similar incidents, parts, routes, SLAs.
- 🧠 Chain LLM Calls: Summarize findings, classify incident type, reason about next steps, generate action plans.
- 🔌 Invoke External Tools: Routing/traffic APIs, weather, Slack/Twilio alerts, ticketing, webhooks.
- 🛠️ Multi-Step Flow: From input → retrieval → reasoning → tool actions → verification → final outcome.
Inspiration
Growing fleets juggle uptime, safety, and cost — while data lives everywhere. We wanted a pragmatic AI “ops brain” that stitches sensor feeds, maintenance history, and context into decisive, auditable actions. TiDB Serverless lets us keep relational truth and vector intelligence in one place, so the agent can retrieve, reason, and act without duct-taped databases. ⚡
What it does
- 📡 Real-time incident triage: Ingest telematics alerts (e.g., engine temp spike), retrieve similar past cases, summarize likely root causes, and rank next actions.
- 🗺️ Route optimization with context: Plan or re-route using traffic, weather, depot constraints, and driver hours; justify decisions with citations to retrieved records.
- 🧰 Predictive maintenance: Surface components trending toward failure based on similarity to historical patterns; open a work order if risk > threshold.
- 📣 Automated comms: Notify dispatch, DM the driver with concise steps, and post a timeline + rationale to Slack for auditability.
- 🧾 Cost- and SLA-aware decisions: Consider penalties, fuel, service windows, and parts availability to choose the best operational path.
- 🧪 “Copilot” and “Autopilot” modes: Human-in-the-loop approvals for critical steps, or fully automated execution for low-risk events.
How we built it
Data model and storage (TiDB Serverless)
- 🗃️ Core tables:
- Vehicles: metadata, maintenance schedules, capabilities.
- Telematics: timestamped sensor events; linked to vehicles.
- Docs: maintenance logs, manuals, SOPs; stored text + vector embedding.
- Incidents: detected issues, decisions, actions, outcomes.
- Routes & Stops: constraints, SLAs, depots, geofences.
- 🧭 Retrieval: Hybrid search combining
- Vector similarity: semantically similar incidents, fixes, and SOPs.
- Full‑text filters: error codes, part numbers, vendor names.
- Relational joins: link results to vehicles, SLAs, inventory.
Agentic workflow
🚪 Intake
- Trigger: telematics anomaly, driver note, or dispatcher query.
- Normalize: parse payloads, attach vehicle + route context.
📥 Ingest & index
- Embed: new logs/SOPs → vector embeddings.
- Store: raw text + vectors in TiDB; update indexes.
🔎 Retrieve
- Hybrid search: top‑k similar incidents + relevant SOPs/manuals.
- Context build: compact snippets, key metrics, and prior outcomes.
🧠 Reason
- LLM calls: classify incident, assess severity, propose actions, estimate risk/cost impact, and choose tools to invoke.
🔌 Act (tools)
- Routing API: compute safe/fast route or depot diversion.
- Weather/Traffic: adjust ETA and risk.
- Comms: Slack/Twilio notifications; create a ticket/work order.
✅ Verify & log
- Feedback loop: check tool responses; if conflicts, re‑plan.
- Persistence: write decisions, artifacts, and outcomes to Incidents.
📈 Learn
- Post‑mortem: embed the outcome summary for future retrieval.
Example schema sketch (conceptual)
-- Pseudo-SQL for illustration; adjust to TiDB's current vector index syntax
CREATE TABLE docs (
id BIGINT PRIMARY KEY,
kind VARCHAR(32), -- 'sop' | 'manual' | 'log'
title VARCHAR(255),
content TEXT,
embedding VECTOR(1536), -- embedding dimension
created_at TIMESTAMP
-- INDEX on embedding for ANN search
);
CREATE TABLE incidents (
id BIGINT PRIMARY KEY,
vehicle_id BIGINT,
trigger JSON, -- telematics payload / user prompt
retrieval JSON, -- doc/incident ids + scores
plan JSON, -- reasoning trace + chosen actions
status VARCHAR(24), -- 'planned' | 'executed' | 'verified'
outcome JSON, -- success/failure/metrics
created_at TIMESTAMP
);
Orchestration spec (human-readable)
flow: logiflow_incident_pipeline
steps:
- name: normalize_input # parse, enrich
- name: embed_if_new_docs # ingest/index
- name: hybrid_retrieve # vector + keyword + joins
- name: llm_plan_actions # classify, risk, plan
- name: route_and_weather # external tools
- name: notify_and_ticket # Slack/Twilio + work order
- name: verify_and_log # close the loop
modes:
- autopilot
- copilot_requires_approval
Challenges we ran into
- 🧩 Hybrid ranking: Balancing semantic similarity with hard constraints (SLA windows, part availability) required careful scoring and tie‑breakers.
- 🗂️ Heterogeneous data: Mixing PDFs, free‑form notes, and IoT signals demanded robust parsing and consistent embedding strategies.
- ⏱️ Latency budgets: Keeping end‑to‑end action under tight SLAs meant batching embeddings, caching retrievals, and pruning context for LLM calls.
- 🧪 Grounded reasoning: Ensuring the agent cites retrieved sources and avoids overreach required tool-availability checks and fallback heuristics.
- 🌍 Real‑world variability: Edge cases (rural connectivity, extreme weather, multi‑stop constraints) pushed the planner beyond “happy paths.”
Accomplishments that we’re proud of
- 🔗 True end-to-end autonomy: From raw signal to routed plan and verified action — no manual glue.
- 🧭 Explainable ops: Every recommendation is backed by retrieved incidents, SOPs, and structured rationale.
- 🧱 Clean data contract: Unified relational + vector store simplified joins, auditing, and evolution of features.
- 🧰 Modular tools: Routing, weather, comms, and ticketing can be swapped without touching core logic.
- 🧪 Demoability: A crisp, repeatable scenario that shows triage → plan → route → notify in minutes.
What we learned
- 🧠 Retrieval-first design: Better outcomes start with great retrieval. Hybrid search with narrow, well-tagged corpora beats giant, noisy contexts.
- 📐 Schema matters: Designing for joins across vectors, telemetry, and SLAs keeps the agent grounded and auditable.
- ⚖️ Guardrails > guesswork: Tool health checks and “copilot mode” approvals prevent brittle automations from escalating.
- 🚦 Cost/latency tuning: Smaller, task‑specific prompts and cached embeddings deliver big wins without sacrificing quality.
What’s next for LogiFlow AI Intelligent Logistics Management Platform
- 🛰️ Digital twin: Simulate routes, depot utilization, and failure cascades to test plans before execution.
- 🧮 Multi-objective routing: Optimize for fuel, time, risk, emissions, and SLA penalties with transparent trade‑offs.
- 🔄 Continuous learning: Fine-tune retrieval and classification from outcomes; auto-tag documents with richer metadata.
- 📦 Parts & inventory loop: Join with suppliers to reserve parts proactively when failure likelihood rises.
- 🧱 Enterprise ops: RBAC, audit trails, red-team scenarios, and SOC-friendly observability.
- 🗺️ Rich visualization: Live map timeline of decisions; “why this route” overlays; driver UX with offline-first hints.
Built With
- docker
- github-actions-(ci/cd)
- google-maps-platform-(routing-&-traffic)
- javascript-(node.js)
- json
- kubernetes
- langchain
- netlify
- openai-api
- openweather-api
- postman
- python
- redis
- rest-apis
- slack-api
- sql
- tidb-serverless-(tidb-cloud)
- tidb-vector-search
- twilio
- vs-code
- websockets
- yaml-(workflow-orchestration)



Log in or sign up for Devpost to join the conversation.