Skip to content

Francis6-git/-stellar-analytics-dashboard

Β 
Β 

Repository files navigation

Stellar Analytics Dashboard

A comprehensive analytics platform for the Stellar blockchain with real-time data ingestion, GraphQL API, and React visualization dashboard.

🌟 Features

  • Real-time Data Ingestion: Continuously polls Stellar Horizon API for ledgers, transactions, and operations
  • GraphQL API: High-performance API with complex aggregations and analytics queries
  • React Dashboard: Modern, responsive analytics interface with real-time charts
  • Soroban Support: Track smart contract deployments and interactions
  • DEX Analytics: Monitor asset volumes, liquidity pools, and trading activity
  • Account Profiling: Track account activity, balances, and portfolio performance
  • Transaction Explorer: Detailed transaction analysis with XDR decoding

πŸ—οΈ Architecture

stellar-analytics-dashboard/
β”œβ”€β”€ packages/
β”‚   β”œβ”€β”€ shared/          # Shared types and utilities
β”‚   β”œβ”€β”€ indexer/         # Node.js data ingestion service
β”‚   β”œβ”€β”€ api/            # Express GraphQL server
β”‚   └── frontend/       # React analytics dashboard
β”œβ”€β”€ docker-compose.yml   # Production deployment
β”œβ”€β”€ docker-compose.dev.yml # Development setup
└── README.md

Components

  • Indexer: Polls Horizon API, stores data in PostgreSQL, provides real-time updates
  • API: GraphQL server with analytics queries, caching, and subscriptions
  • Frontend: React dashboard with real-time charts and data visualization
  • Database: PostgreSQL for analytics data, Redis for caching

πŸš€ Quick Start

Prerequisites

  • Node.js 18+
  • Docker & Docker Compose
  • pnpm (recommended) or npm

Development Setup

  1. Clone the repository

    git clone https://github.com/Kevin737866/stellar-analytics-dashboard.git
    cd stellar-analytics-dashboard
  2. Install dependencies

    npm install -g pnpm
    pnpm install
  3. Start development environment

    # Start databases only
    docker-compose -f docker-compose.dev.yml up -d
    
    # Install dependencies and start services
    pnpm dev
  4. Access the applications

Production Deployment

  1. Build and deploy with Docker

    docker-compose up -d
  2. Access the applications

πŸ“Š Usage

GraphQL API

The GraphQL API provides access to all Stellar analytics data. Key queries include:

# Get network statistics
query GetStats {
  stats {
    totalTransactions
    totalAccounts
    volume24h
    successRate24h
    latestLedger
  }
}

# Get recent transactions
query GetTransactions($first: Int = 20) {
  transactions(pagination: { first: $first }) {
    edges {
      node {
        hash
        successful
        sourceAccount
        feeCharged
        createdAt
        operationCount
      }
    }
  }
}

# Get account details
query GetAccount($accountId: String!) {
  account(accountId: $accountId) {
    accountId
    balance
    sequenceNumber
    numSubentries
    thresholds
  }
}

Real-time Subscriptions

subscription OnNewLedger {
  ledgerAdded {
    sequence
    closedAt
    operationCount
    successfulTransactionCount
  }
}

Frontend Features

  • Dashboard: Overview of network metrics and activity
  • Network: Detailed network performance analytics
  • Accounts: Account explorer and profiling
  • Transactions: Transaction search and analysis
  • Assets: Asset analytics and DEX metrics

πŸ”§ Configuration

Environment Variables

Indexer (packages/indexer/.env)

DATABASE_URL=postgresql://user:password@localhost:5432/stellar_analytics
REDIS_URL=redis://localhost:6379
STELLAR_NETWORK=public
STELLAR_HORIZON_URL=https://horizon.stellar.org
PORT=3001
NODE_ENV=development
LOG_LEVEL=info

API (packages/api/.env)

DATABASE_URL=postgresql://user:password@localhost:5432/stellar_analytics
REDIS_URL=redis://localhost:6379
PORT=4000
NODE_ENV=development
CORS_ORIGIN=http://localhost:3000
LOG_LEVEL=info

Frontend (packages/frontend/.env)

VITE_API_URL=http://localhost:4000/graphql
VITE_WS_URL=ws://localhost:4000/graphql

Database Schema

The application uses PostgreSQL with the following main tables:

  • ledgers: Stellar ledger data
  • transactions: Transaction records
  • `operations: Operation details
  • accounts: Account information
  • assets: Asset metadata
  • network_metrics: Aggregated network statistics
  • asset_metrics: Asset-specific analytics
  • account_metrics: Account activity metrics

πŸ› οΈ Development

Package Scripts

# Root level
pnpm dev              # Start all services in development
pnpm build            # Build all packages
pnpm test             # Run all tests
pnpm lint             # Lint all packages

# Individual packages
pnpm --filter @stellar-analytics/indexer dev
pnpm --filter @stellar-analytics/api dev
pnpm --filter @stellar-analytics/frontend dev

Database Migrations

# Run migrations
pnpm --filter @stellar-analytics/indexer db:migrate

# Seed with initial data
pnpm --filter @stellar-analytics/indexer db:seed

Adding New Features

  1. Shared Types: Add new types to packages/shared/src/types/
  2. Database Schema: Update packages/indexer/src/database/schema.sql
  3. API Resolvers: Add resolvers to packages/api/src/resolvers/
  4. Frontend Components: Add components to packages/frontend/src/components/

πŸ“ˆ Monitoring

Health Checks

  • Indexer: GET /health
  • API: GET /health
  • Database: PostgreSQL health check
  • Redis: PING command

Metrics

  • Prometheus-compatible metrics at /metrics
  • Application logs in structured JSON format
  • Performance monitoring with Apollo Studio (optional)

πŸ”’ Security

  • Input validation with Zod schemas
  • SQL injection prevention with parameterized queries
  • Rate limiting on API endpoints
  • CORS configuration
  • Environment variable management
  • Non-root Docker containers

πŸ§ͺ Testing

# Run all tests
pnpm test

# Run tests for specific package
pnpm --filter @stellar-analytics/api test

# Run with coverage
pnpm test --coverage

πŸ“š API Reference

GraphQL Endpoints

  • Production: https://your-domain.com/graphql
  • Development: http://localhost:4000/graphql

REST Endpoints

  • Health Check: GET /health
  • Metrics: GET /metrics

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/amazing-feature
  3. Commit changes: git commit -m 'Add amazing feature'
  4. Push to branch: git push origin feature/amazing-feature
  5. Open a Pull Request

Development Guidelines

  • Follow TypeScript best practices
  • Use ESLint and Prettier formatting
  • Write tests for new features
  • Update documentation
  • Use conventional commit messages

πŸ“ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments

πŸ“ž Support

  • Create an issue on GitHub for bug reports
  • Join our Discord community for discussions
  • Check the documentation for common questions

Built with ❀️ for the Stellar ecosystem

About

Real-time analytics dashboard for the Stellar blockchain. Track network metrics, explore transactions, analyze accounts, and visualize DEX data with GraphQL API and React frontend. Pure Stellar - no Ethereum.

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • TypeScript 90.0%
  • PLpgSQL 4.7%
  • Dockerfile 2.4%
  • JavaScript 1.4%
  • CSS 1.2%
  • HTML 0.3%