Real-time Shipment Risk Monitoring & Logistics Intelligence Platform
Real-time Tracking โข Risk Assessment โข Intelligent Alerts โข Analytics Dashboard โข Webhook Integration
Live Demo โข Features โข Quick Start โข API Docs
ShipGuard AI is an enterprise-grade logistics monitoring platform that provides real-time visibility into shipment operations, automated risk assessment, and predictive analytics. Built for modern supply chains, it seamlessly integrates with Transportation Management Systems (TMS), Enterprise Resource Planning (ERP) systems, and carrier APIs.
The platform leverages Firebase Firestore for real-time data synchronization, enabling instant updates across dashboards, alerts, and analytics. With intelligent webhook ingestion, weather integration, and logistics news aggregation, ShipGuard AI delivers actionable insights that help businesses proactively manage shipment risks and optimize operations.
Whether you're tracking a single shipment or managing thousands across multiple carriers and modes, ShipGuard AI provides the tools you need for complete logistics visibility and control.
- โ Real-time Shipment Tracking โ Monitor shipments across multiple carriers and transport modes
- โ Automated Risk Scoring โ Dynamic risk calculation with visual distribution analytics
- โ Intelligent Alert System โ Proactive notifications for high-risk events and delays
- โ Live Analytics Dashboard โ Trend analysis, operational metrics, and KPIs
- โ Webhook Integration โ Seamless ingestion from TMS/ERP systems with secure authentication
- โ Webhook Security Hardening โ HMAC signature verification, payload validation, and rate limiting
- โ Weather Monitoring โ Location-based weather forecasts for route planning
- โ Logistics News Feed โ Real-time industry news aggregation
- โ Route Intelligence โ Alternative route recommendations with operational risk context
- โ Firestore Real-time Sync โ Instant updates across all connected clients
- โ Multi-carrier Support โ DHL, FedEx, UPS, and custom carrier integration
- โ Custom Reporting โ Configurable views, filters, and data exports
- โ User Settings Persistence โ Firestore-backed preferences and configurations
- โ Secure API Routes โ Weather, news, and route proxy endpoints with backend-only provider keys
- โ Session Protection โ Frontend session timeout controls and protected route enforcement
- โ Resilience Layer โ Frontend retry/timeout handling and offline/online status UX
- โ Observability Ready โ Optional Sentry integration for frontend and backend error monitoring
- โ CI Automation โ Frontend and backend GitHub Actions workflows
- React 18 โ Modern component-based UI framework
- Vite โ Lightning-fast build tool and dev server
- Tailwind CSS โ Utility-first styling with custom design system
- Recharts โ Interactive data visualization and charting
- Firebase Web SDK โ Client-side Firestore subscriptions and authentication
- Node.js โ JavaScript runtime for server-side logic
- Express โ Minimal and flexible web application framework
- Firebase Admin SDK โ Server-side Firestore operations and authentication
- CORS + Helmet + Morgan โ Cross-origin controls, security headers, and request logging
- Joi + express-rate-limit โ Payload validation and abuse protection
- Sentry โ Optional application error monitoring (frontend + backend)
- GitHub Actions โ Frontend build checks and backend syntax validation
- Cloud Firestore โ Scalable NoSQL document database with real-time sync
- Firebase Authentication โ Secure user authentication and authorization
- OpenWeather API โ Weather data and location-based forecasts
- News API โ Logistics and supply chain news aggregation
shipguard-ai/
โโโ backend/
โ โโโ server.js # Express server, API routes, webhook handler
โ โโโ .env # Backend environment variables
โ โโโ .env.example # Backend env template
โ โโโ service-account.json # Firebase Admin credentials (gitignored)
โ โโโ package.json # Backend dependencies
โ โโโ node_modules/
โโโ src/
โ โโโ components/ # Reusable React components
โ โโโ pages/ # Page-level components (Dashboard, Analytics, Alerts)
โ โโโ lib/ # Firebase client & API integrations
โ โ โโโ api/ # Backend proxy API clients + retry utility
โ โ โโโ ml/ # Risk prediction and recommendation utilities
โ โโโ App.jsx # Main application component
โ โโโ main.jsx # React entry point
โโโ public/ # Static assets
โโโ .env # Frontend environment variables
โโโ .env.example # Frontend env template
โโโ .gitignore # Git ignore configuration
โโโ package.json # Frontend dependencies and scripts
โโโ vite.config.js # Vite build configuration
โโโ tailwind.config.js # Tailwind CSS customization
โโโ postcss.config.js # PostCSS configuration
โโโ README.md # Project documentation
Ensure you have the following installed:
- Node.js v16 or higher
- npm or yarn
- Firebase project with Firestore and Authentication enabled
- API keys for OpenWeather and News API
# Clone the repository
git clone https://github.com/LegendarySumit/shipguard-ai.git
cd shipguard-ai
# Install frontend dependencies
npm install
# Install backend dependencies
cd backend
npm install
cd ..Create .env file in project root:
# Firebase Client Configuration
VITE_FIREBASE_API_KEY=your_firebase_api_key
VITE_FIREBASE_AUTH_DOMAIN=your-project.firebaseapp.com
VITE_FIREBASE_PROJECT_ID=your-project-id
VITE_FIREBASE_STORAGE_BUCKET=your-project.appspot.com
VITE_FIREBASE_MESSAGING_SENDER_ID=your_sender_id
VITE_FIREBASE_APP_ID=your_app_id
# Backend API URL
VITE_BACKEND_URL=http://localhost:8787Create backend/.env file:
# Server Configuration
PORT=8787
NODE_ENV=development
ALLOWED_ORIGINS=http://localhost:5173,http://127.0.0.1:5173
# Webhook Security
WEBHOOK_SECRET=your_secure_webhook_secret_min_32_chars
WEBHOOK_URL=http://localhost:8787
WEBHOOK_REQUIRE_HMAC=true
WEBHOOK_ALLOW_LEGACY_SECRET=false
# External APIs
OPENWEATHER_API_KEY=your_openweather_api_key
NEWS_API_KEY=your_news_api_key
# PII encryption (required for encrypted storage of customer/product fields)
PII_ENCRYPTION_KEY=replace_with_strong_random_secret
# Webhook retry queue (prevents data loss on transient failures)
WEBHOOK_RETRY_ENABLED=true
WEBHOOK_RETRY_INTERVAL_SEC=60
WEBHOOK_RETRY_MAX_ATTEMPTS=6
WEBHOOK_RETRY_BATCH_SIZE=25
# Firestore retention policy
RETENTION_ENABLED=true
RETENTION_DAYS=365
RETENTION_RUN_EVERY_HOURS=24
# Firebase Admin (choose one method)
FIREBASE_SERVICE_ACCOUNT_PATH=backend/service-account.json
# OR FIREBASE_SERVICE_ACCOUNT_JSON={"type":"service_account",...}
# OR FIREBASE_SERVICE_ACCOUNT_JSON_BASE64=base64_encoded_jsonnode -e "console.log(require('crypto').randomBytes(48).toString('base64url'))"This project includes hardened rules in firestore.rules.
firebase deploy --only firestore:rulesTerminal 1 โ Start Frontend:
npm run devFrontend available at http://localhost:5173
Terminal 2 โ Start Backend:
npm run backend:devBackend available at http://localhost:8787
# Build frontend
npm run build
# Preview production build
npm run preview
# Run backend in production
cd backend
NODE_ENV=production node server.jsAccess the main dashboard at http://localhost:5173 to view:
- Real-time shipment risk distribution
- Active alerts and notifications
- Quick statistics and KPIs
Navigate to /analytics for:
- Trend analysis with historical data
- Carrier and mode performance metrics
- Risk score evolution over time
Send a test shipment via webhook:
curl -X POST http://localhost:8787/api/webhooks/shipments \
-H "Content-Type: application/json" \
-H "x-webhook-secret: YOUR_WEBHOOK_SECRET" \
-d '{
"shipment": {
"trackingId": "TEST-1001",
"status": "in_transit",
"origin": "Berlin, DE",
"destination": "Munich, DE",
"riskScore": 25
}
}'Verify the shipment appears in Firestore and updates the dashboard in real-time.
GET /api/healthResponse:
{
"ok": true,
"timestamp": "2026-03-18T10:30:00.000Z",
"integrations": {
"firestoreIngestion": true,
"weatherAPI": true,
"newsAPI": true
}
}| Endpoint | Method | Description |
|---|---|---|
/api/weather/by-city |
GET | Get weather by city name |
/api/weather/by-coords |
GET | Get weather by coordinates |
/api/weather/geocode |
GET | Convert location to coordinates |
/api/weather/forecast |
GET | Get weather forecast |
/api/routes/alternatives |
POST | Get route alternatives from backend intelligence layer |
Example โ Weather by City:
GET /api/weather/by-city?city=London&units=metricQuery Parameters:
city(required) โ City nameunits(optional) โmetric,imperial, orstandard(default:metric)
Example โ Weather by Coordinates:
GET /api/weather/by-coords?lat=51.5074&lon=-0.1278&units=metricQuery Parameters:
lat(required) โ Latitudelon(required) โ Longitudeunits(optional) โ Temperature units
GET /api/news/logisticsResponse:
{
"articles": [
{
"title": "Global Shipping Disruptions Continue",
"description": "Latest updates on supply chain issues...",
"url": "https://example.com/article",
"publishedAt": "2026-03-18T10:00:00Z",
"source": { "name": "Logistics Weekly" }
}
]
}POST /api/webhooks/shipmentsHeaders:
Content-Type: application/json
X-Webhook-Timestamp: <unix-seconds>
X-Webhook-Signature: sha256=<hmac_sha256(secret, timestamp.rawBody)>
Migration compatibility (temporary):
x-webhook-secret: your_webhook_secret
Single Shipment Payload:
{
"shipment": {
"trackingId": "TMS-1002",
"status": "in_transit",
"carrier": "DHL",
"mode": "road",
"origin": "Hamburg, DE",
"destination": "Cologne, DE",
"riskScore": 31,
"riskLevel": "low"
}
}Batch Shipments Payload:
{
"shipments": [
{
"trackingId": "TMS-1001",
"status": "in_transit",
"carrier": "DHL",
"mode": "road",
"origin": "Berlin, DE",
"destination": "Munich, DE",
"riskScore": 42,
"riskLevel": "medium"
},
{
"trackingId": "TMS-1002",
"status": "delivered",
"carrier": "FedEx",
"mode": "air",
"origin": "London, UK",
"destination": "Paris, FR",
"riskScore": 15,
"riskLevel": "low"
}
]
}Shipment Schema:
| Field | Type | Required | Description |
|---|---|---|---|
trackingId |
string | โ | Unique tracking identifier |
status |
string | โ | pending, in_transit, delivered, delayed |
carrier |
string | โ | Carrier name (DHL, FedEx, UPS) |
mode |
string | โ | Transport mode: road, air, sea, rail |
origin |
string | โ | Origin location |
destination |
string | โ | Destination location |
riskScore |
number | โ | Risk score (0-100) |
riskLevel |
string | โ | low, medium, high (auto-calculated) |
Success Response:
{
"ok": true,
"written": 2,
"message": "Shipments processed successfully"
}Error Response:
{
"ok": false,
"error": "Invalid webhook secret"
}| Feature | Status |
|---|---|
| Real-time Firestore Subscriptions | โ Complete |
| Webhook Ingestion | โ Complete |
| Risk Analytics Dashboard | โ Complete |
| Trend Analysis (Firestore Aggregates) | โ Complete |
| Weather API Integration | โ Complete |
| News API Integration | โ Complete |
| Settings Persistence | โ Complete |
| Firebase Authentication | โ Complete |
| Multi-carrier Support | โ Complete |
| Session Timeout Controls | โ Complete |
| Route Intelligence Recommendations | โ Complete |
| Request Retry + Timeout Layer | โ Complete |
| Frontend Error Boundary | โ Complete |
| CI Workflows (Frontend + Backend) | โ Complete |
Error: Cannot find module 'firebase-admin'
Solution:
cd backend
npm installError: Invalid webhook secret
Solution:
- Verify
x-webhook-secretheader matchesWEBHOOK_SECRETinbackend/.env - Ensure secret is at least 32 characters
- Check for extra spaces or line breaks in the secret
Error: Missing or insufficient permissions
Solution:
- Check Firebase security rules
- Verify user is authenticated
- Ensure service account has Firestore read/write permissions
- Deploy the repository rules file:
firebase deploy --only firestore:rules
Error: Network Error or CORS error
Solution:
- Verify backend is running on port 8787
- Check
VITE_BACKEND_URL=http://localhost:8787in frontend.env - Verify
ALLOWED_ORIGINSinbackend/.envincludeshttp://localhost:5173
Error: 401 Unauthorized or 403 Forbidden
Solution:
- Verify API keys are correct in
backend/.env - Check API key restrictions in provider dashboards
- Ensure API usage limits haven't been exceeded
- Test API keys directly:
curl "https://api.openweathermap.org/data/2.5/weather?q=London&appid=YOUR_KEY"
- Machine learning-based risk prediction
- Advanced route optimization algorithms
- Mobile app for iOS and Android
- Email/SMS notification system
- Custom alert rules engine
- Multi-language support
- Shipment cost tracking and analytics
- Carrier performance benchmarking
- Export reports to PDF/Excel
- GraphQL API option
- Role-based access control (RBAC)
- Integration with more carrier APIs
- Geofencing and zone-based alerts
- Carbon footprint tracking
- ๐ Never commit credentials โ Keep
.envfiles out of version control - ๐ Service account protection โ Ensure
backend/service-account.jsonis gitignored - ๐ Rotate secrets regularly โ Update webhook secret every 90 days
- ๐ Use HTTPS in production โ Always use SSL/TLS certificates
- ๐ช Restrict CORS โ Limit
ALLOWED_ORIGINSto your frontend domain only - ๐ก๏ธ Firebase security rules โ Implement proper read/write restrictions
- ๐ Environment variables โ Use secret management in production (Railway, Render, etc.)
- ๐ซ API key restrictions โ Restrict keys by domain/IP in provider dashboards
-
.envandbackend/.envare in.gitignore - Service account JSON is not committed to repository
- Webhook secret is strong (48+ characters, generated cryptographically)
- CORS is restricted to frontend domain in production
- HTTPS is enabled for production deployment
- Firebase security rules enforce authentication
- API keys have domain/IP restrictions configured
- Rate limiting is enabled on webhook endpoint
This project is licensed under the MIT License.
See LICENSE for full terms.
LegendarySumit
- GitHub: @LegendarySumit
- Project Repository: ShipGuard AI
- Live Demo: Launch Platform
๐ข Revolutionizing Logistics with Real-time Intelligence
Built with React, Node.js, Firebase, and dedication to supply chain excellence
โญ Star this repo if you find it helpful!