neil-data/Chain-guard-hackathon-

GitHub: neil-data/Chain-guard-hackathon-

一个基于 AI 的海事供应链风险预测与航线优化平台,能实时抓取多源新闻、量化航线威胁评分并在两秒内生成替代航线与战术简报。

Stars: 0 | Forks: 0



``` ██████╗██╗ ██╗ █████╗ ██╗███╗ ██╗ ██████╗ ██╗ ██╗ █████╗ ██████╗ ██████╗ ██╔════╝██║ ██║██╔══██╗██║████╗ ██║██╔════╝ ██║ ██║██╔══██╗██╔══██╗██╔══██╗ ██║ ███████║███████║██║██╔██╗ ██║██║ ███╗██║ ██║███████║██████╔╝██║ ██║ ██║ ██╔══██║██╔══██║██║██║╚██╗██║██║ ██║██║ ██║██╔══██║██╔══██╗██║ ██║ ╚██████╗██║ ██║██║ ██║██║██║ ╚████║╚██████╔╝╚██████╔╝██║ ██║██║ ██║██████╔╝ ╚═════╝╚═╝ ╚═╝╚═╝ ╚═╝╚═╝╚═╝ ╚═══╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚═════╝ ``` ### 🚢 AI 驱动的海事供应链智能平台 **预测风险。即时重定向。在干扰发生前抢占先机。** [![Next.js](https://img.shields.io/badge/Next.js-15-black?style=flat-square&logo=next.js)](https://nextjs.org) [![Python](https://img.shields.io/badge/Python-3.11-3776AB?style=flat-square&logo=python&logoColor=white)](https://python.org) [![Firebase](https://img.shields.io/badge/Firebase-Auth-FF6B00?style=flat-square&logo=firebase&logoColor=white)](https://firebase.google.com) [![Gemini](https://img.shields.io/badge/Gemini-1.5_Flash-4285F4?style=flat-square&logo=google&logoColor=white)](https://ai.google.dev) [![XGBoost](https://img.shields.io/badge/XGBoost-R²_0.9691-1D9E75?style=flat-square)](https://xgboost.readthedocs.io) [![License](https://img.shields.io/badge/License-MIT-1D9E75?style=flat-square)](LICENSE)
[🌊 在线演示](#) · [📖 文档](#architecture) · [🚀 快速开始](#quick-start) · [👥 团队](#team)
## 🌊 问题背景 海运承担着 **全球 80% 以上的贸易量** —— 每年价值高达 **14 万亿美元**。然而,当干扰发生时: ``` ⚓ Piracy in Gulf of Aden → Ships reroute manually (hours lost) 🔥 Sanctions on Strait of Hormuz → No real-time intelligence 🌪️ Extreme weather events → Cargo delayed, millions lost ⚔️ Geopolitical conflicts → Operators flying blind ``` **现有的解决方案是被动的。ChainGuard 使其变得主动。** ## ⚡ ChainGuard 的功能 ``` 📡 Live RSS Feeds (6 sources, every 30min) ↓ 🔍 NLP Threat Verification Engine ↓ 🤖 XGBoost Risk Scoring (16 features, R²=0.9691) ↓ 🗺️ Yen's K-Shortest Path (3 optimal routes) ↓ ✨ Gemini AI Captain's Briefing (<2 seconds) ``` ## 🎯 核心功能
### 🛡️ 预测性风险评分 在跨越 **16 个特征** 的 **3,000 条合成路线** 上训练的 XGBoost 模型 —— 涵盖天气、地缘政治信号、咽喉要道风险、海盗区和制裁数据。 **R² = 0.9691** —— 达到生产级别的准确度。 ### 📰 新闻验证引擎 每 30 分钟抓取 **6 个实时海事 RSS 订阅源**: - Reuters, BBC, gCaptain - Maritime Executive - Splash247, IMB Piracy Bureau 综合置信度:**Ψ(a) = 0.30·T(s) + 0.25·τ(t) + 0.20·G(a) + 0.25·C**
### 🗺️ AI 路线优化 **Yen's K-Shortest** 算法可在毫秒内计算出 **3 条备选路线**。每条路径的权重依据: - α=0.60 威胁严重程度 - β=0.25 距离 - γ=0.15 天气风险 ### 🤖 Gemini 战术简报 **Gemini 1.5 Flash** 可生成机密的船长简报,包含: - 威胁摘要 - 天气评估 - 路线建议 - 风险缓解措施 全部在 **2 秒内** 完成。
### 📊 SHAP 值洞察 可解释性 AI —— 准确了解 **为什么** 某条路线被标记为高风险。特征级别的归因分析展示了是哪些信号影响了评分。 ### 🔐 Firebase 身份验证 安全的多提供商身份验证: - 电子邮箱/密码 - Google OAuth - GitHub OAuth 为海事官员提供基于角色的访问控制。
## 🏗️ 系统架构 ``` ┌─────────────────────────────────────────────────────────────┐ │ CHAINGUARD v4.0 │ ├─────────────────────┬───────────────────────────────────────┤ │ FRONTEND │ BACKEND │ │ (Next.js 15) │ (Python/FastAPI) │ │ │ │ │ ┌─────────────┐ │ ┌──────────────────────────────┐ │ │ │ Firebase │ │ │ News Ingestion Pipeline │ │ │ │ Auth │ │ │ 6 RSS feeds × 30min cycle │ │ │ └─────────────┘ │ └──────────────┬───────────────┘ │ │ │ ↓ │ │ ┌─────────────┐ │ ┌──────────────────────────────┐ │ │ │ Gemini │◄───┼────│ NLP Verification Engine │ │ │ │ Briefings │ │ │ Ψ(a) confidence scoring │ │ │ └─────────────┘ │ └──────────────┬───────────────┘ │ │ │ ↓ │ │ ┌─────────────┐ │ ┌──────────────────────────────┐ │ │ │ Route Map │◄───┼────│ XGBoost Risk Model │ │ │ │ Dashboard │ │ │ R² = 0.9691, 16 features │ │ │ └─────────────┘ │ └──────────────┬───────────────┘ │ │ │ ↓ │ │ ┌─────────────┐ │ ┌──────────────────────────────┐ │ │ │ Threat │◄───┼────│ Yen's K-Shortest Path │ │ │ │ Intel │ │ │ 3 optimal routes computed │ │ │ └─────────────┘ │ └──────────────────────────────┘ │ └─────────────────────┴───────────────────────────────────────┘ ``` ## 🛠️ 技术栈 | 层级 | 技术 | 用途 | |-------|-----------|---------| | **前端** | Next.js 15, TypeScript, Tailwind CSS | UI 与路由 | | **身份验证** | Firebase Authentication | 电子邮箱, Google, GitHub OAuth | | **AI 简报** | Google Gemini 1.5 Flash | 船长战术简报 | | **ML 模型** | XGBoost, scikit-learn | 风险评分 (R²=0.9691) | | **路径规划** | Yen's K-Shortest Path | 备选路线计算 | | **NLP** | 自定义验证引擎 | 威胁置信度评分 | | **数据** | 6 个实时 RSS 订阅源 | 实时海事情报 | | **后端** | Python, FastAPI | 风险引擎 API | | **可视化** | Three.js Globe, Google Maps | 路线可视化 | ## 🚀 快速开始 ### 前置条件 ``` Node.js 18+ # Frontend Python 3.11+ # Backend ``` ### 1. 克隆代码库 ``` git clone https://github.com/neil-data/Chain-guard-hackathon-.git cd Chain-guard-hackathon- ``` ### 2. 前端设置 ``` cd frontends npm install cp .env.example .env.local # 在 .env.local 中填入你的 keys npm run dev ``` ### 3. 后端设置 ``` cd chainguard python -m venv .venv .venv\Scripts\activate # Windows # source .venv/bin/activate # Mac/Linux pip install -r requirements.txt python app.py ``` ### 4. 环境变量 将 `.env.example` 复制到 `.env.local` 并填写: ``` # Firebase (从 console.firebase.google.com 获取) NEXT_PUBLIC_FIREBASE_API_KEY= NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN= NEXT_PUBLIC_FIREBASE_PROJECT_ID= NEXT_PUBLIC_FIREBASE_APP_ID= # Firebase Admin (仅限 server-side) FIREBASE_ADMIN_PROJECT_ID= FIREBASE_ADMIN_CLIENT_EMAIL= FIREBASE_ADMIN_PRIVATE_KEY= # Google Gemini (从 aistudio.google.com 获取) GEMINI_API_KEY= # Backend NEXT_PUBLIC_API_URL=http://localhost:8000 ``` ### 5. 在浏览器中打开 ``` Frontend: http://localhost:3000 Backend: http://localhost:8000 ``` ## 📊 性能指标
| 指标 | 数值 | |--------|-------| | 🎯 预测准确度 | **94.3%** | | ⚡ AI 响应时间 | **< 2 秒** | | 🗺️ 监控中的活跃路线 | **50+** | | 🔄 重定向速度 | 比手动操作 **快 3 倍** | | 📰 新闻来源 | **6 个实时订阅源** | | 🔍 模型 R² 分数 | **0.9691** | | 🛣️ 每次分析的路线数 | **3 条备选路线** | | ⏱️ 订阅源抓取间隔 | **每 30 分钟** |
## 🌍 联合国可持续发展目标对齐
**SDG 9 —— 产业、创新和基础设施** ChainGuard 通过用 AI 驱动的主动决策取代手动、被动的路线规划,实现了关键海事物流基础设施的现代化 —— 将干扰响应时间从数小时缩短至 2 秒以内。 **SDG 17 —— 促进目标实现的伙伴关系** 通过保护全球贸易走廊,ChainGuard 为发展中经济体依赖进出口和经济增长的航运路线提供了更安全、更可靠的保障。
## 📁 项目结构 ``` Chain-guard-hackathon-/ ├── 📂 frontends/ # Next.js frontend │ ├── 📂 app/ │ │ ├── 📂 (auth)/ # Login, register pages │ │ ├── 📂 (dashboard)/ # Dashboard, analyzer, threats │ │ ├── 📂 api/ # API routes (Gemini, analyze) │ │ ├── globals.css │ │ └── layout.tsx │ ├── 📂 components/ │ │ ├── 📂 landing/ # Hero, Footer, HowItWorks │ │ └── 📂 ui/ # Globe3D, DynamicGlobe │ ├── 📂 lib/ │ │ ├── firebase.ts # Firebase client config │ │ ├── firebase-admin.ts # Firebase admin (server) │ │ └── auth-context.tsx # Global auth state │ ├── middleware.ts # Route protection │ ├── .env.example # Environment template │ └── package.json │ ├── 📂 chainguard/ # Python backend │ ├── app.py # FastAPI risk engine │ └── requirements.txt │ ├── .gitignore └── README.md ``` ## 🔒 安全性 - ✅ 所有 API 密钥均存储在服务器端的 `.env.local` 中 —— 绝不暴露给前端 - ✅ Firebase Admin SDK 用于服务器端 token 验证 - ✅ 通过 Next.js 中间件进行路由保护 - ✅ `.env.local` 已排除在版本控制之外 - ✅ 强制执行 Firebase 安全规则 ## 👥 团队
为 **Google Solution Challenge 2026** 用 ❤️ 构建 | 成员 | 角色 | |--------|------| | Neil Banerjee | 全栈与测试 | | Yash Vania | 后端与数据管道 | | Manthan Balani | AI 与 NLP 工程 | | Shrey gohil | UI/UX 与前端 |
## 📄 许可证 本项目基于 MIT 许可证授权 —— 详见 [LICENSE](LICENSE) 文件。
**为 Google Solution Challenge 2026 而构建** *"预测风险。韧性供应链。"* 如果 ChainGuard 帮助你学到了新知识,请给本仓库点个 ⭐!
标签:AI预测, CISA项目, Firebase, Google Solution Challenge 2026, Next.js 15, Python 3.11, 人工智能, 供应链智能平台, 实时威胁检测, 实时数据处理, 智能导航, 智能改道, 海上运输, 海事供应链, 物流风险管控, 用户模式Hook绕过, 网络物理系统, 自动化攻击, 航运安全, 航运路线风险, 路径规划, 逆向工具