Skip to content

Gzeu/CryptoTraderPro

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

67 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

CryptoTraderPro

Version Next.js TypeScript TailwindCSS Recharts MultiversX License Deploy

Professional cryptocurrency trading dashboard.
Real-time WebSocket prices Β· Portfolio P&L Β· Price Alerts Β· Backtest Β· Compare Β· MultiversX/EGLD native Β· Address Inspector Β· CryptoPanic news Β· Binance WS singleton.

πŸ”— Live Demo Β· πŸ“‹ Changelog Β· πŸ› Issues Β· 🌐 /egld Dashboard


✨ Features

Feature Details
πŸ“Š Market Dashboard Top 50 coins live, sortable by Price / 24h% / MCap / Volume
⚑ Binance WebSocket Singleton priceFeed β€” batched subscriptions, exponential reconnect
πŸ’Ό Portfolio Tracker Add positions with buy price, live P&L per row, 24h%, pie chart, CSV export
πŸ”” Price Alerts Above/below thresholds β†’ browser Notification API, persisted Zustand
⭐ Watchlist Star any coin, live prices via WS, persistent /watchlist page
πŸ” Global Search Cmd+K modal β€” live filter, keyboard nav ↑↓↡Esc
⌨️ Keyboard Shortcuts D dashboard · W watchlist · P portfolio · A alerts · ? help
πŸ“° Crypto News CryptoPanic feed per coin, paginated, vote counts
πŸ“ˆ TradingView Charts Embedded Advanced Chart per coin (SSR-safe dynamic import)
↔️ Compare Side-by-side dual-chart overlay, normalized to 100%
πŸ§ͺ Backtest SMA crossover strategy on Binance OHLC klines, equity curve
🌐 EGLD Dashboard MultiversX economics, staking APR, validators, live EGLDUSDT Β· ● LIVE
πŸ”Ž Address Inspector erd1... wallet lookup β€” EGLD balance, ESDT tokens, NFTs, recent txs
✨ PriceFlash Green/red flash 600ms on every price update across all pages
🟒 LiveDot Reusable animated live indicator β€” <LiveDot showLabel />
πŸŒ— Dark / Light Mode prefers-color-scheme default + manual data-theme toggle
πŸ›‘οΈ Error Boundary React class ErrorBoundary β€” catch + retry UI, no raw stack traces
πŸ—ΊοΈ SEO Sitemap Dynamic sitemap.ts β€” home + portfolio + watchlist + top-15 coins + EGLD

πŸ›  Tech Stack

Layer Library Version
Framework Next.js App Router 14
Language TypeScript 5.6
Styling TailwindCSS 3.4
Server state @tanstack/react-query 5
Client state Zustand + persist 4.5
Charts Recharts 2
HTTP Axios + retry interceptor 1.7
Icons Lucide React latest
Data CoinGecko API v3 free / Pro
News CryptoPanic API v1 free
Live prices Binance WebSocket public
EGLD MultiversX API public

πŸš€ Getting Started

# Install
npm install

# Configure environment
cp .env.example .env.local

# Dev server
npm run dev         # http://localhost:3000

# Type check + lint
npm run type-check
npm run lint

# Build
npm run build

πŸ”‘ Environment Variables (.env.local)

# CoinGecko (free tier works without key; Pro removes 429 rate limit)
COINGECKO_API_KEY=
NEXT_PUBLIC_COINGECKO_BASE=https://api.coingecko.com/api/v3

# CryptoPanic β€” news feed per currency
CRYPTOPANIC_API_KEY=                        # REQUIRED β€” https://cryptopanic.com/developers/api/
NEXT_PUBLIC_CRYPTOPANIC_BASE=https://cryptopanic.com/api/v1

# MultiversX (EGLD dashboard + Address Inspector)
MULTIVERSX_API_URL=https://api.multiversx.com
NEXT_PUBLIC_MULTIVERSX_EXPLORER=https://explorer.multiversx.com

