| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
A real-time analytics platform for Polymarket, built with Next.js and powered by the Struct API. Explore traders, markets, events, tags, and builders — with full PnL histories, positions, activity feeds, leaderboards, and a global analytics dashboard, all server-rendered.
This project demonstrates what can be built on top of the Struct SDK to create a rich, fully server-rendered analytics experience over Polymarket data.
| Layer | Technology |
|---|---|
| Framework | Next.js 16 (App Router) |
| Language | TypeScript 5.9 |
| UI | React 19 |
| Styling | Tailwind CSS 4 |
| Components | shadcn/ui (base-nova) on Base UI |
| Data | Struct SDK (@structbuild/sdk) |
| Charts | Recharts + Lightweight Charts |
| Tables | TanStack Table |
| URL State | nuqs |
| Command Palette | cmdk |
| Auth | better-auth (email OTP) |
| Bot Protection | Vercel BotID + Cloudflare Turnstile |
| Analytics | PostHog + Vercel Analytics |
| 3D Effects | React Three Fiber |
| Image Export | html-to-image |
| Icons | Lucide |
| Fonts | Geist |
Browser --> Next.js Server --> Struct SDK --> Polymarket data
All data fetching happens server-side through the Struct SDK — the Struct API key never reaches the client. React's cache() deduplicates requests within a render pass. Optionally, Next.js Cache Components (use cache / cacheLife / cacheTag) can be enabled with the ENABLE_COMPONENT_CACHE flag for cross-request caching.
Pages:
Legacy routes (/leaderboard, /trader/[address], /market/[slug]) permanently redirect to their current equivalents.
Clone the repository:
git clone https://github.com/polymarket/polymarket-explorer.git
cd polymarket-explorerInstall dependencies:
pnpm installConfigure environment variables:
cp .env.example .env.localEdit .env.local and add your Struct API key:
STRUCTBUILD_API_KEY=your-api-keyStart the development server:
pnpm devThe app will be available at http://localhost:3000.
If STRUCTBUILD_API_KEY is not set, the app renders a setup state instead of failing.
| Script | Description |
|---|---|
| pnpm dev | Start the development server |
| pnpm build | Production build |
| pnpm start | Start the production server |
| pnpm lint | Run ESLint |
| pnpm test:pnl | Run the PnL calculation tests |
| Variable | Required | Default | Description |
|---|---|---|---|
| STRUCTBUILD_API_KEY | Yes | - | Struct SDK API key for fetching Polymarket data |
| STRUCTBUILD_TIMEOUT_MS | No | 10000 | API request timeout in milliseconds |
| NEXT_PUBLIC_STRUCTBUILD_API_URL | No | https://api.struct.to/v1 | Struct API base URL |
| NEXT_PUBLIC_SITE_URL | No | http://localhost:3000 | Public URL used for metadata and sitemap generation |
| NEXT_PUBLIC_AUTH_URL | No | https://struct.to | better-auth base URL (restricted to struct.to / localhost) |
| NEXT_PUBLIC_TURNSTILE_SITE_KEY | No | - | Cloudflare Turnstile site key for sign-in |
| NEXT_PUBLIC_POSTHOG_PROJECT_TOKEN | No | - | PostHog project token for product analytics |
| ENABLE_COMPONENT_CACHE | No | false | Enables Next.js Cache Components when set to true, 1, yes, or on |
app/
layout.tsx Root layout with theme provider and fonts
page.tsx Home with activity feeds and explore grid
actions.ts Server actions
manifest.ts PWA web app manifest
sitemap.xml/ Sitemap index + paginated segments
robots.ts robots.txt
traders/ Traders leaderboard and profile pages
markets/ Markets index and detail pages
events/ Events index and detail pages
tags/ Tag / category index and detail pages
builders/ Builders index, detail, and comparison pages
analytics/ Global analytics dashboard
rewards/ Rewards page
login/ account/ Authentication and account pages
components/
trader/ Profile header, PnL, DNA radar, positions, activity
market/ Market detail, charts, holders, trades, tables
event/ Event header, child-market tables, overview charts
tags/ Tag grid, stats, top traders, tables
builders/ Builder detail, comparison, global stats, tables
analytics/ KPI strip, volume/trade charts, shareable cards, toggles
home/ Activity feeds, trending markets, explore grid
auth/ Sign-in dialog/form, auth gate, user menu
search/ Cmd+K command palette
seo/ Breadcrumbs, JSON-LD, pagination, error/not-found states
layout/ Header, footer, mobile nav, changelog, notifications
ui/ shadcn primitives (button, card, dialog, table, chart, etc.)
lib/
struct/ Struct SDK client, queries, and data projections
client.ts Struct SDK singleton with retry config
queries/ Per-entity query modules (markets, events, builders, ...)
analytics-*.ts Analytics queries and projections
pnl*.ts PnL calculations, ranges, and timeframes
types.ts Shared TypeScript interfaces
auth/ auth-client.ts better-auth session helpers and client
*-search-params*.ts nuqs URL search-param parsers per entity
polymarket/ Trader archetype / DNA logic
hooks/ Client hooks (localStorage, timezone, share mode, ...)
utils.ts format.ts Formatting, address truncation, class merging
env.ts Environment variable helpers
share-image.ts DOM-to-PNG export logic
site-metadata.ts Metadata and Open Graph helpers
changelog.ts In-app changelog entries
The Struct SDK (@structbuild/sdk) is the app's sole data layer, providing:
Transaction links resolve to Polygonscan, and markets/events link back to Polymarket.
This is a standard Next.js application deployable to any Node.js-compatible platform (Vercel, Netlify, Railway, etc.). Security headers (HSTS, CSP, X-Frame-Options, and others) are configured in next.config.ts.
MIT
| Back | FazBrowse Home | New Git URL |