Real-time ship tracking + whale risk detection + Gemini AI insights to prevent ship-whale collisions.
- Node.js 18+
- Python 3.8+
- MyShipTracking API key (Get one here)
- Google Gemini API key (Get one here)
Run the automated setup script to install all dependencies:
.\setup.batThis will:
- Install Node.js packages for backend & frontend
- Install Python dependencies for ML service
- Train the whale risk detection model
- Navigate to
backendfolder - Copy
.env.templateto.env:cd backend copy .env.template .env
- Edit
.envand add your API keys:MST_API_KEY=your_myshiptracking_key_here GEMINI_API_KEY=your_gemini_api_key_here
Run the startup script (uses fixed Python path for ML service):
.\start_fixed.ps1This will launch:
- π ML Service on
http://localhost:5002(Python Flask) - π’ Backend API on
http://localhost:5001(Node.js/Express) - π Frontend on
http://localhost:5173(React + Vite)
Navigate to http://localhost:5173 in your browser.
βββββββββββββββββββββββββββββββββββββββββββββββ
β Frontend (React + Leaflet + Gemini UI) β Port 5173
β - Interactive ship map β
β - Real-time vessel tracking β
β - AI safety briefings β
ββββββββββββββββββββ¬βββββββββββββββββββββββββββ
β
βββββββββββ΄ββββββββββ
βΌ βΌ
ββββββββββββββββββββ ββββββββββββββββββββ
β Backend API β β ML Service β
β (Node/TS) β β (Python/Flask) β
β Port 5001 β β Port 5002 β
β β β β
β β’ Ship tracking β β β’ Whale risk β
β β’ Gemini AI β β prediction β
β β’ Route calc β β β’ GBM classifier β
ββββββββββββββββββββ ββββββββββββββββββββ
β β
βΌ βΌ
ββββββββββββββββββββ ββββββββββββββββββββ
β MyShipTracking β β OBIS Whale Data β
β AIS API β β (trained model) β
ββββββββββββββββββββ ββββββββββββββββββββ
- Search vessels by name (e.g., "EVER GIVEN")
- View ships near your location or in bounding box
- Query ships in specific ports
- Live AIS position updates
- Predicts whale presence risk: HIGH / MEDIUM / LOW
- Trained on OBIS-SEAMAP whale sighting dataset
- Features: latitude, longitude, month (seasonal patterns)
- ~85-90% accuracy
- Visual Analysis: AI sees the map screenshot (html2canvas)
- Context-Aware: Integrates vessel data, track history, whale risk
- Natural Language: Bridge crew briefings with actionable recommendations
- Markdown Rendering: Beautiful formatted output
Ship Tracking:
GET /api/vessels/search/:name- Search vesselsGET /api/vessels/status/:mmsi- Current position (extended AIS data)GET /api/vessels/track/:mmsi?days=1- Historical trackGET /api/vessels/status/:mmsi/whale-risk- Position + risk
AI Insights:
POST /api/gemini/insight- Generate Gemini safety briefing{ "ship": { "lat": 35.2, "lon": 139.5, "mmsi": "311918000", ... }, "track": [...], "question": "What should the bridge team know?", "mapSnapshot": { "dataUrl": "data:image/png;base64,...", "mimeType": "image/png" } }
Whale Risk:
POST /api/whale-risk- Get risk for coordinates
POST /api/whale-risk- Risk prediction{ "latitude": 40.7, "longitude": -74.0, "month": 11 }
Algorithm: Gradient Boosting Classifier
Features: Latitude, Longitude, Month
Training Data: OBIS-SEAMAP whale sightings + synthetic migration patterns
Risk Thresholds:
- π΄ HIGH (>60%): Reduce speed to <10 knots, post whale watch
- π‘ MEDIUM (30-60%): Exercise caution, brief crew
- π’ LOW (<30%): Standard protocols
Model Files:
ml/whale_risk_model.pkl- Trained classifierml/train_whale_model.py- Training scriptml/whale_predictor.py- Standalone predictor
PORT=5001
MST_API_KEY=your_myshiptracking_api_key
MST_CACHE_TTL_MS=30000
MST_DEFAULT_MINUTES_BACK=60
GEMINI_API_KEY=your_google_gemini_api_key
GEMINI_MODEL=gemini-2.0-flash-liteNo configuration needed (port 5002 hardcoded).
/
βββ backend/ # Node.js/TypeScript API
β βββ src/
β β βββ classes/server.ts # Express routes
β β βββ services/
β β β βββ mstClient.ts # MyShipTracking client
β β β βββ whaleRiskService.ts
β β β βββ geminiService.ts # Gemini AI integration
β β βββ index.ts
β βββ .env.template
β βββ package.json
β
βββ frontend/ # React + Vite
β βββ src/
β β βββ components/ShipMap.tsx # Main map UI
β β βββ App.css # Styling
β β βββ main.tsx
β βββ package.json
β
βββ ml/ # Python Flask ML service
β βββ api.py # Flask server
β βββ train_whale_model.py # Model training
β βββ whale_predictor.py # Inference script
β βββ whale_risk_model.pkl # Trained model
β βββ requirements.txt
β
βββ setup.bat # Dependency installer
βββ start_fixed.ps1 # Startup script (all services)
βββ README.md
cd ml
python train_whale_model.pyBackend:
cd backend
npm startML Service:
cd ml
python api.pyFrontend:
cd frontend
npm run dev- Frontend: React, TypeScript, Leaflet, Vite, html2canvas, react-icons, marked
- Backend: Node.js, Express, TypeScript, Axios, @google/generative-ai
- ML: Python, Flask, scikit-learn, pandas, numpy
- Data: MyShipTracking API (AIS), OBIS-SEAMAP (whale sightings)
This project targets:
- β Best Use of Gemini API - Multimodal safety briefings with map visual analysis
- β Best UI/UX - Professional maritime dashboard with real-time updates
- β Most Creative Use of AI - Combining ML whale detection + Gemini contextual insights
MIT License - Hackathon project for marine conservation.