# Binance WebSocket (public, no auth)
NEXT_PUBLIC_BINANCE_WS_BASE=wss://stream.binance.com:9443
NEXT_PUBLIC_BINANCE_REST_BASE=https://api.binance.com/api/v3

# App
NEXT_PUBLIC_APP_URL=http://localhost:3000
NEXT_PUBLIC_APP_NAME=CryptoTraderPro

πŸ“ Project Structure

src/
β”œβ”€β”€ app/                          # Next.js App Router
β”‚   β”œβ”€β”€ layout.tsx                # Root layout: ThemeProvider, QueryClient, ErrorBoundary, Header
β”‚   β”œβ”€β”€ providers.tsx             # ReactQueryDevtools + QueryClientProvider
β”‚   β”œβ”€β”€ globals.css               # CSS variables: Nexus palette light/dark, fluid type scale
β”‚   β”œβ”€β”€ page.tsx                  # /  β†’ Dashboard: top coins table, global stats, search modal
β”‚   β”œβ”€β”€ sitemap.ts                # Dynamic sitemap (home + portfolio + watchlist + top-15 coins + /egld)
β”‚   β”œβ”€β”€ error.tsx                 # Global error boundary page
β”‚   β”œβ”€β”€ not-found.tsx             # 404 page
β”‚   β”‚
β”‚   β”œβ”€β”€ portfolio/page.tsx        # /portfolio β†’ table + pie chart, Binance WS live prices
β”‚   β”œβ”€β”€ watchlist/page.tsx        # /watchlist  β†’ live prices per coin card
β”‚   β”œβ”€β”€ alerts/page.tsx           # /alerts     β†’ threshold triggers + Notification API
β”‚   β”œβ”€β”€ compare/page.tsx          # /compare    β†’ side-by-side dual-chart, normalized %
β”‚   β”œβ”€β”€ backtest/page.tsx         # /backtest   β†’ SMA crossover, equity curve, metrics
β”‚   β”‚
β”‚   β”œβ”€β”€ egld/
β”‚   β”‚   β”œβ”€β”€ page.tsx              # /egld       β†’ EGLD KPI cards, staking, validators, wallet input
β”‚   β”‚   └── [address]/page.tsx    # /egld/erd1… β†’ balance, ESDT tokens, NFTs, recent transactions
β”‚   β”‚
β”‚   β”œβ”€β”€ coin/[id]/page.tsx        # /coin/[id]  β†’ TradingView chart, stats, news, live price
β”‚   β”‚
β”‚   └── api/                      # Route Handlers β€” server-side proxy (hides API keys)
β”‚       β”œβ”€β”€ coins/route.ts        # GET /api/coins
β”‚       β”œβ”€β”€ coin/[id]/route.ts    # GET /api/coin/[id]
β”‚       β”œβ”€β”€ chart/[id]/route.ts   # GET /api/chart/[id]?days=
β”‚       β”œβ”€β”€ news/route.ts         # GET /api/news?currency=
β”‚       β”œβ”€β”€ global/route.ts       # GET /api/global
β”‚       β”œβ”€β”€ search/route.ts       # GET /api/search?q=
β”‚       β”œβ”€β”€ egld/route.ts         # GET /api/egld          β€” aggregates /economics + /stats, revalidate 30s
β”‚       β”œβ”€β”€ egld/address/
β”‚       β”‚   └── [address]/route.ts # GET /api/egld/address/[address] β€” account + tokens + nfts + txs, revalidate 15s
β”‚       └── alerts/check/route.ts # POST /api/alerts/check
β”‚
β”œβ”€β”€ components/
β”‚   β”œβ”€β”€ Header.tsx                # Sticky nav: logo, links, theme toggle, Cmd+K
β”‚   β”œβ”€β”€ SearchModal.tsx           # Cmd+K modal: live filter + keyboard nav
β”‚   β”œβ”€β”€ ErrorBoundary.tsx         # React class ErrorBoundary
β”‚   β”‚
β”‚   β”œβ”€β”€ charts/
β”‚   β”‚   β”œβ”€β”€ PortfolioPieChart.tsx # Recharts PieChart β€” tooltip, legends, animation
β”‚   β”‚   β”œβ”€β”€ PriceLineChart.tsx    # Recharts AreaChart β€” price history
β”‚   β”‚   └── CompareChart.tsx      # Recharts dual-axis LineChart
β”‚   β”‚
β”‚   β”œβ”€β”€ coin/
β”‚   β”‚   β”œβ”€β”€ CoinNewsFeed.tsx      # Wrapper β†’ CryptoPanicFeed
β”‚   β”‚   β”œβ”€β”€ CryptoPanicFeed.tsx   # News cards, skeleton, pagination
β”‚   β”‚   └── TradingViewWidget.tsx # TradingView Advanced Chart (SSR-safe)
β”‚   β”‚
β”‚   β”œβ”€β”€ portfolio/
β”‚   β”‚   └── PortfolioTable.tsx    # Live dot ●, P&L colored, 24h%, remove button
β”‚   β”‚
β”‚   β”œβ”€β”€ watchlist/
β”‚   β”‚   └── WatchlistCard.tsx     # Card with live price + 24h%
β”‚   β”‚
β”‚   β”œβ”€β”€ alerts/
β”‚   β”‚   └── AlertRow.tsx          # Target price, current price, status badge
β”‚   β”‚
β”‚   β”œβ”€β”€ egld/
β”‚   β”‚   β”œβ”€β”€ EgldKpiCard.tsx       # KPI card: icon, label, value, optional delta
β”‚   β”‚   β”œβ”€β”€ EgldQuickLinks.tsx    # Explorer Β· xExchange Β· xPortal Β· Docs Β· Staking
β”‚   β”‚   β”œβ”€β”€ WalletInspector.tsx   # erd1… input + validate + navigate to /egld/[address]
β”‚   β”‚   └── AddressDetail.tsx     # Balance, ESDT list, NFT count, recent txs
β”‚   β”‚
β”‚   └── ui/
β”‚       β”œβ”€β”€ Skeleton.tsx          # Shimmer skeleton
β”‚       β”œβ”€β”€ Badge.tsx             # Color badge (success/error/warning/info)
β”‚       β”œβ”€β”€ Tooltip.tsx           # CSS-only accessible tooltip
β”‚       β”œβ”€β”€ Button.tsx            # primary / secondary / ghost / danger variants
β”‚       β”œβ”€β”€ PriceFlash.tsx        # Wraps any value β€” green/red flash 600ms on change
β”‚       β”œβ”€β”€ LiveDot.tsx           # Animated ● indicator β€” size sm/md, optional label
β”‚       └── CopyButton.tsx        # Copy to clipboard β€” βœ“ feedback 1.5s
β”‚
β”œβ”€β”€ hooks/
β”‚   β”œβ”€β”€ useLivePrice.ts           # Single symbol via priceFeed singleton
β”‚   β”œβ”€β”€ usePortfolioLivePrices.ts # portfolioStore + useLivePrices β†’ rows with isLive
β”‚   β”œβ”€β”€ useMultiTickerWS.ts       # Direct Binance WS (fallback)
β”‚   β”œβ”€β”€ useTheme.ts               # Light/dark with data-theme on <html>
β”‚   β”œβ”€β”€ useKeyboardShortcuts.ts   # Global shortcuts, auto-cleanup
β”‚   β”œβ”€β”€ usePortfolioExport.ts     # CSV blob download
β”‚   └── useDebounce.ts            # Generic debounce
β”‚
β”œβ”€β”€ lib/
β”‚   β”œβ”€β”€ ws/priceFeed.ts           # Singleton Binance WS: subscribe/unsubscribe, batching, reconnect
β”‚   β”œβ”€β”€ api/
β”‚   β”‚   β”œβ”€β”€ coingecko.ts          # Typed CoinGecko fetchers
β”‚   β”‚   β”œβ”€β”€ cryptopanic.ts        # CryptoPanic news fetcher
β”‚   β”‚   β”œβ”€β”€ multiversx.ts         # MultiversX economics + stats + address + tokens + txs
β”‚   β”‚   └── binance.ts            # Binance klines/OHLC fetcher
β”‚   β”œβ”€β”€ formatters.ts             # fmtPrice / fmtLarge / fmtPct / fmtDate / fmtEgld
β”‚   β”œβ”€β”€ cgToBinance.ts            # CoinGecko id β†’ Binance USDT symbol map
β”‚   β”œβ”€β”€ egldValidation.ts         # isValidEgldAddress(addr) β€” bech32 erd1 check
β”‚   └── constants.ts              # TOP_COINS, DEFAULT_CURRENCY, REFRESH_INTERVALS
β”‚
β”œβ”€β”€ store/
β”‚   β”œβ”€β”€ portfolioStore.ts         # Zustand persist β€” entries[], addEntry, removeEntry
β”‚   β”œβ”€β”€ watchlistStore.ts         # Zustand persist β€” coinIds[], add, remove, has
β”‚   └── alertsStore.ts            # Zustand persist β€” alerts[], addAlert, updateStatus
β”‚
└── types/
    β”œβ”€β”€ coingecko.ts
    β”œβ”€β”€ cryptopanic.ts
    β”œβ”€β”€ multiversx.ts             # EgldEconomics, EgldStats, MvxAccount, EsdtToken, MvxTx
    └── portfolio.ts              # PortfolioEntry, PortfolioRow, AlertEntry

