Inspiration
In April 2022, Afghanistan's opium ban wiped out 95% of the world's largest supply in a single season. The drugs didn't disappear. They rerouted through new countries almost overnight, and nobody saw it coming.
That's the core problem with the drug trade: routes shift in months, while the data that reveals a crisis, like overdose, HIV and homicide rates, arrives years later. We wanted to see where the trade is going next, not where it has already been. So we built TRACE.
What it does
TRACE is a real-time intelligence terminal for the global drug trade. It maps trafficking corridors for cocaine, heroin, methamphetamine and cannabis across 217 countries, forecasts how those corridors will shift next year, and scores every country's risk of a new drug crisis. It also reads the news live, flags emerging routes as they surface, and lets you simulate shocks like a crop ban and watch the whole network rewire. Every number on screen traces back to its original source.
How we built it
We pulled 24 indicators for 217 economies from the World Bank Indicators API and fused them with UNODC seizure, price and cultivation data (2.3 million seizure cases), the Global Organized Crime Index, Harm Reduction International and CEPII trade distances.
Our forecasting engine is a LightGBM hurdle model, benchmarked against a PPML gravity model. It predicts whether each corridor will be active next year and how much will move through it.
Every country gets a risk score built from route exposure $E$, vulnerability $V$ and protection $P$:
$$ R = 0.45\,E + 0.35\,V + 0.20\,(100 - P) $$
For live news, we trained our own 70M-parameter classifier, Reflex, on a cloud GPU. It reads headlines, extracts the drug, origin, destination and seizure size, and reports calibrated confidence on every answer. The backend runs on FastAPI with a WebSocket news feed, and the frontend is Next.js with deck.gl and MapLibre, all deployed on Vercel.
Challenges we ran into
Public seizure data only records where drugs were caught, not where they came from, so there was no route data to train on. We engineered our own: a corridor network built from UNODC's published route maps, with seizure volumes allocated across it year by year.
Seizures also reflect where police are looking, not just where drugs flow. We built detection-bias controls into the model and a six-signal confidence score for every corridor.
Getting machine learning models to run on serverless infrastructure took real work too: slimming a 1.2 GB database down to 84 MB, loading heavy libraries only when needed, and cutting cold starts from 8 seconds to under half a second.
Accomplishments that we're proud of
On held-out 2020 to 2024 data, TRACE predicts which corridors will be active with 0.88 AUC, compared with 0.58 for the standard economics baseline.
We also ran the Afghan opium ban through it as a live test. Given only the ban, the model called 12 of 13 corridor shifts correctly and predicted Southeast Asia's share would rise to 14%. The real figure came in at 13%.
We also fine-tuned our own 70-million-parameter language model, Reflex, on a cloud GPU. It nearly doubled the base model's accuracy on held-out tasks, from 48% to 90%, and cut its calibration error tenfold, from 0.206 to 0.020. On held-out headlines it classifies drug events with 98% accuracy, identifies the destination country 82% of the time against 52% for a keyword baseline, and processes each headline in about 50 milliseconds.
What we learned
Real-world data is messy, and the difference between a demo and a tool people can trust is traceability. Linking every number back to its source row made the whole system sharper and easier to defend.
What's next for Trace
Validating Reflex on live news feeds, adding fentanyl and wastewater data, weekly retraining with country-level alerts, and taking TRACE to organizations working in the transit corridors it flags.
Built With
- claude
- colab
- deck.gl
- fastapi
- gdelt
- lightgbm
- maplibre
- next.js
- onnx
- pandas
- python
- pytorch
- react
- recharts
- scikit-learn
- shap
- sqlite
- statsmodels
- tailwind
- transformers
- typescript
- unodc
- vercel
- websockets
- world-bank-api
Log in or sign up for Devpost to join the conversation.