How git791/chain-guard-ai works
ChainGuard AI is a logistics command center for shipment visibility, disruption awareness, AI-generated operational suggestions, and sustainability reporting. Managers sign in, inspect live shipment status and routes, create shipments, and review analytics; Firestore snapshots feed the tracking views, while a delay-triggered function records event-feed alerts. The README also describes automated rerouting, but sampled code shows Gemini suggestions rather than an implemented route-approval or persistence flow. Wiring from the dashboard’s insight widget to the Gemini endpoint was not sampled, so that connection is omitted.
Main entry points: app/page.js Command Dashboard · AuthContext.js Auth Context · useShipments.js Shipment Feed · routes/page.js Live Routes
Components 21
Access and Profile
- Sign In
app/login/page.js - Auth Context
lib/AuthContext.js - Profile Settings
app/settings/page.js
Shipment Operations
- Command Dashboard
app/page.js - Shipment Feed
hooks/useShipments.js - Shipment List
components/ShipmentList.jsx - Create Shipment
components/CreateShipmentModal.jsx
Risk and Insights
- Delay Detector
functions/index.js - Event Feed
- Disruption Alerts
components/DisruptionList.jsx - AI Insights View
components/AIInsights.jsx - Gemini API Route
app/api/gemini/route.js
Mapping and Analytics
- Live Routes
app/routes/page.js - Route Map
components/Map.jsx - Sustainability Analytics
app/analytics/page.js - Trend Chart
components/Chart.jsx
Other components
- Logistics Manager
- Firebase Auth
- Firestore
- Gemini
- Google Maps API
Connections 25
- Logistics Manager → Sign In: submits credentials
- Sign In → Auth Context: calls login
- Auth Context → Firebase Auth: authenticates
- Logistics Manager → Command Dashboard: views operations
- Command Dashboard → Auth Context: checks session
- Logistics Manager → Profile Settings: edits profile
- Profile Settings → Auth Context: updates profile
- Command Dashboard → Shipment Feed: loads shipments
- Shipment Feed → Firestore: subscribes to shipments
- Command Dashboard → Shipment List: renders shipments
- Logistics Manager → Create Shipment: enters shipment
- Create Shipment → Firestore: adds shipment
- Firestore → Delay Detector: dispatches update
- Delay Detector → Event Feed: writes delay event
- Command Dashboard → Disruption Alerts: renders alerts
- Command Dashboard → AI Insights View: renders insights
- Gemini API Route → Gemini: requests generation
- Logistics Manager → Live Routes: views live routes
- Live Routes → Shipment Feed: loads shipments
- Live Routes → Route Map: passes shipments
- Command Dashboard → Route Map: passes shipments
- Route Map → Google Maps API: renders map
- Logistics Manager → Sustainability Analytics: views sustainability
- Sustainability Analytics → Shipment Feed: loads shipments
- Sustainability Analytics → Trend Chart: renders trend