Dhruva P Gowda commited on
Commit
dab38d3
·
1 Parent(s): f59a149

Update README with detailed project overview and roadmap

Browse files
Files changed (1) hide show
  1. README.md +426 -63
README.md CHANGED
@@ -1,103 +1,466 @@
1
- # ShockMap Intelligence Platform
2
- ### *National Supply Chain Security & Disruption Command Center*
3
 
4
- **ShockMap** is a high-fidelity geospatial intelligence platform designed to secure India's critical import dependencies (Pharma APIs & Rare Earth Minerals). Built for the **Google Solution Challenge 2026**, it transforms unstructured global disruption signals into actionable procurement intelligence.
 
 
 
 
 
 
 
 
5
 
6
  ---
7
 
8
- ## ⚡ The 3-Engine Architecture
9
 
10
- ShockMap operates on a proprietary triple-engine workflow that bridges the gap between news and action:
11
 
12
- 1. **Engine 1: Signal Intelligence (NER & Extraction)**
13
- * Autonomous scanning of global trade news, policy shifts, and port telemetry via GDELT.
14
- * Entity extraction identifies provinces (e.g., Hebei), sectors (Pharma), and event types (Export Ban).
15
 
16
- 2. **Engine 2: Propagation Intelligence (Graph Theory)**
17
- * Models the supply chain as a complex network of 60+ nodes and 70+ corridors.
18
- * Uses **Personalized PageRank** and **Louvain Community Detection** to calculate how a factory shutdown in China ripples through Indian manufacturing states.
19
 
20
- 3. **Engine 3: Action Intelligence (Grounded RAG)**
21
- * Powered by **Gemini 2.0 Flash**.
22
- * Generates specific 72-hour action plans (e.g., "Secure 18 MT of PAP from SE Asia") grounded in NLEM policy and real-time telemetry.
23
 
24
  ---
25
 
26
- ## 🚀 Key Features (The "WOW" Factors)
 
 
 
 
 
 
 
 
 
 
 
 
27
 
28
- * **Geospatial Risk Heatmap**: Real-time visualization of supply nodes in China and absorption nodes in India.
29
- * **Animated Propagation Graph**: WebGL-rendered supply network featuring **live particle flow** on disrupted corridors and **ripple-effect** shock simulations.
30
- * **War Room Command Center**: Cinematic incident detail pages with stockout countdowns and multi-path response simulators.
31
- * **AI Operator Analyst**: Natural language interface with streaming typewriter responses and evidence-backed citations.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
 
33
  ---
34
 
35
- ## 🛠️ Technical Stack
36
 
37
- * **Frontend**: React 19, Vite, Leaflet (Geospatial), Sigma.js (WebGL Graph), Framer Motion.
38
- * **Backend**: FastAPI, Pydantic v2, Python 3.11.
39
- * **Intelligence**: Gemini 2.0 Flash (Action Gen), NetworkX (Propagation), GDELT (Live Signal Intake).
40
- * **Geocoding**: Google Maps Platform (Primary) + Nominatim (Fallback).
 
 
 
 
 
41
 
42
  ---
43
 
44
- ## 🌍 Deployment Guide
 
 
 
45
 
46
- ShockMap is production-ready and optimized for high-performance edge deployment.
 
47
 
48
- ### 1. Backend (Render)
49
- * **Service Type**: Docker (Web + Background Worker)
50
- * **Config**: Uses `render.yaml` for automatic infrastructure provisioning.
51
- * **Environment**:
52
- * `GEMINI_API_KEY`: Required for Engine 3.
53
- * `GOOGLE_MAPS_API_KEY`: Required for Geospatial Intel.
54
- * `PORT`: 8080
 
 
55
 
56
- ### 2. Frontend (Netlify / Vercel)
57
- * **Build Command**: `npm run build`
58
- * **Publish Directory**: `dist`
59
- * **Environment**:
60
- * `VITE_BACKEND_URL`: Points to your deployed Render API.
61
- * `VITE_GOOGLE_MAPS_API_KEY`: Client-side map rendering key.
 
 
62
 
63
  ---
64
 
65
- ## 💻 Local Development
66
 
67
- ### Prerequisites
68
- * Node.js 20+
69
- * Python 3.11+
70
- * Google Maps API Key
71
- * Gemini API Key
72
 
