Skip to content

imokokok/Insight

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

439 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Insight - Oracle Data Analytics Platform

Insight is a professional oracle data analytics platform that provides comprehensive analysis and comparison of mainstream oracle protocols including Chainlink, Pyth, API3, RedStone, DIA, and WINkLink.

Key Features

  • Real-time Price Monitoring - Live price feeds from multiple oracle providers with real-time updates
  • Cross-Oracle Price Comparison - Compare prices across different oracles for the same asset
  • Cross-Chain Performance Analysis - Analyze oracle performance across multiple blockchain networks
  • Price Alerts & Notifications - Configure custom price alerts with multiple trigger conditions
  • User Favorites & Snapshots - Save and share price snapshots and favorite configurations
  • Data Export - Export data in CSV, JSON, Excel, PDF, and PNG formats
  • Internationalization - Full support for English and Chinese (zh-CN)
  • Anomaly Detection - Automatic detection of price anomalies and outliers
  • Technical Indicators - RSI, MACD, Bollinger Bands, ATR, and more
  • Data Transparency - Data source indicators and update time tracking
  • Accessibility Support - Keyboard navigation, colorblind mode, screen reader support

Technology Stack

Frontend

  • Framework: Next.js 16.1.6 (App Router)
  • UI Library: React 19.2.3
  • Language: TypeScript 5.x
  • Styling: Tailwind CSS 4.x
  • State Management: React Query 5.90.21, Zustand 5.0.11
  • Charts: Recharts 3.8.0
  • Animations: Framer Motion 12.36.0
  • Internationalization: next-intl 4.8.3

Backend

  • API: Next.js API Routes
  • Database: Supabase 2.98.0 (PostgreSQL with Row Level Security)
  • Authentication: Supabase Auth with OAuth support
  • Real-time: WebSocket, Supabase Realtime
  • Error Tracking: Sentry 10.43.0

Oracle Clients

  • Pyth Hermes Client (@pythnetwork/hermes-client 2.0.0)
  • Pyth Price Service SDK (@pythnetwork/price-service-sdk 1.8.0)
  • API3 Contracts (@api3/contracts 27.0.0)
  • Custom oracle clients for all supported providers (Chainlink, Pyth, API3, RedStone, DIA, WINkLink)

Prerequisites

  • Node.js 18.x or higher
  • npm or yarn
  • Supabase account (for database and authentication)

Installation

  1. Clone the repository:

    git clone <repository-url>
    cd insight
  2. Install dependencies:

    npm install
  3. Set up environment variables (see Environment Variables section below)

  4. Run the development server:

    npm run dev

Environment Variables

Create a .env.local file in the root directory with the following variables:

Variable Description Required
NEXT_PUBLIC_SUPABASE_URL Supabase project URL Yes
NEXT_PUBLIC_SUPABASE_ANON_KEY Supabase anonymous key Yes
NEXT_PUBLIC_APP_URL Application base URL No
NEXT_PUBLIC_WS_URL WebSocket server URL No
NEXT_PUBLIC_ENABLE_REALTIME Enable real-time features (default: true) No
NEXT_PUBLIC_ENABLE_ANALYTICS Enable Vercel Analytics No
NEXT_PUBLIC_ENABLE_PERFORMANCE_MONITORING Enable performance monitoring (Speed Insights) No

Example .env.local:

NEXT_PUBLIC_SUPABASE_URL=https://your-project.supabase.co
NEXT_PUBLIC_SUPABASE_ANON_KEY=your-anon-key
NEXT_PUBLIC_APP_URL=http://localhost:3000
NEXT_PUBLIC_WS_URL=ws://localhost:3001
NEXT_PUBLIC_ENABLE_REALTIME=true
NEXT_PUBLIC_ENABLE_ANALYTICS=true
NEXT_PUBLIC_ENABLE_PERFORMANCE_MONITORING=true

Available Scripts

Command Description
npm run dev Start development server
npm run build Build for production
npm run start Start production server
npm run lint Run ESLint
npm run lint:fix Run ESLint with auto-fix
npm run format Format code with Prettier
npm run format:check Check code formatting with Prettier
npm run typecheck Run TypeScript type checking
npm run validate Run lint, typecheck, and tests
npm run test Run Jest tests
npm run test:watch Run tests in watch mode
npm run test:coverage Run tests with coverage report
npm run test:e2e Run Playwright E2E tests
npm run test:e2e:ui Run Playwright E2E tests with UI
npm run clean:dev Clean .next and start dev server
npm run clean:start Clean .next, build and start server
npm run perf:test Run performance tests
npm run perf:quick Run quick performance check
npm run i18n:types Generate i18n types
npm run i18n:check Check i18n translations
npm run i18n:validate Validate i18n translations
npm run naming:check Check naming conventions
npm run prepare Prepare husky git hooks