⚑ Binance WebSocket β€” priceFeed Singleton

All live prices flow through a single managed WebSocket connection:

wss://stream.binance.com:9443/stream?streams=btcusdt@miniTicker/ethusdt@miniTicker/egldusdt@miniTicker

API:

priceFeed.subscribe(symbol, cb) β†’ unsubscribeFn
priceFeed.getCached(symbol)     β†’ TickerPayload | null
  • Subscriptions from the same React render tick are batched after 40ms β†’ 1 reconnect
  • Reconnect: exponential 1.5s β†’ 3s β†’ 6s β†’ 12s β†’ 24s, max 5 retries
  • Use useLivePrices(symbols[]) β€” never subscribe to Binance WS directly

✨ Frontend Polish Components

PriceFlash

Wraps any price value and flashes green/red for 600ms when the value changes:

<PriceFlash value={price}>
  {fmtPrice(price)}
</PriceFlash>

Used on every live price in Dashboard, Portfolio, Watchlist, and EGLD pages.

LiveDot

Reusable animated live indicator with two variants:

<LiveDot isLive={isConnected} />                  // ● dot only
<LiveDot isLive={isConnected} showLabel size="md" /> // ● LIVE

CopyButton

Copy any string to clipboard with 1.5s visual confirmation (βœ“ Copied):