73
- ### Installation
74
- ```bash
75
- # Clone the repository
76
- git clone https://github.com/dhruva137/pharmashield.git
77
- cd pharmashield
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
78
 
79
- # Start Backend
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
80
  cd backend
 
 
81
  pip install -r requirements.txt
82
- uvicorn app.main:app --host 0.0.0.0 --port 8080 --reload
 
 
 
 
 
 
83
 
84
- # Start Frontend
85
- cd ../frontend
 
86
  npm install
87
  npm run dev
88
  ```
89
 
 
 
 
 
 
 
 
 
90
  ---
91
 
92
- ## 📊 MVP Coverage
93
- * **20+** Essential Medicines (NLEM)
94
- * **25+** Critical Pharma APIs
95
- * **8** Strategic Rare Earth Minerals
96
- * **52** International Supply Corridors
97
- * **15** Indian Manufacturing States
 
 
 
 
98
 
99
  ---
100
 
101
- ### Google Solution Challenge 2026
102
- *Developed by Dhruva P Gowda*
103
- *MIT License*
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # ShockMap
 
2
 
3
+ **Real-time supply shock intelligence for India's critical import dependencies**
4
+
5
+ ShockMap is an operator-facing intelligence platform built for the Google Solution Challenge 2026. It turns weak early signals from trade, news, and policy sources into a clear operational workflow:
6
+
7
+ **detect -> assess -> decide -> act**
8
+
9
+ The product is designed around a simple mission:
10
+
11
+ > When a disruption hits an upstream source region, show Indian operators what is at risk, how the shock propagates, and what action changes the outcome in the next 72 hours.
12
 
13
  ---
14
 
15
+ ## Why ShockMap
16
 
17
+ India depends heavily on external supply chains for critical industrial and health-system inputs. In the MVP, ShockMap focuses on two high-impact sectors:
18
 
19
+ - **Pharma**: essential medicines, APIs, intermediates, and upstream source regions
20
+ - **Rare earths**: strategically important minerals used in EV, electronics, and advanced industry
 
21
 
22
+ The core problem is not a lack of information. It is a lack of **early, structured, decision-ready intelligence**.
 
 
23
 
24
+ ShockMap closes that gap by combining live signal intake, graph-based propagation, and grounded action generation in one operator workflow.
 
 
25
 
26
  ---
27
 
28
+ ## What the MVP Delivers
29
+
30
+ The current MVP is built around a complete incident-response loop.
31
+
32
+ ### 1. Live shock feed
33
+ - Ingests disruption signals into a structured shock feed
34
+ - Tracks event type, province/region, sector, severity, source, and affected entities
35
+ - Supports a **hybrid live + curated scenario mode** for reliable demos and consistent walkthroughs
36
+
37
+ ### 2. Shock propagation engine
38
+ - Models upstream-to-downstream impact through a supply graph
39
+ - Uses **NetworkX**, **Louvain communities**, and **Personalized PageRank**
40
+ - Produces ranked affected nodes with risk, buffer pressure, substitutability, and cluster context
41
 
42
+ ### 3. War room for every shock
43
+ - Each shock opens into a decision surface, not just an alert
44
+ - Surfaces:
45
+ - aggregate risk
46
+ - days to stockout
47
+ - exposure estimate
48
+ - top affected inputs
49
+ - source evidence
50
+ - recommended actions
51
+
52
+ ### 4. Action delta simulator
53
+ - Lets the operator run response actions against a live scenario
54
+ - Shows before/after impact such as:
55
+ - risk reduction
56
+ - stockout extension
57
+ - exposure change
58
+
59
+ ### 5. Grounded operator analyst
60
+ - Natural-language query interface backed by Gemini Flash
61
+ - Returns concise answers, citations, matched scenarios, and suggested entities to inspect next
62
+ - Uses schema-constrained outputs, short timeouts, retrieval merging, and deterministic degradation
63
+
64
+ ### 6. Graph explorer
65
+ - Interactive graph view for provinces, APIs, inputs, and downstream drugs
66
+ - Highlights dependency corridors and the currently selected node's upstream/downstream links
67
+ - Exposes state-level aggregate risk at a glance
68
 
69
  ---
70
 
71
+ ## Current MVP Coverage
72
 
73
+ | Area | MVP Coverage |
74
+ |---|---|
75
+ | Essential medicines | 20 tracked medicines |
76
+ | Pharma APIs | 25 API records in seed data |
77
+ | Rare earth minerals | 8 critical minerals |
78
+ | Live shock feed | `data/shocks.json` + curated scenario pack |
79
+ | Graph mode | PageRank + Louvain production path |
80
+ | Action intelligence | Grounded Flash-based plans with deterministic action output |
81
+ | UI surfaces | Dashboard, Alerts, Shock Detail, War Room, Graph, Query |
82
 
