← Dumka Lkhagva
PPE Journal Entry
v0.1 v0.2

Trade & Tariff
Policy Simulator

My first ever creation of a trade policy simulator, where generative AI analyses a trade policy from three competing economic perspectives — each making core arguments, determining winners & losers, and tracing second-order effects.

PPE Economics React Claude API Trade Policy Mongolia-China

I built a tool that takes any trade policy as input — for example, "China imposing 20% tariffs on Mongolia's copper" — and runs it through multiple AI-powered analysis modules simultaneously. Each module represents a different lens through which economists, political scientists, and policymakers evaluate trade decisions.

The idea came from a simple observation in my PPE coursework: the same policy looks completely different depending on your framework. A free-trade economist sees deadweight loss; a strategic protectionist sees leverage; a labor advocate sees displaced workers. I wanted to see all three simultaneously and understand where they agree and where they diverge.

3
Economic perspectives
v0.1
6
Analysis modules
v0.2
8
Sequential API calls
per analysis
1
Policy question
input
Test Case
"China imposing 20% tariffs on Mongolia's copper"
Chosen because it directly connects to the Mongolia-China bilateral trade relationship and affects a resource-dependent economy with limited diversification options.
v0.1 — First Prototype
Three competing economic perspectives analyse the same policy. Core arguments, winners & losers, second-order effects, and historical parallels.
v0.2 — Full Analysis Engine
Added statistical data, rational expectations vs reality, leader psychology, monetary effects, and chain reaction visualization. Fixed rate limiting and JSON parsing resilience.

The first prototype asked one question: what happens when you give the same trade policy to three economists with fundamentally different worldviews? Here are the results from the very first run.

Example Run · v0.1
China imposing 20% tariffs on Mongolia's copper
🌐Free Trade Economist
Comparative advantage violated — China diverts resources into protecting less competitive domestic miners rather than sectors it excels in. Allocative inefficiency.
Winners
Chinese domestic copper producers
Losers
Mongolia (loses export revenue), Chinese manufacturers (higher input costs)
🛡️Strategic Protectionist
Resource leverage play — China protects its smelting industry from competition and keeps Mongolian copper cheaper, securing downstream processing dominance.
Winners
China's copper smelters and fabricators
Losers
Mongolia (loses export revenue), Chinese industrial consumers (higher input costs)
👥Consumer & Labor
Direct threat to Mongolian miners — wages, employment, and community survival in regions where mining is the only game in town are all directly attacked.
Winners
Chinese copper processors
Losers
Mongolian herders and miners, ordinary Mongolian households
All three perspectives largely agree on who wins and who loses — the disagreement is about whether the costs are justified. The free-trade economist says no (allocative inefficiency), the protectionist says yes (strategic leverage), and the consumer advocate focuses on the human devastation that both others abstract away.

The simulator included reflection prompts after each analysis. These questions pushed me to think critically rather than passively consuming the AI's output. My answers directly shaped what I built for v0.2.

"Where do the three perspectives actually agree?"
They largely agree on who wins and who loses. This trade policy has obvious winners and losers meaning there is a clear disadvantage to one country than the other. Although Free Trade Economist argues that it would be pointless because China will be dealing with allocative inefficiency and violation on comparative disadvantage, the costs of such issues are small in comparison to the costs coming onto Mongolia with full force.
"Which perspective's 'winners & losers' analysis surprised you most?"
The consumer advocacy perspective is the only one that does not have China losing any aspect, whereas impact on Mongolian social life is devastating.
"What empirical data would you need to settle the disagreements?"
Government revenue (before & after effects), consumer surplus, producer surplus and deadweight loss, long term and short term effects. This question directly inspired the five new modules I built for v0.2.
💡 THE KEY INSIGHT
The reflection question "What empirical data would you need to settle the disagreements?" directly generated my feature list for v0.2. Every module I added — statistical data, rational expectations, leader psychology, monetary effects, chain visuals — came from answering this one question seriously.

Every module I added was directly inspired by the reflection question: "What data would you need to settle the disagreements between the three perspectives?"

01
Statistical Data
Real economic indicators — GDP, trade balance, unemployment, inflation — for each country involved, with affected sectors and trade volume at stake.
02
Rational vs Real
Side-by-side comparison of what economic models predict versus what history shows actually happens, exposing the gap between theory and reality.
03
Leader Psychology
Psychological profiles of each country's leader — decision style, risk tolerance, negotiation approach — predicting how they'll actually respond.
04
Monetary Effects
Currency movements, interest rate pressure, inflation timelines, and the central bank dilemma the policy creates.
05
Chain Effect Visuals
Ripple-effect graph showing how consequences cascade through 1st, 2nd, and 3rd order effects, color-coded by positive/negative impact.
PPE Policy Lab v0.2
Statistical Context — Economic Indicators
China
GDP (USD T)
17.8
Trade Balance (USD B)
823
Bilateral Trade (USD B)
9.8
Tariff Rate %
20
Unemployment %
5.1
Manufacturing/GDP %
27.4
Mongolia
GDP (USD T)
0.02
Trade Balance (USD B)
-2.1
Bilateral Trade (USD B)
9.8
Tariff Rate %
5
Unemployment %
4.8
Manufacturing/GDP %
6.2
Copper Mining Raw Materials Metals Processing Construction Electronics
Trade volume at stake: $2.48B
PPE Policy Lab v0.2
Chain Reaction — Ripple Effect Visualization
Positive
Negative
Neutral
POLICY 1ST ORDER 2ND ORDER 3RD ORDER 20% tariff onMongolian copper Mongolian exportsdrop sharply Chinese inputcosts rise Mongolia seeksnew markets Domestic producersgain share Mining revenuedeclines Construction costsrise in China Russia/EU tradelinks grow Budget shortfallsin Mongolia Regional copperpricing volatile Mongolia strengthensnon-China trade

Understanding the engineering behind the simulator. Built as a single React component that orchestrates 8 sequential Claude API calls, each with a different role-based prompt.

React
Component-based UI
Claude API
AI analysis engine
Prompt Engineering
Role-based multi-perspective prompts
SVG
Chain effect visualization
Sequential Queue
Rate limit handling
JSON Normalizer
Resilient LLM output parsing
// The full analysis flow:
1. User types a policy → state update
2. Click "Run" → 8 modules set to loading
3. Sequential API calls: one at a time (avoids 429 rate limits)
4. Each response → parse text or JSON
5. JSON normalizer → handles variant key names
6. State update → React re-renders → spinner disappears, content appears
7. Repeat for all 8 modules
429 Rate Limit Error
Fix: All 8 API calls fired simultaneously, hitting the concurrency limit. Fixed by switching from parallel forEach to a sequential async queue.
💡 LLM APIs have concurrency limits — you can't just fire-and-forget multiple calls.
Empty Rational Expectations Panel
Fix: The model returned data under different key names than expected (e.g., 'rational_expectations' vs 'rational_expectation'). Built a normalizer that tries multiple key variants.
💡 LLMs are probabilistic — you can't trust exact JSON key names. Always build a normalization layer.
JavaScript Operator Precedence
Fix: (A && B || []) evaluates as (A && B) || [] — when A is truthy but B is undefined, you get undefined, not the fallback. Changed to ((obj || {}).key || []).
💡 Classic JS gotcha. Parentheses matter.