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โ
- User creates pool via frontend
- Frontend calls smart contract
- PredinexPool emits
PoolCreatedevent - Indexer captures event and stores in database
- API serves updated pool data to frontend
๐ฏ Bet Placement Flowโ
- User places bet via frontend
- Frontend validates bet constraints
- Smart contract processes bet and transfers tokens
- Indexer updates database with bet data
- API provides real-time updates to all users
๐ฎ Oracle Resolution Flowโ
- Data Fetcher retrieves outcome from external API
- Database stores validated outcome data
- Oracle Bot submits outcome to smart contract
- Guided Oracle processes and validates outcome
- PredinexPool settles affected pools
- Indexer updates settlement data
- 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.