<CopyButton value="erd1abc..." />

⌨️ Keyboard Shortcuts

Shortcut Action
Cmd+K / Ctrl+K Open global search
D Go to Dashboard
W Go to Watchlist
P Go to Portfolio
A Go to Alerts
? Show shortcuts help
Esc Close modal / search

πŸ’° Formatters (src/lib/formatters.ts)

fmtPrice(42341.5)     // "$42,341.50"
fmtPrice(0.000123)    // "$0.000123"
fmtLarge(1_230_000)   // "$1.23M"
fmtPct(3.45)          // "+3.45%"
fmtDate(timestamp)    // "May 17, 2026 Β· 01:33"
fmtEgld(1234500000000000000n) // "1.2345 EGLD"

All numeric values in the UI must use fmtPrice / fmtLarge / fmtPct / fmtEgld and the tabular-nums CSS class.


🌐 EGLD / MultiversX

CryptoTraderPro has first-class support for the MultiversX ecosystem:

/egld β€” Main Dashboard

  • 8 KPI cards: EGLD Price (live WS ● LIVE), 24h%, Market Cap, Staking APR, Total Staked, Validators, Total Transactions, Total Accounts
  • Wallet Inspector β€” enter any erd1... address, validates bech32, navigates to Address Detail
  • Quick Links β€” Explorer Β· xExchange Β· xPortal Β· Docs Β· Staking Providers
  • PriceFlash on EGLD price + LiveDot indicator

