Skip to content

Latest commit

History

19 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

CommodityChain

Real-time commodity intelligence platform — live prices, AI analysis, India macro layer, news feed, alerts, and interactive tools.

Dashboard Preview

Frontend:commoditychain.vercel.app · Backend API:commoditychain.onrender.com/docs


Features

ModuleDescription
DashboardLive price cards, bar charts, top movers, market sentiment
ExplorerFull price history chart (1W/1M/3M/1Y), OHLC table, watchlist
Global MapD3 world map — producer/consumer profiles for 20 countries
Correlation8×8 Pearson correlation heatmap (30-day rolling)
ConverterCurrency + commodity unit + value converter with live FX rates
WatchlistHypothetical portfolio with live unrealised PnL
AlertsBrowser push notification price alerts (localStorage)
ExportCSV / JSON price history download
NewsCommodity-filtered news feed with AI sentiment labels
LearnExplainer articles — oil, gold, futures, copper, India context
AI AnalystGroq Llama 3.3 70B chat with live price context + 3 persona modes
Shock SimulatorIndia macro impact model — drag crude price, see petrol/inflation/INR
India LayerCity-wise petrol/diesel prices + tax breakdown + macro indicators

Tech Stack

LayerTechnology
FrontendNext.js 14 + TypeScript
StylingCustom CSS variable design system (dark + light)
BackendFastAPI + WebSockets
AIGroq Llama 3.3 70B (free tier)
Price dataTwelve Data API (real-time)
Metals fallbackmetals.live
FX ratesopen.er-api.com
NewsNewsAPI + curated fallback
Frontend hostVercel
Backend hostRender

Local Setup

# Terminal 1 — Backendcd backend
py -3.12 -m venv venv
.\venv\Scripts\Activate.ps1
pip install -r requirements.txt
uvicorn main:app --reload --port 8000
# Terminal 2 — Frontendcd frontend
npm install
npm run dev

Open http://localhost:3000 · API docs at http://localhost:8000/docs


Environment Variables

backend/.env

ALLOWED_ORIGINS=http://localhost:3000
GROQ_API_KEY= # console.groq.com — free
TWELVE_DATA_KEY= # twelvedata.com — free tier
NEWS_API_KEY= # newsapi.org — optional

frontend/.env.local

NEXT_PUBLIC_API_URL=http://localhost:8000
NEXT_PUBLIC_WS_URL=ws://localhost:8000

API Reference

MethodRouteDescription
GET/api/pricesAll commodity prices
GET/api/prices/:idSingle commodity
GET/api/newsNews feed
GET/api/ratesLive FX rates
POST/api/analystAI analysis (Groq)
POST/api/simulateIndia macro shock model
GET/api/export/:idCSV/JSON download
GET/api/india/pricesCity-wise petrol/diesel
GET/api/correlationPearson matrix
WS/ws/pricesLive price stream

Project Structure

commoditychain/
backend/
main.py # FastAPI app, 9 routers
requirements.txt
services/
commodity_service.py # Twelve Data + GBM fallback
routers/
prices.py / websocket.py / news.py / fx.py
analyst.py / simulator.py / export.py
india.py / correlation.py
frontend/src/
app/ # 13 pages (Next.js App Router)
components/
Sidebar.tsx # Grouped nav with icons
Topbar.tsx # Search + live status
PriceCard.tsx / Ticker.tsx / StatsBar.tsx
hooks/
usePrices.ts / useTheme.ts / useWatchlist.ts
lib/
api.ts / constants.ts / utils.ts

Build Phases

PhaseFeatures
1Dashboard, live prices, WebSocket, dark mode
2Explorer, News, Converter, Watchlist
3AI Analyst, Shock Simulator, Alerts, Learn
4Global Map, Correlation Matrix, Export, India Layer

Built by Ayush Raj — BSc CSDA @ IIT Patna 2024–2028
Stack: Next.js 14 · FastAPI · Groq · Twelve Data · Vercel · Render

About

Real-time commodity intelligence platform with live prices, AI analysis, macro simulations, market news, and interactive dashboards.

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Contributors

Languages