Project Structure

insight/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ app/                    # Next.js App Router pages and API routes
β”‚   β”‚   β”œβ”€β”€ [locale]/           # Localized pages (next-intl)
β”‚   β”‚   β”‚   β”œβ”€β”€ alerts/         # Alerts management page
β”‚   β”‚   β”‚   β”œβ”€β”€ auth/           # Authentication pages
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ forgot-password/
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ resend-verification/
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ reset-password/
β”‚   β”‚   β”‚   β”‚   └── verify-email/
β”‚   β”‚   β”‚   β”œβ”€β”€ cross-chain/    # Cross-chain analysis page
β”‚   β”‚   β”‚   β”œβ”€β”€ cross-oracle/   # Cross-oracle comparison page
β”‚   β”‚   β”‚   β”œβ”€β”€ docs/           # Documentation page
β”‚   β”‚   β”‚   β”œβ”€β”€ favorites/      # User favorites page
β”‚   β”‚   β”‚   β”œβ”€β”€ home-components/# Homepage components
β”‚   β”‚   β”‚   β”œβ”€β”€ login/          # Login page
β”‚   β”‚   β”‚   β”œβ”€β”€ price-query/    # Price query page
β”‚   β”‚   β”‚   β”œβ”€β”€ register/       # Registration page
β”‚   β”‚   β”‚   └── settings/       # User settings page
β”‚   β”‚   β”œβ”€β”€ api/                # API endpoints
β”‚   β”‚   β”‚   β”œβ”€β”€ alerts/         # Price alerts API
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ batch/      # Batch alert operations
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ events/     # Alert events API
β”‚   β”‚   β”‚   β”‚   └── [id]/       # Individual alert endpoints
β”‚   β”‚   β”‚   β”œβ”€β”€ auth/           # Authentication callbacks
β”‚   β”‚   β”‚   β”œβ”€β”€ favorites/      # User favorites API
β”‚   β”‚   β”‚   β”œβ”€β”€ health/         # Health check endpoint
β”‚   β”‚   β”‚   β”œβ”€β”€ oracles/        # Oracle data API
β”‚   β”‚   β”‚   β”‚   └── [provider]/ # Provider-specific endpoints
β”‚   β”‚   β”‚   └── prices/         # Prices API
β”‚   β”‚   β”œβ”€β”€ error.tsx           # Error boundary
β”‚   β”‚   β”œβ”€β”€ global-error.tsx    # Global error handler
β”‚   β”‚   β”œβ”€β”€ layout.tsx          # Root layout
β”‚   β”‚   β”œβ”€β”€ not-found.tsx       # 404 page
β”‚   β”‚   β”œβ”€β”€ globals.css         # Global styles
β”‚   β”‚   └── favicon.ico         # Favicon
β”‚   β”œβ”€β”€ components/             # React components
β”‚   β”‚   β”œβ”€β”€ accessibility/      # Accessibility components
β”‚   β”‚   β”œβ”€β”€ alerts/             # Alert components
β”‚   β”‚   β”œβ”€β”€ charts/             # Chart components
β”‚   β”‚   β”œβ”€β”€ data-transparency/  # Data transparency components
β”‚   β”‚   β”œβ”€β”€ error-boundary/     # Error boundary components
β”‚   β”‚   β”œβ”€β”€ export/             # Export components
β”‚   β”‚   β”œβ”€β”€ favorites/          # Favorite components
β”‚   β”‚   β”œβ”€β”€ navigation/         # Navigation components
β”‚   β”‚   β”œβ”€β”€ realtime/           # Real-time components
β”‚   β”‚   β”œβ”€β”€ search/             # Search components
β”‚   β”‚   β”œβ”€β”€ settings/           # Settings components
β”‚   β”‚   β”œβ”€β”€ shortcuts/          # Keyboard shortcuts
β”‚   β”‚   β”œβ”€β”€ ui/                 # Reusable UI components
β”‚   β”‚   β”‚   β”œβ”€β”€ DataTablePro/   # Advanced data table
β”‚   β”‚   β”‚   └── selectors/      # Selector components
β”‚   β”‚   β”œβ”€β”€ AppInitializer.tsx  # App initializer
β”‚   β”‚   β”œβ”€β”€ Footer.tsx          # Footer component
β”‚   β”‚   β”œβ”€β”€ LanguageSwitcher.tsx# Language switcher
β”‚   β”‚   β”œβ”€β”€ Navbar.tsx          # Navigation bar
β”‚   β”‚   └── PerformanceMetricsCollector.tsx
β”‚   β”œβ”€β”€ hooks/                  # Custom React hooks
β”‚   β”‚   β”œβ”€β”€ data/               # Data fetching hooks
β”‚   β”‚   β”œβ”€β”€ oracles/            # Oracle-specific hooks
β”‚   β”‚   β”œβ”€β”€ ui/                 # UI hooks
β”‚   β”‚   └── utils/              # Utility hooks
β”‚   β”œβ”€β”€ lib/                    # Core libraries
β”‚   β”‚   β”œβ”€β”€ analytics/          # Analytics utilities
β”‚   β”‚   β”œβ”€β”€ api/                # API utilities
β”‚   β”‚   β”‚   β”œβ”€β”€ client/         # API client with interceptors
β”‚   β”‚   β”‚   β”œβ”€β”€ middleware/     # API middleware (auth, rate limit, validation)
β”‚   β”‚   β”‚   β”œβ”€β”€ recovery/       # Error recovery
β”‚   β”‚   β”‚   β”œβ”€β”€ response/       # Response builders
β”‚   β”‚   β”‚   β”œβ”€β”€ retry/          # Retry logic
β”‚   β”‚   β”‚   β”œβ”€β”€ types/          # API types
β”‚   β”‚   β”‚   β”œβ”€β”€ validation/     # Validation schemas (Zod)
β”‚   β”‚   β”‚   └── versioning/     # API versioning
β”‚   β”‚   β”œβ”€β”€ config/             # Configuration files
β”‚   β”‚   β”œβ”€β”€ constants/          # Application constants
β”‚   β”‚   β”œβ”€β”€ di/                 # Dependency injection
β”‚   β”‚   β”œβ”€β”€ errors/             # Error handling
β”‚   β”‚   β”œβ”€β”€ export/             # Data export utilities
β”‚   β”‚   β”œβ”€β”€ i18n/               # i18n provider
β”‚   β”‚   β”œβ”€β”€ indicators/         # Technical indicators
β”‚   β”‚   β”œβ”€β”€ logger/             # Logging utilities
β”‚   β”‚   β”œβ”€β”€ monitoring/         # Performance monitoring
β”‚   β”‚   β”œβ”€β”€ oracles/            # Oracle client implementations
β”‚   β”‚   β”‚   β”œβ”€β”€ api3/           # API3 client and services
β”‚   β”‚   β”‚   β”œβ”€β”€ base/           # Base oracle client
β”‚   β”‚   β”‚   β”œβ”€β”€ constants/      # Oracle constants
β”‚   β”‚   β”‚   β”œβ”€β”€ pyth/           # Pyth client and services
β”‚   β”‚   β”‚   β”œβ”€β”€ api3.ts         # API3 client
β”‚   β”‚   β”‚   β”œβ”€β”€ base.ts         # BaseOracleClient abstract class
β”‚   β”‚   β”‚   β”œβ”€β”€ chainlink.ts    # Chainlink client
β”‚   β”‚   β”‚   β”œβ”€β”€ colors.ts       # Oracle colors
β”‚   β”‚   β”‚   β”œβ”€β”€ dia.ts          # DIA client
β”‚   β”‚   β”‚   β”œβ”€β”€ diaDataService.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ diaNFTService.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ diaNetworkService.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ diaPriceService.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ factory.ts      # OracleClientFactory
β”‚   β”‚   β”‚   β”œβ”€β”€ interfaces.ts   # Oracle interfaces
β”‚   β”‚   β”‚   β”œβ”€β”€ memoryManager.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ oracle-config.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ oracleDataUtils.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ performanceMetricsCalculator.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ pythConstants.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ pythDataService.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ pythHermesClient.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ pythNetwork.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ pythPublishersData.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ redstone.ts     # RedStone client
β”‚   β”‚   β”‚   β”œβ”€β”€ redstoneConstants.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ storage.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ supportedSymbols.ts
β”‚   β”‚   β”‚   └── winklink.ts     # WINkLink client
β”‚   β”‚   β”œβ”€β”€ queries/            # React Query keys and client
β”‚   β”‚   β”œβ”€β”€ realtime/           # Real-time communication
β”‚   β”‚   β”œβ”€β”€ security/           # Security utilities
β”‚   β”‚   β”œβ”€β”€ services/           # External services
β”‚   β”‚   β”‚   β”œβ”€β”€ marketData/     # Market data services
β”‚   β”‚   β”‚   β”‚   └── defiLlamaApi/
β”‚   β”‚   β”‚   └── oracle/         # Oracle services
β”‚   β”‚   β”œβ”€β”€ snapshots/          # Snapshot management
β”‚   β”‚   β”œβ”€β”€ supabase/           # Supabase client and utilities
β”‚   β”‚   β”œβ”€β”€ utils/              # Utility functions
β”‚   β”‚   β”‚   └── chartExport/    # Chart export utilities
β”‚   β”‚   └── validation/         # Validation utilities
β”‚   β”œβ”€β”€ stores/                 # Zustand stores
β”‚   β”‚   β”œβ”€β”€ authStore.ts        # Authentication state
β”‚   β”‚   β”œβ”€β”€ crossChainStore.ts  # Cross-chain analysis state
β”‚   β”‚   β”œβ”€β”€ realtimeStore.ts    # Real-time data state
β”‚   β”‚   β”œβ”€β”€ selectors.ts        # Store selectors
β”‚   β”‚   └── uiStore.ts          # UI state
β”‚   β”œβ”€β”€ types/                  # TypeScript type definitions
β”‚   β”‚   β”œβ”€β”€ oracle/             # Oracle types
β”‚   β”‚   β”œβ”€β”€ api/                # API types
β”‚   β”‚   β”œβ”€β”€ ui/                 # UI types
β”‚   β”‚   β”œβ”€β”€ auth/               # Auth types
β”‚   β”‚   └── common/             # Common types
β”‚   β”œβ”€β”€ i18n/                   # Internationalization
β”‚   β”‚   β”œβ”€β”€ messages/           # Translation messages
β”‚   β”‚   β”‚   β”œβ”€β”€ en/             # English translations
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ components/
β”‚   β”‚   β”‚   β”‚   └── features/
β”‚   β”‚   β”‚   β”œβ”€β”€ zh-CN/          # Chinese translations
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ components/
β”‚   β”‚   β”‚   β”‚   └── features/
β”‚   β”‚   β”‚   β”œβ”€β”€ common.json
β”‚   β”‚   β”‚   β”œβ”€β”€ home.json
β”‚   β”‚   β”‚   └── navigation.json
β”‚   β”‚   β”œβ”€β”€ config.ts
β”‚   β”‚   β”œβ”€β”€ generated-types.ts
β”‚   β”‚   β”œβ”€β”€ request.ts
β”‚   β”‚   β”œβ”€β”€ routing.ts
β”‚   β”‚   └── types.ts
β”‚   └── __mocks__/              # Test mocks
β”œβ”€β”€ e2e/                        # E2E tests
β”‚   β”œβ”€β”€ home.spec.ts
β”‚   β”œβ”€β”€ oracle-data.spec.ts
β”‚   └── price-query.spec.ts
β”œβ”€β”€ public/                     # Static assets
β”‚   └── logos/                  # Logo assets
β”‚       β”œβ”€β”€ cryptos/            # Cryptocurrency logos
β”‚       └── oracles/            # Oracle logos
β”œβ”€β”€ scripts/                    # Utility scripts
β”‚   β”œβ”€β”€ generate-i18n-types.js  # i18n type generation
β”‚   β”œβ”€β”€ check-i18n.js           # i18n validation
β”‚   β”œβ”€β”€ check-naming-convention.js
β”‚   β”œβ”€β”€ performance-test.ts     # Performance testing
β”‚   └── quick-perf.mjs          # Quick performance check
β”œβ”€β”€ next.config.ts              # Next.js configuration
β”œβ”€β”€ tsconfig.json               # TypeScript configuration
β”œβ”€β”€ jest.config.js              # Jest configuration
β”œβ”€β”€ playwright.config.ts        # Playwright configuration
β”œβ”€β”€ eslint.config.mjs           # ESLint configuration
β”œβ”€β”€ .husky/                     # Husky git hooks
└── .trae/rules/                # Trae IDE rules
    β”œβ”€β”€ project_rules.md
    └── ui-redesign-rules.md