/egld/[address] β€” Address Inspector

  • EGLD balance + USD value (calculated from live WS price)
  • MultiversX username (@alias) if registered
  • ESDT tokens list β€” logo, identifier, balance with correct decimals
  • NFT/SFT count
  • Recent transactions β€” status icon (↑ send / ↓ receive), hash, action label, value, timestamp
  • CopyButton on address Β· direct link to Explorer

API Routes

Route Data Revalidate
GET /api/egld economics + stats aggregated 30s
GET /api/egld/address/[address] account + tokens + nfts + txs 15s

Data source

https://api.multiversx.com/economics
https://api.multiversx.com/stats
https://api.multiversx.com/accounts/{address}
https://api.multiversx.com/accounts/{address}/tokens
https://api.multiversx.com/accounts/{address}/nfts?size=1
https://api.multiversx.com/accounts/{address}/transactions?size=10

🀝 Extending the App

Task Where to add
New coin WS support src/lib/cgToBinance.ts
New external API src/lib/api/{service}.ts + src/app/api/{service}/route.ts
New Zustand store src/store/{name}Store.ts with persist middleware
New page src/app/{route}/page.tsx + entry in sitemap.ts
New WS hook Build on useLivePrices β€” never raw Binance WS
New UI component src/components/ui/ β€” use Nexus CSS variables only

πŸ—ΊοΈ Roadmap

Feature Status
Dashboard top coins + search Cmd+K βœ… v0.5.0
Keyboard shortcuts globale βœ… v0.5.0
ErrorBoundary + Axios retry 429 βœ… v0.5.0
Sitemap dinamic SEO βœ… v0.5.0
priceFeed singleton WS βœ… v0.7.0
CoinNewsFeed β†’ CryptoPanicFeed βœ… v0.7.0
usePortfolioLivePrices + pie chart βœ… v0.8.0
Live dot ● per row portfolio βœ… v0.8.0
PriceFlash animaΘ›ie preΘ› schimbat βœ… v0.9.0
24h% per row portfolio (from WS) βœ… v0.9.0
/alerts page cu Notification API βœ… v0.9.0
/compare dual-chart normalizat βœ… v0.10.0
/backtest SMA crossover βœ… v0.10.0
/egld MultiversX dashboard complet βœ… v0.11.0
/egld/[address] Address Inspector βœ… v0.11.0
LiveDot + CopyButton components βœ… v0.11.0
Supabase auth + cloud sync portfolio πŸ”² v1.0.0
Mobile PWA + push notifications πŸ”² v1.0.0
xExchange DEX integration πŸ”² v1.0.0
Multi-chain support (ETH, SOL) πŸ”² v1.1.0

πŸ“¦ Deployment

Auto-deployed to GitHub Pages via GitHub Actions on every push to main.

# .github/workflows/deploy.yml:
# 1. npm ci + next build
# 2. next export β†’ /out
# 3. Deploy /out to gh-pages branch

Live URL: https://gzeu.github.io/CryptoTraderPro


🀝 Contributing

git checkout -b feat/your-feature
npm run dev
npm run type-check
git push origin feat/your-feature
# Open Pull Request

Follow existing code style (Prettier + ESLint config included).


πŸ“„ License

MIT Β© Gzeu

About

πŸš€ Next.js 14 crypto trading dashboard with real-time charts, portfolio tracking, and TradingView integration. Built with TypeScript, shadcn/ui, and Lightweight Charts.

Topics

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors