File size: 11,603 Bytes
f0bfaf0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2443db5
f0bfaf0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2443db5
 
f0bfaf0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
# πŸ›‘οΈ Aegis β€” Autonomous Enterprise Crisis Management

> **AMD Developer Hackathon 2026** | Track 1: AI Agents & Agentic Workflows

[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
[![Python](https://img.shields.io/badge/Python-3.11-blue.svg)](https://python.org)
[![FastAPI](https://img.shields.io/badge/FastAPI-0.110-green.svg)](https://fastapi.tiangolo.com)
[![Groq](https://img.shields.io/badge/LLM-Groq%20LLaMA%203.3%2070B-orange.svg)](https://groq.com)
[![AMD](https://img.shields.io/badge/GPU-AMD%20Instinct%20MI300X-red.svg)](https://amd.com)
[![ROCm](https://img.shields.io/badge/ROCm-6.2-red.svg)](https://rocm.docs.amd.com)

**Aegis** is a fully autonomous 7-agent AI system that monitors global supply chain risks in real time, scrapes live maritime shipping intelligence, predicts disruptions using a hybrid ML forecasting model, and autonomously executes crisis response decisions β€” before humans can react.

> *"Aegis protects enterprises from global disruptions by turning real-time chaos into autonomous decisions."*

---

## 🎬 Live Demo

| | |
|---|---|
| **Live App** | http://YOUR_AMD_INSTANCE_IP:8000 |
| **Demo Video** | https://youtu.be/w_jquBRuLkA |
| **API Docs** | http://YOUR_AMD_INSTANCE_IP:8000/docs |
| **GitHub** | https://github.com/Benny-Tang/aegis |

---

## 🌍 Real-World Relevance

Aegis was built as the **Strait of Hormuz crisis unfolded in real time** (2026). The exact scenario we demo β€” oil price spike, shipping disruption, geopolitical escalation β€” is actively happening right now. Our live MarineTraffic scraper pulls **real headlines** like:

- *"Trump's Hormuz Blockade Has Deepened A Historic Shipping Crisis"*
- *"Strait of Hormuz Remains Near-Empty With Just A Few Iran Ships Moving"*
- *"Iran War Leaves Seafarers Stranded In The Gulf"*
- *"US Says Navy Intercepted Iran-Linked Vessel in Arabian Sea"*

**Aegis responds to this real crisis autonomously in 2 seconds.**

---

## 🧠 How It Works

When a crisis event is detected, Aegis activates a chain of 7 specialized AI agents that observe, think, predict, simulate, decide, alert and act β€” autonomously.

```
Crisis Event Detected
        β”‚
        β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                AEGIS 7-AGENT PIPELINE               β”‚
β”‚                                                     β”‚
β”‚  πŸ“‘ Signal Agent      β†’ Detects anomalies +         β”‚
β”‚                          scrapes live MarineTraffic  β”‚
β”‚  🧠 Intelligence Agent β†’ Interprets risk context    β”‚
β”‚  πŸ“ˆ Forecast Agent    β†’ ARIMA + XGBoost prediction  β”‚
β”‚  🧩 Simulation Agent  β†’ Runs what-if scenarios      β”‚
β”‚  ⚑ Decision Agent    β†’ Ranks action plan           β”‚
β”‚  🚨 Alert Agent       β†’ Dispatches notifications    β”‚
β”‚  πŸ”„ Execution Agent   β†’ Triggers workflows          β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
        β”‚
        β–Ό
  Autonomous Response in ~2 seconds
  ($1.7M savings identified per crisis event)
```

---

## 🚒 Live MarineTraffic Intelligence

Aegis scrapes **real-time shipping intelligence** from multiple maritime sources on every crisis trigger:

| Source | Type | Status |
|--------|------|--------|
| gCaptain | Maritime news | βœ… Live |
| TradeWinds | Shipping intelligence | βœ… Live |
| MarineTraffic Blog | Vessel tracking news | ⚠️ Partial |
| Reuters | Geopolitical news | ⚠️ Auth required |

The Signal Agent automatically enriches every crisis analysis with live shipping alerts β€” tanker reroutes, port closures, war risk insurance changes, navy intercepts.

**Tested live β€” 8 real shipping intelligence items scraped in a single run with 95% CRITICAL confidence classification by Groq LLaMA 3.3 70B.**

---

## βš™οΈ Tech Stack

| Layer | Technology |
|-------|-----------|
| **LLM** | Groq β€” LLaMA 3.3 70B Versatile |
| **ML Forecast** | XGBoost 2.0 + ARIMA(2,1,2) hybrid ensemble |
| **Marine Intelligence** | MarineTraffic + gCaptain + TradeWinds scraper |
| **GPU Acceleration** | AMD Instinct MI300X via ROCm 6.2 |
| **API** | FastAPI + Uvicorn + Gunicorn (4 workers) |
| **Streaming** | Server-Sent Events (SSE) β€” live agent updates |
| **Deployment** | AMD Developer Cloud (amd.digitalocean.com) |
| **Frontend** | Vanilla JS + CSS β€” dark terminal aesthetic |
| **Auto-Monitor** | Autonomous scan every 5 minutes 24/7 |

---

## πŸš€ Quick Start

### Option A β€” Google Colab (easiest)
1. Open `Aegis_Hackathon.ipynb` in Google Colab
2. Fill in your `GROQ_API_KEY` and `NGROK_TOKEN` in Cell 1
3. Click **Runtime β†’ Run All**
4. Copy the ngrok URL printed at the bottom

### Option B β€” AMD Developer Cloud (production)
```bash
# 1. SSH into your AMD MI300X instance
ssh -i your-key.ppk root@YOUR_AMD_IP

# 2. Set your Groq API key
export GROQ_API_KEY=gsk_YOUR_KEY_HERE

# 3. Install packages
pip3 install fastapi "uvicorn[standard]" groq httpx pydantic \
    numpy pandas scikit-learn xgboost statsmodels \
    python-multipart aiofiles gunicorn \
    requests beautifulsoup4 lxml

# 4. Create project folders
mkdir -p /opt/aegis/agents /opt/aegis/models /opt/aegis/api /opt/aegis/logs

# 5. Upload project files and start
cd /opt/aegis && gunicorn api.server:app \
    --workers 4 \
    --worker-class uvicorn.workers.UvicornWorker \
    --bind 0.0.0.0:8000 \
    --timeout 120 \
    --daemon

# 6. Open in browser
http://YOUR_AMD_IP:8000
```

---

## πŸ“ Project Structure

```
aegis/
β”œβ”€β”€ agents/
β”‚   └── swarm.py              # 7 Groq-powered autonomous agents
β”‚                             # + MarineTraffic live scraper
β”œβ”€β”€ models/
β”‚   └── forecaster.py         # ARIMA + XGBoost hybrid ML model
β”œβ”€β”€ api/
β”‚   └── server.py             # FastAPI + SSE streaming server
β”œβ”€β”€ frontend.html             # Live dashboard β€” dark terminal UI
β”œβ”€β”€ Aegis_Hackathon.ipynb     # Google Colab notebook
β”œβ”€β”€ requirements.txt          # Python dependencies
└── LICENSE                   # MIT License
```

---

## πŸ€– The 7 Agents

### 1. πŸ“‘ Signal Agent (Watcher)
Monitors real-time feeds β€” oil prices, shipping routes, geopolitical news. **Automatically scrapes live MarineTraffic, gCaptain and TradeWinds shipping intelligence on every trigger.** Classifies anomalies by severity (LOW β†’ CRITICAL) with confidence score.

### 2. 🧠 Intelligence Agent (Interpreter)
Uses LLaMA 3.3 70B to convert raw signals and marine data into structured risk context. Identifies root causes, affected regions, and escalation probability.

### 3. πŸ“ˆ Forecast Agent (Predictor)
Runs a **hybrid ARIMA(2,1,2) + XGBoost ensemble** model to predict oil prices, logistics delays, and cost impact over a 14-day horizon. XGBoost runs on AMD MI300X GPU via ROCm for accelerated inference.

### 4. 🧩 Simulation Agent (Strategist)
Generates 3 weighted what-if scenarios (best case, base case, worst case) with probability weights and cost impact estimates for each.

### 5. ⚑ Decision Agent (Brain)
Synthesizes all upstream intelligence into a ranked action plan with dollar savings estimates, implementation timelines, and risk ratings.

### 6. 🚨 Alert Agent (Communicator)
Formats and dispatches real-time notifications to Slack, email, and live dashboard. Generates executive summaries for C-suite stakeholders.

### 7. πŸ”„ Execution Agent (Operator)
Triggers downstream enterprise workflows autonomously β€” ERP supplier switches, procurement API calls, logistics rerouting.

---

## πŸ“Š ML Forecasting Model

**Why ARIMA + XGBoost hybrid?**

| Component | Role | Weight (crisis) |
|-----------|------|-----------------|
| ARIMA(2,1,2) | Linear trend + autocorrelation | 30% |
| XGBoost (ROCm GPU) | Non-linear geopolitical signals | 70% |

**Features engineered:** lag-1, lag-3, lag-7, lag-14, rolling mean/std (7 & 14 day), 3-day % change, day-of-week

**AMD MI300X advantage:** XGBoost tree building runs 8–15x faster on MI300X vs CPU via ROCm CUDA compatibility layer.

---

## πŸ”Œ API Reference

| Method | Endpoint | Description |
|--------|----------|-------------|
| `GET` | `/` | Live dashboard |
| `GET` | `/health` | System health check |
| `GET` | `/docs` | Swagger UI |
| `POST` | `/api/crisis` | Full 7-agent pipeline (JSON) |
| `GET` | `/api/stream` | SSE live agent stream |
| `POST` | `/api/forecast` | ML forecast only |
| `GET` | `/api/marine` | Live MarineTraffic shipping feed |
| `GET` | `/api/status` | Live system status |

### Example β€” trigger crisis
```bash
curl -X POST http://YOUR_IP:8000/api/crisis \
  -H "Content-Type: application/json" \
  -d '{
    "oil_price_change_pct": 18.0,
    "shipping_disruption": "Strait of Hormuz β€” 3 tankers rerouted",
    "news_headline": "Regional conflict escalation near Persian Gulf",
    "severity": "HIGH",
    "disruption_factor": 0.7,
    "horizon_days": 14
  }'
```

### Example β€” get live marine intelligence
```bash
curl http://YOUR_IP:8000/api/marine
```

### Example β€” SSE stream
```javascript
const es = new EventSource('http://YOUR_IP:8000/api/stream?oil_change=18&disruption=0.7');
es.onmessage = (e) => {
  const msg = JSON.parse(e.data);
  console.log(msg.type, msg.agent, msg.data);
};
```

---

## πŸ’‘ Business Value

Aegis addresses a **$1.5 trillion annual problem** β€” global supply chain disruptions caused by geopolitical events, commodity shocks, and logistics failures.

**Key metrics from live demo (Strait of Hormuz crisis):**

| Metric | Value |
|--------|-------|
| Pipeline response time | **2 seconds** |
| Agents active simultaneously | **7 / 7** |
| Savings identified | **$1.7M per crisis** |
| Logistics delay risk detected | **45.8%** |
| Oil price forecast accuracy | ARIMA+XGBoost hybrid |
| Marine intelligence items | **8 live headlines** |
| Auto-monitoring interval | **Every 5 minutes** |
| Concurrent viewers supported | **Unlimited** |

---

## πŸ”₯ Auto-Monitoring β€” 24/7 Autonomous Operation

Aegis doesn't wait for humans. It monitors global signals **every 5 minutes autonomously**:

- Fetches live oil price from status API
- Detects anomalies automatically
- Triggers full 7-agent pipeline when risk threshold exceeded
- Dashboard shows live countdown timer to next scan
- Zero human intervention required in production mode

---

## πŸ—οΈ AMD Developer Cloud Deployment

```bash
# Verify MI300X is available
rocm-smi

# Check server health
curl http://localhost:8000/health

# View live marine intelligence
curl http://localhost:8000/api/marine

# Monitor logs
tail -f /opt/aegis/logs/error.log
```

---

## πŸ“‹ Environment Variables

| Variable | Required | Description |
|----------|----------|-------------|
| `GROQ_API_KEY` | βœ… Yes | Get free at console.groq.com |
| `NGROK_TOKEN` | Colab only | Get free at ngrok.com |

---

## πŸ™ Acknowledgements

- **AMD** β€” MI300X GPU access via AMD Developer Cloud
- **Groq** β€” Ultra-fast LLaMA 3.3 70B inference
- **lablab.ai** β€” Hackathon platform and community
- **gCaptain** β€” Live maritime news intelligence
- **TradeWinds** β€” Live shipping intelligence
- **FastAPI** β€” Production API framework
- **XGBoost** β€” GPU-accelerated gradient boosting

---

## πŸ“„ License

MIT License β€” see [LICENSE](LICENSE) for details.

---

*Built with ❀️ for the AMD Developer Hackathon 2026*

*πŸ›‘οΈ SHIELD AGAINST CHAOS*