WEHack UTD · Capital One Track Model pricing shifts, franchise expansion, and audience changes against real economic data. Compare control vs. experiment outcomes with full explainability.
TwinTrack lets a small business owner register their business as a digital twin — a structured snapshot of their financials, costs, and sales profile — and then run what-if simulations before making real decisions.
Each simulation runs a full pipeline:
- Pulls live economic data (CPI, unemployment, GDP, consumer spending, local market density, news sentiment)
- Computes price elasticity and market context using Claude Haiku
- Models the financial outcome under the proposed change
- Returns OP1 (control baseline) and OP2 (experiment result) with a plain-English recommendation
Three use cases:
- Pricing changes — raise or lower average price; models demand response via price elasticity derived from CPI trends
- Target audience — shift to a new demographic segment; models ticket size, footfall, and marketing cost impact
- Franchise expansion — open new locations; models upfront costs, amortized over 36 months, with break-even projection
twintrack/ ← React + Vite frontend (port 5173)
backend/
server.py ← ThreadingHTTPServer (port 8765)
ml/ ← Market data + LLM layer
fetcher.py ← FRED, BLS, BEA, Census, NewsAPI
context.py ← NAICS/MSA resolver via Claude Haiku
elasticity.py ← Price/labor/market elasticity
forecaster.py ← ARIMA 12-month projections
sentiment.py ← News sentiment scoring
ms_builder.py ← Builds MS (market snapshot) JSON
main.py ← ML pipeline entry point
sim/
sim_bridge.py ← Translates frontend form → IP1/IP2
sim_layer.py ← Financial simulation engine
data/
base/ ← Enrollment JSON + IP files
ms/ ← Market snapshot outputs
op/ ← Simulation outputs (OP1 + OP2)
cache/ ← API response cache (by date)
Request flow for a simulation:
Frontend → POST /api/simulate
→ load twin layer from disk
→ write IP file
→ ml_run() → ms/ms_exp_<bizid>_<date>.json
→ run_simulation() → {op1, op2}
→ write_op() → op/op_<usecase>_<bizid>_<date>.json
→ return {op1, op2, recommendation}
- Python 3.10+
- Node.js 18+
# Python dependencies (from repo root)
pip install -r requirements.txt
# Frontend dependencies
cd twintrack
npm installCopy .env.example to .env and fill in your keys:
ANTHROPIC_API_KEY=sk-ant-...
FRED_API_KEY=...
BLS_API_KEY=...
BEA_API_KEY=...
CENSUS_API_KEY=...
NEWSDATA_API_KEY=...| Key | Get it from |
|---|---|
ANTHROPIC_API_KEY |
console.anthropic.com |
FRED_API_KEY |
fred.stlouisfed.org/docs/api |
BLS_API_KEY |
data.bls.gov/registrationEngine |
BEA_API_KEY |
apps.bea.gov/API/signup |
CENSUS_API_KEY |
api.census.gov/data/key_signup.html |
NEWSDATA_API_KEY |
newsdata.io |
Terminal 1 — backend:
python backend/server.py
# Listening on http://127.0.0.1:8765Terminal 2 — frontend:
cd twintrack
npm run dev
# Running on http://localhost:5173Open http://localhost:5173 in your browser.
Go to Register business in the sidebar. Enter your financials, cost breakdown, loan details, sales channel, and product info. The server assigns a business_id (integer, starting at 1) and writes:
backend/data/base/input_newbusiness_<date>.jsonbackend/data/base/ip_<bizid>_<date>.json
Go to Run simulation. Select your registered business, pick a use case, fill in the parameters, and optionally describe your decision in plain English. The LLM layer will extract and merge any additional parameters from your description.
Click Run simulation engine to execute the full pipeline. Results appear as OP1 (control) and OP2 (experiment) with a Claude-generated recommendation.
The dashboard shows:
- Revenue, margin, and footfall delta (OP2 vs OP1)
- 12-month projections (ARIMA)
- Confidence score
- News sentiment (from local market news)
- Plain-English verdict: proceed / proceed with caution / avoid
| Method | Path | Description |
|---|---|---|
GET |
/api/health |
Server health check |
POST |
/api/save-twin-layer |
Register/update a business |
POST |
/api/simulate |
Run a simulation |
GET |
/api/list-businesses |
List all enrolled businesses |
GET |
/api/op-result?business_id=1&use_case=pricing |
Fetch latest OP output |
POST |
/api/update-twin-layer |
Update business financials |
| Source | What it provides |
|---|---|
| FRED (St. Louis Fed) | CPI, interest rates, GDP |
| BLS (Bureau of Labor Statistics) | Unemployment by metro area |
| BEA (Bureau of Economic Analysis) | Consumer spending by sector |
| Census | Business density by NAICS + metro |
| NewsData.io | Local news sentiment for the business category |
All API responses are cached to backend/data/cache/ by date. Repeat runs on the same day reuse the cache.
Three Claude Haiku (claude-haiku-4-5-20251001) calls in the pipeline:
- NAICS + MSA resolver — maps
business_type + city + state→naics_code + msa_codewhen the business type doesn't match the dropdown options - NL → IP2 enrichment — extracts structured simulation parameters from the optional plain-English description on step 3; only overrides keys explicitly mentioned
- Recommendation generator — writes a 2–3 sentence verdict grounded in the actual OP delta numbers (revenue, margin, footfall, confidence score)
All three calls degrade gracefully — if the API key is missing or the call fails, the pipeline continues without LLM output.
| Layer | Pattern |
|---|---|
| Enrollment | input_newbusiness_<date>.json |
| IP (twin layer) | ip_<bizid>_<date>.json |
| Market snapshot | ms_exp_<bizid>_<date>.json |
| Simulation output | op_<usecase>_<bizid>_<date>.json |
| Layer | Technology |
|---|---|
| Frontend | React 19, Vite 5 |
| Backend | Python 3 http.server.ThreadingHTTPServer |
| Forecasting | statsmodels ARIMA, pmdarima auto-ARIMA |
| LLM | Anthropic Claude Haiku (anthropic SDK) |
| Data | pandas, requests |
| Config | python-dotenv |
backend/server.py— single-file HTTP server; all routes in onedo_GET/do_POSThandlerbackend/ml/— stateless pipeline; each module exports one main functionbackend/sim/sim_bridge.py— translates messy frontend form values into clean IP1/IP2 dicts, with sanity checks and warningstwintrack/src/TwinTrack.jsx— main app component; all pages rendered inline (no router)twintrack/src/Dashboard.jsx— live dashboard that fetches OP output from the backend
Built at WEHack UTD · April 2026