Supported Oracles

Chainlink

  • Supported Chains: Ethereum, Arbitrum, Optimism, Polygon, Avalanche, Base, BNB Chain, Fantom, Starknet, Blast, Moonbeam, Kava, Polkadot
  • Features: Node analytics, extensive data feeds, high reliability

Pyth

  • Supported Chains: Solana, Ethereum, Arbitrum, Polygon, Optimism, Avalanche, Base, Starknet, Blast, Sui, Aptos, Injective, Sei
  • Features: Publisher analytics, high-frequency updates, confidence intervals

API3

  • Supported Chains: Ethereum, Arbitrum, Polygon, Avalanche, Base, BNB Chain, Optimism, Moonbeam, Kava, Fantom, Gnosis, Linea, Scroll
  • Features: First-party oracle, quantifiable security, Airnode deployments

RedStone

  • Supported Chains: Ethereum, Arbitrum, Optimism, Polygon, Avalanche, Base, BNB Chain, Fantom, Linea, Mantle, Scroll, zkSync, Blast, Starknet, Aptos, Sui
  • Features: Modular oracle design, data streams, cross-chain support

DIA

  • Supported Chains: Ethereum, Arbitrum, Polygon, Avalanche, BNB Chain, Base, Optimism, Fantom, Cronos, Moonbeam, Gnosis, Kava, Solana, Sui, Aptos, Injective, Sei, Cosmos, Osmosis, Juno, Celestia, Tron, TON, Near, Aurora, Celo, Starknet, Blast, Cardano, Polkadot, Mantle, Linea, Scroll, zkSync, Moonriver, Metis, StarkEx
  • Features: Open-source cross-chain oracle, NFT floor price data feeds, transparent methodology, comprehensive token on-chain data (supply, market cap, exchange volume)
  • Data Services: DIADataService with dedicated PriceService, NFTService, and NetworkService modules

