Skip to main content

System Architecture

Predinex is built as a modular, scalable platform that combines multiple technologies to deliver a seamless prediction market experience. This page provides a high-level overview of our system components and data flow.

๐Ÿ—๏ธ Architecture Overviewโ€‹

๐ŸŽฏ Core Componentsโ€‹

๐ŸŒ Frontend Layerโ€‹

Progressive Web App built for optimal user experience:

  • React/Next.js for responsive UI
  • Web3 wallet integration (MetaMask, WalletConnect)
  • Real-time updates via WebSocket connections
  • Mobile-optimized design for prediction on the go

โ›“๏ธ Blockchain Layer (BSC Network)โ€‹

Smart contracts that handle all core logic:

๐Ÿ“Š PredinexPool Contractโ€‹

  • Pool creation and management
  • Bet placement and liquidity provision
  • Settlement and payout distribution
  • Reputation tracking and access control

๐Ÿ”ฎ Guided Oracle Contractโ€‹

  • Automated outcome resolution
  • Integration with external data sources
  • Fraud protection and validation

๐Ÿ—ณ๏ธ Optimistic Oracle Contractโ€‹

  • Community-driven outcome proposals
  • Dispute resolution mechanism
  • Bonding and challenge system

๐ŸŽฎ Oddyssey Contractโ€‹

  • Daily game creation and management
  • Slip submission and scoring
  • Leaderboard and prize distribution

๐Ÿ”— Backend Infrastructureโ€‹

Scalable services that support the frontend and contracts:

๐Ÿ“ก API Serverโ€‹

  • RESTful endpoints for pool data
  • Real-time analytics and statistics
  • User management and reputation tracking
  • Rate limiting and caching

โšก Event Indexerโ€‹

  • Real-time blockchain event processing
  • Database synchronization
  • Analytics data aggregation
  • Notification triggers

๐Ÿค– Oracle Botโ€‹

  • Automated outcome submission
  • Data verification and validation
  • Transaction scheduling and retry logic
  • Error handling and alerting

๐Ÿ“Š Data Fetcherโ€‹

  • Scheduled API calls to external sources
  • Data transformation and normalization
  • Database storage and caching
  • API rate limit management

๐Ÿ’พ Data Layerโ€‹

PostgreSQL database with optimized schemas:

  • Core: User accounts and reputation
  • Oracle: External data from APIs
  • Prediction: Pool and bet tracking
  • Analytics: Aggregated statistics and metrics

๐Ÿ”„ Data Flowโ€‹

๐Ÿ“ˆ Pool Creation Flowโ€‹

  1. User creates pool via frontend
  2. Frontend calls smart contract
  3. PredinexPool emits PoolCreated event
  4. Indexer captures event and stores in database
  5. API serves updated pool data to frontend

๐ŸŽฏ Bet Placement Flowโ€‹

  1. User places bet via frontend
  2. Frontend validates bet constraints
  3. Smart contract processes bet and transfers tokens
  4. Indexer updates database with bet data
  5. API provides real-time updates to all users

๐Ÿ”ฎ Oracle Resolution Flowโ€‹

  1. Data Fetcher retrieves outcome from external API
  2. Database stores validated outcome data
  3. Oracle Bot submits outcome to smart contract
  4. Guided Oracle processes and validates outcome
  5. PredinexPool settles affected pools
  6. Indexer updates settlement data
  7. Users can claim winnings via frontend

๐Ÿ›ก๏ธ Security Architectureโ€‹

๐Ÿ” Smart Contract Securityโ€‹

  • Multi-signature deployment and upgrades
  • Timelock for critical parameter changes
  • Access control with role-based permissions
  • Reentrancy guards on all external calls
  • Overflow protection with SafeMath

๐Ÿ›ก๏ธ Oracle Securityโ€‹

  • Multiple data sources for cross-verification
  • Economic incentives for honest behavior
  • Dispute mechanisms for challenge periods
  • Slashing conditions for malicious actors

๐Ÿ”’ Infrastructure Securityโ€‹

  • API rate limiting to prevent abuse
  • Input validation on all endpoints
  • Database encryption at rest and in transit
  • Regular security audits and penetration testing

๐Ÿ“Š Scalability Designโ€‹

โšก Performance Optimizationsโ€‹

  • BSC Network: 400,000+ TPS capacity
  • Database indexing for fast queries
  • API caching with Redis
  • CDN integration for static assets

๐Ÿ“ˆ Growth Handlingโ€‹

  • Horizontal scaling of API servers
  • Database sharding for large datasets
  • Event processing with message queues
  • Microservices architecture for modularity

๐Ÿ”ง Monitoring & Analyticsโ€‹

  • Real-time metrics via Prometheus
  • Error tracking with Sentry
  • Performance monitoring with DataDog
  • User analytics with custom dashboards

๐ŸŒ Integration Pointsโ€‹

๐Ÿ“ก External APIsโ€‹

  • SportMonks: Live sports data and results
  • CoinGecko: Cryptocurrency prices and market data
  • Custom APIs: Additional data sources as needed

๐Ÿ”— Blockchain Integrationsโ€‹

  • BSC RPC: Primary blockchain connection
  • IPFS: Decentralized storage for metadata
  • The Graph: Optional subgraph for complex queries

๐Ÿ“ฑ Frontend Integrationsโ€‹

  • Wallet providers: MetaMask, WalletConnect, Coinbase
  • Analytics: Google Analytics, Mixpanel
  • Social features: Twitter, Discord integrations

๐Ÿš€ Deployment Strategyโ€‹

๐Ÿงช Development Environmentโ€‹

  • Local blockchain with Hardhat
  • Test databases with sample data
  • Mock APIs for development testing

๐Ÿ”ง Staging Environmentโ€‹

  • BSC testnet for contract testing
  • Staging database with production-like data
  • Integration testing with real APIs

๐ŸŒŸ Production Environmentโ€‹

  • BSC mainnet for live contracts
  • Production database with high availability
  • Load balancers and CDN for global access
  • Automated deployments with CI/CD

This architecture is designed to be modular, scalable, and secure while providing the best possible user experience for prediction markets.