83
  ---
84
 
85
+ ## Product Experience
86
+
87
+ ### Dashboard
88
+ The dashboard gives operators an immediate view of active shocks, sector activity, feed mode, and system status.
89
 
90
+ ### Alerts
91
+ The alerts surface is the real-time event feed for live shocks and scenario-backed incidents.
92
 
93
+ ### Shock Detail / War Room
94
+ This is the core MVP experience. A single incident page brings together:
95
+ - shock summary
96
+ - severity
97
+ - top exposed inputs
98
+ - evidence pack
99
+ - propagation explanation
100
+ - recommended actions
101
+ - delta simulation
102
 
103
+ ### Graph
104
+ The graph page shows how disruptions travel through the network, which nodes are under the most pressure, and which states absorb the highest downstream risk.
105
+
106
+ ### Query
107
+ The operator can ask plain-English questions such as:
108
+ - "Which drugs are most exposed to Hebei shutdown?"
109
+ - "What should procurement do in the next 72 hours?"
110
+ - "Which nodes are highest risk in the current cluster?"
111
 
112
  ---
113
 
114
+ ## MVP Demo Flow
115
 
116
+ This is the cleanest walkthrough for judges, mentors, or users:
 
 
 
 
117
 
118
+ 1. Open the **Dashboard**
119
+ 2. Select a high-severity shock
120
+ 3. Enter the **War Room**
121
+ 4. Inspect propagation and evidence
122
+ 5. Run one response action in the simulator
123
+ 6. Show the risk delta and stockout extension
124
+ 7. Ask a question in **Query**
125
+
126
+ This makes the system feel operational from end to end.
127
+
128
+ ---
129
+
130
+ ## 3-Engine Architecture
131
+
132
+ ```text
133
+ ENGINE 1 ENGINE 2 ENGINE 3
134
+ Signal Shock Action
135
+ Intelligence -> Propagation -> Intelligence
136
+ (What happened) (What it means) (What to do)
137
+ ```
138
+
139
+ ### Engine 1: Signal Intelligence
140
+
141
+ Engine 1 is responsible for turning unstructured event streams into structured shocks.
142
+
143
+ Current MVP path:
144
+ - event fetch and refresh pipeline
145
+ - disruption keyword filtering
146
+ - structured shock records persisted to `data/shocks.json`
147
+ - Gemini Flash used for efficient structured extraction where available
148
+
149
+ Typical extracted fields:
150
+ - `shock_type`
151
+ - `province`
152
+ - `sector`
153
+ - `severity`
154
+ - `affected_entities`
155
+ - `estimated_duration_days`
156
+
157
+ ### Engine 2: Shock Propagation
158
+
159
+ Engine 2 is the production risk engine in the MVP.
160
+
161
+ Current production method:
162
+ - **Knowledge graph** for supply structure
163
+ - **Louvain community detection** for co-propagating clusters
164
+ - **Personalized PageRank** for directional shock spread
165
+ - **Criticality modifiers** for substitutability, buffer pressure, and concentration
166
+
167
+ Propagation formula:
168
+
169
+ ```text
170
+ R_i = PR_i(shock) * (1 - S_i) * exp(-B_i / tau) * C_community
171
+ ```
172
+
173
+ Where:
174
+ - `PR_i(shock)` = PageRank influence from the shocked origin
175
+ - `S_i` = substitutability
176
+ - `B_i` = buffer days
177
+ - `tau` = lead-time constant by sector
178
+ - `C_community` = community amplification factor
179
+
180
+ ### Engine 3: Action Intelligence
181
+
182
+ Engine 3 converts risk into decisions.
183
+
184
+ Current MVP behavior:
185
+ - retrieves grounded context from local policy and reference data
186
+ - uses Gemini Flash for structured answer/action generation
187
+ - returns citations, confidence, suggested entities, and next actions
188
+ - preserves a deterministic operator experience through scenario-backed degradation
189
+
190
+ ---
191
+
192
+ ## Gemini Usage Strategy
193
+
194
+ ShockMap uses Gemini Flash in a cost-aware, operator-safe way.
195
+
196
+ ### Design principles
197
+ - **Flash-only routing** for MVP speed and cost control
198
+ - **Schema-constrained generation** for stable JSON outputs
199
+ - **Short timeout budget** to avoid hanging user flows
200
+ - **Prompt minimization** to keep token usage tight
201
+ - **Retrieval merge** across vector and lexical evidence
202
+ - **Deterministic fallback** so the product remains usable even when external AI calls are slow
203
+
204
+ ### Where Gemini is used
205
+ - Engine 1 extraction and normalization
206
+ - Engine 3 query answering
207
+ - Engine 3 action-plan generation
208
+
209
+ This keeps Gemini central to the product while preserving a reliable operational UX.
210
+
211
+ ---
212
+
213
+ ## Research-Informed Product Direction
214
+
215
+ ShockMap is built as a practical MVP now, with a clear path toward more advanced graph learning and causal response intelligence.
216
+
217
+ The current production path is intentionally strong:
218
+ - interpretable
219
+ - stable
220
+ - easy to validate
221
+ - suitable for a judging demo
222
+
223
+ The next phases extend that foundation into a more advanced learning system without changing the product workflow.
224
+
225
+ ---
226
+
227
+ ## Phase Roadmap
228
+
229
+ ### Phase 1: MVP Operations Layer
230
+ - hybrid live shock feed
231
+ - production graph propagation
232
+ - war room
233
+ - action simulation
234
+ - grounded operator query
235
+ - deployable frontend + backend surfaces
236
+
237
+ ### Phase 2: Regional Operations Expansion
238
+ - state-level and corridor-level overlays
239
+ - inventory and days-of-cover modeling
240
+ - regional reallocation workflows
241
+ - map-based incident command views
242
+ - expanded sector templates beyond pharma and rare earths
243
+
244
+ ### Phase 3: GNN Propagation Layer
245
+ - temporal graph learning on historical disruptions
246
+ - node embeddings across provinces, APIs, inputs, and downstream products
247
+ - learned propagation that augments or replaces the PageRank path
248
+ - improved ranking under multi-origin and cascading shocks
249
+
250
+ ### Phase 4: Procurement and Policy Platform
251
+ - procurement workflow integration
252
+ - escalation playbooks
253
+ - role-based action tracking
254
+ - stakeholder notes and audit history
255
+ - organization-level workspaces
256
+
257
+ ### Phase 5: Multi-Sector National Risk Platform
258
+ - semiconductor inputs
259
+ - solar and clean-energy dependencies
260
+ - EV battery chain monitoring
261
+ - defense and advanced-manufacturing inputs
262
+ - cross-sector risk portfolio views
263
 
264
+ ---
265
+
266
+ ## GNN Roadmap
267
+
268
+ The graph layer is already structured for a future GNN upgrade.
269
+
270
+ ### Planned graph design
271
+
272
+ **Node types**
273
+ - province
274
+ - factory
275
+ - input
276
+ - API
277
+ - drug
278
+ - rare earth mineral
279
+ - route / logistics node
280
+ - supplier / buyer entity
281
+
282
+ **Node features**
283
+ - import concentration
284
+ - current risk score
285
+ - buffer days
286
+ - substitutability
287
+ - strategic priority
288
+ - demand criticality
289
+ - recent shock exposure
290
+ - regulatory pressure
291
+
292
+ **Edge features**
293
+ - trade volume
294
+ - lead time
295
+ - dependency strength
296
+ - route dependence
297
+ - concentration and exclusivity
298
+
299
+ **Training targets**
300
+ - realized shortage severity
301
+ - price spikes
302
+ - fill-rate stress
303
+ - procurement delays
304
+ - duration to recovery
305
+
306
+ ### Planned inference outcome
307
+
308
+ The GNN phase will learn propagation patterns from observed disruptions rather than relying only on static graph logic. The product experience remains the same, but the engine underneath becomes better at:
309
+ - multi-hop shock attribution
310
+ - hidden cluster coupling
311
+ - non-linear escalation
312
+ - time-aware recovery forecasting
313
+
314
+ ---
315
+
316
+ ## Scalability Design
317
+
318
+ ShockMap is being shaped to scale from a demo system into a broader intelligence platform.
319
+
320
+ ### 1. Stateless serving layer
321
+ - FastAPI backend stays stateless
322
+ - frontend remains CDN-friendly and easy to cache
323
+ - deployment can scale horizontally without application rewrites
324
+
325
+ ### 2. Separate ingestion from serving
326
+ - ingestion jobs run on a schedule
327
+ - serving reads normalized shock data
328
+ - this keeps user-facing latency stable even as source count grows
329
+
330
+ ### 3. Layered storage model
331
+ - raw source archive
332
+ - normalized shock records
333
+ - graph-ready feature tables
334
+ - retrieval-ready citation corpus
335
+
336
+ ### 4. Cached graph snapshots
337
+ - precompute community structure
338
+ - cache graph responses for UI views
339
+ - isolate heavy recomputation to background refresh cycles
340
+
341
+ ### 5. Retrieval layer growth
342
+ - lexical fallback today
343
+ - hosted vector retrieval at scale
344
+ - sector-specific retrieval collections later
345
+
346
+ ### 6. Multi-tenant evolution
347
+ - tenant-scoped sectors, alerts, and workspaces
348
+ - org-specific configuration and alerting
349
+ - audit trails for action workflows
350
+
351
+ ### 7. Observability and reliability
352
+ - structured logs
353
+ - engine health status
354
+ - shock feed mode visibility
355
+ - deterministic degradation under model or network pressure
356
+
357
+ ---
358
+
359
+ ## Repository Structure
360
+
361
+ | Path | Purpose |
362
+ |---|---|
363
+ | `backend/app/` | FastAPI APIs, services, models, dependency injection |
364
+ | `frontend/src/` | React UI surfaces and client-side workflow |
365
+ | `ingestion/` | shock detection, scrapers, and signal intake |
366
+ | `graph/` | graph-building utilities |
367
+ | `data/seed/` | curated seed data, scenarios, policy snippets |
368
+ | `data/shocks.json` | live structured shock feed |
369
+ | `docs/` | architecture and data-source notes |
370
+
371
+ ---
372
+
373
+ ## Key API Surfaces
374
+
375
+ | Endpoint | Purpose |
376
+ |---|---|
377
+ | `/healthz` | system status and engine health |
378
+ | `/api/v1/sectors` | sector overview |
379
+ | `/api/v1/shocks` | live shock feed |
380
+ | `/api/v1/shocks/{id}` | shock detail |
381
+ | `/api/v1/shocks/{id}/war-room` | incident command surface |
382
+ | `/api/v1/shocks/{id}/simulate-action` | action delta simulation |
383
+ | `/api/v1/graph` | graph snapshot and state risk |
384
+ | `/api/v1/query` | operator analyst |
385
+ | `/api/v1/engines` | engine diagnostics |
386
+
387
+ ---
388
+
389
+ ## Run Locally
390
+
391
+ ### Backend
392
+ ```bash
393
  cd backend
394
+ python -m venv venv
395
+ venv\Scripts\activate
396
  pip install -r requirements.txt
397
+ uvicorn app.main:app --reload
398
+ ```
399
+
400
+ Backend URLs:
401
+ - API: `http://localhost:8000`
402
+ - Docs: `http://localhost:8000/docs`
403
+ - Health: `http://localhost:8000/healthz`
404
 
405
+ ### Frontend
406
+ ```bash
407
+ cd frontend
408
  npm install
409
  npm run dev
410
  ```
411
 
412
+ Frontend URL:
413
+ - App: `http://localhost:5173`
414
+
415
+ ### Optional ingestion refresh
416
+ ```bash
417
+ python -m ingestion.shock_detector --once
418
+ ```
419
+
420
  ---
421
 
422
+ ## Environment Variables
423
+
424
+ | Variable | Purpose |
425
+ |---|---|
426
+ | `GEMINI_API_KEY` | Gemini Flash access for extraction and action intelligence |
427
+ | `QDRANT_URL` | hosted vector store endpoint |
428
+ | `QDRANT_API_KEY` | vector store authentication |
429
+ | `DEMO_MODE` | enables curated scenario mode |
430
+ | `ENABLE_GNN` | toggles the future GNN path |
431
+ | `ALLOWED_ORIGINS` | frontend origins for the API |
432
 
433
  ---
434
 
435
+ ## Tech Stack
436
+
437
+ | Layer | Stack |
438
+ |---|---|
439
+ | Backend | FastAPI, Pydantic v2, Python |
440
+ | Graph | NetworkX, python-louvain, criticality scoring |
441
+ | AI | Gemini Flash |
442
+ | Retrieval | Qdrant + lexical fallback |
443
+ | Frontend | React 19, Vite |
444
+ | Ingestion | Python schedulers, source fetchers, structured normalization |
445
+
446
+ ---
447
+
448
+ ## Positioning
449
+
450
+ ShockMap is not just an alert dashboard.
451
+
452
+ It is a **decision engine for upstream supply shocks**:
453
+ - detect the disruption
454
+ - map the downstream exposure
455
+ - simulate the response
456
+ - act with evidence
457
+
458
+ That is the MVP.
459
+
460
+ ---
461
+
462
+ ## License
463
+
464
+ MIT
465
+
466
+ Built for the **Google Solution Challenge 2026**.