WINkLink

  • Supported Chains: BNB Chain, TRON, Ethereum
  • Features: TRON ecosystem integration, gaming data feeds, entertainment focus

Database Schema

The application uses Supabase (PostgreSQL) with the following main tables:

  • user_profiles - User preferences and settings
  • price_records - Historical price data from oracles
  • user_snapshots - User-saved price snapshots
  • user_favorites - User favorite configurations
  • price_alerts - Price alert configurations
  • alert_events - Alert trigger event history

All tables have Row Level Security (RLS) enabled for data protection.

API Endpoints

Authentication

  • GET /api/auth/callback - OAuth callback handler
  • GET /api/auth/profile - Get user profile

Alerts

  • GET /api/alerts - List user alerts
  • POST /api/alerts - Create new alert
  • GET /api/alerts/[id] - Get specific alert
  • PUT /api/alerts/[id] - Update alert
  • DELETE /api/alerts/[id] - Delete alert
  • GET /api/alerts/events - List alert events
  • POST /api/alerts/events/[id]/acknowledge - Acknowledge alert event
  • POST /api/alerts/batch - Batch alert operations

Favorites

  • GET /api/favorites - List user favorites
  • POST /api/favorites - Create favorite
  • GET /api/favorites/[id] - Get specific favorite
  • DELETE /api/favorites/[id] - Delete favorite

