Don't compromise with your data. ComPrice it.
Commodity price intelligence for Indian APMC mandis. Surfaces Agmarknet (Govt. of India) data with satellite-view market cards, price history charts, and Claude-generated briefs.
- Next.js 14 (App Router) + TypeScript + Tailwind
- Firebase (Auth + Firestore + App Hosting)
- Anthropic SDK —
claude-sonnet-4-6for AI briefs - Recharts for price history
- Google Static Maps for satellite tiles (no interactive maps in v1)
cp .env.local.example .env.local
# fill in: DATA_GOV_IN_API_KEY, ANTHROPIC_API_KEY, GOOGLE_MAPS_API_KEY,
# NEXT_PUBLIC_FIREBASE_CONFIG, FIREBASE_ADMIN_KEY
npm install
npm run devIf your machine has a corporate proxy / TLS interceptor (Zscaler, Cloudflare WARP, etc.) and fetch() to data.gov.in fails with self-signed-cert errors, either:
- Add the proxy's root CA via
NODE_EXTRA_CA_CERTS=/path/to/ca.pem(preferred), or - For local dev only:
NODE_TLS_REJECT_UNAUTHORIZED=0 npm run dev. Never set this in prod.
NODE_TLS_REJECT_UNAUTHORIZED=0 npx tsx scripts/smoke-agmarknet.tsShould print 5 normalized records for Tomato/Karnataka and the aggregated grid view.
The /api/commodities route auto-seeds on first call. To seed manually:
npx tsx scripts/seed-commodities.tsnpm install -g firebase-tools
firebase emulators:startThe emulator UI is at http://localhost:4000.
app/
page.tsx # Home grid (auth-gated)
login/page.tsx
market/[marketId]/commodity/[commodityId]/page.tsx # Detail view
api/
commodities/route.ts # List + auto-seed
grid/route.ts # Cached, stale-fallback
market/[marketId]/commodity/[commodityId]/route.ts # 90d history + AI brief
ai/brief/route.ts # Standalone brief generator
health/route.ts # Env validation status
components/ shadcn-style UI primitives + feature components
lib/
agmarknet.ts # data.gov.in client + DD/MM/YYYY → ISO normalization
commodity-aliases.ts # Top-30 + alias map
firebase-admin.ts # Server SDK
firebase-client.ts # Browser SDK
google-maps.ts # Geocoding + Static Maps URL builder
anthropic.ts # Claude wrapper for briefs
cache.ts # Firestore cache helpers (with stale fallback)
markets-store.ts # Geocodes + caches Static Maps URL per market (once, ever)
types/
agmarknet.ts # Raw + normalized record shapes
domain.ts # API response contracts
| Key | TTL | Notes |
|---|---|---|
grid_{commodity}_{state} |
6 h | Stale fallback on Agmarknet errors |
detail_{market}_{commodity} |
1 h | |
brief_{market}_{commodity} |
1 h | Avoid burning Anthropic tokens |
| Geocoded lat/lng (per market) | Forever | Mandis don't move |
| Static Maps URL (per market) | 90 d | Image content stable; URL key rotation buffer |
- Dates arrive as
DD/MM/YYYY; we normalize to ISO at ingest - Markets report sparsely — we always show most recent record per market, never "today's"
- Volume is absent from the data.gov.in resource — we surface "Volume: N/A" with a tooltip
% changecompares to the previous record for that market+commodity, not yesterday- Multiple varieties per market+day are averaged in the grid; broken out on the detail page
- Volume scraping from agmarknet.gov.in
- Satellite imagery analytics (placeholder card on detail page)
- Inter-mandi arbitrage view (placeholder card)
- Price predictions (placeholder card)
- Interactive maps — Static Maps images only
firebase deploy --only firestore:rules,firestore:indexes
firebase apphosting:backends:create comprice # one-time
git push # App Hosting builds from your connected git repoSet the same .env.local keys as App Hosting secrets via the Firebase console.
ComPrice is not SEBI-registered. We do not provide buy/sell recommendations. AI briefs are descriptive and explicitly avoid trading advice.