Oracles

  • GET /api/oracles - List all oracle providers
  • POST /api/oracles - Create oracle configuration
  • GET /api/oracles/[provider] - Get specific oracle data
  • PUT /api/oracles/[provider] - Update oracle configuration

System

  • GET /api/health - Health check

Code Quality

This project adopts strict code quality standards to ensure maintainability and reliability:

Code Standards

  • ESLint: TypeScript ESLint ruleset with strict type checking
  • Prettier: Unified code formatting configuration
  • TypeScript: Strict type checking configuration (strict: true)
  • Naming Conventions: Unified file and variable naming conventions

Quality Check Scripts

# Run ESLint check
npm run lint

# Auto-fix ESLint issues
npm run lint:fix

# Run type checking
npm run typecheck

# Run all tests
npm run test

# Run test coverage check
npm run test:coverage

# Run full validation (lint + typecheck + test)
npm run validate

# Check naming conventions
npm run naming:check

Code Quality Metrics

  • Test Coverage: Target 80%+
  • Type Safety: 100% TypeScript coverage
  • Lint Pass Rate: Zero errors, minimized warnings
  • Build Success Rate: 100%

Continuous Improvement

  • Regularly run npm run validate to ensure code quality
  • Use npm run lint:fix to auto-fix formatting issues
  • Ensure all tests pass before committing

Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Ensure code passes all quality checks (npm run validate)
  4. Commit your changes (git commit -m 'Add amazing feature')
  5. Push to the branch (git push origin feature/amazing-feature)
  6. Open a Pull Request

License

This project is private and proprietary.

Acknowledgments

About

No description, website, or topics provided.

Resources

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages