Spaces:
Sleeping
Sleeping
Delete LEADERBOARD_ROADMAP.md
Browse files- LEADERBOARD_ROADMAP.md +0 -171
LEADERBOARD_ROADMAP.md
DELETED
|
@@ -1,171 +0,0 @@
|
|
| 1 |
-
# Cloze Reader Leaderboard Implementation Roadmap
|
| 2 |
-
|
| 3 |
-
## Overview
|
| 4 |
-
This document outlines the implementation plan for adding a competitive leaderboard system to the Cloze Reader game, where players can submit their scores using 3-letter acronyms.
|
| 5 |
-
|
| 6 |
-
## Phase 1: Core Infrastructure (Week 1-2)
|
| 7 |
-
|
| 8 |
-
### 1.1 Database Schema
|
| 9 |
-
- Create leaderboard table structure:
|
| 10 |
-
```sql
|
| 11 |
-
leaderboard {
|
| 12 |
-
id: UUID
|
| 13 |
-
acronym: VARCHAR(3)
|
| 14 |
-
score: INTEGER
|
| 15 |
-
level_reached: INTEGER
|
| 16 |
-
total_time: INTEGER (seconds)
|
| 17 |
-
created_at: TIMESTAMP
|
| 18 |
-
ip_hash: VARCHAR(64) // For rate limiting
|
| 19 |
-
}
|
| 20 |
-
```
|
| 21 |
-
|
| 22 |
-
### 1.2 API Endpoints
|
| 23 |
-
- `POST /api/leaderboard/submit` - Submit new score
|
| 24 |
-
- `GET /api/leaderboard/top/{period}` - Get top scores (daily/weekly/all-time)
|
| 25 |
-
- `GET /api/leaderboard/check-acronym/{acronym}` - Validate acronym availability
|
| 26 |
-
|
| 27 |
-
### 1.3 Score Calculation
|
| 28 |
-
- Base score = (correct_answers * 100) * level_multiplier
|
| 29 |
-
- Time bonus = max(0, 1000 - seconds_per_round)
|
| 30 |
-
- Streak bonus = consecutive_correct * 50
|
| 31 |
-
|
| 32 |
-
## Phase 2: Frontend Integration (Week 2-3)
|
| 33 |
-
|
| 34 |
-
### 2.1 UI Components
|
| 35 |
-
- **Leaderboard Modal** (`leaderboardModal.js`)
|
| 36 |
-
- Top 10 display with rank, acronym, score, level
|
| 37 |
-
- Period toggle (Today/Week/All-Time)
|
| 38 |
-
- Personal best highlight
|
| 39 |
-
|
| 40 |
-
### 2.2 Score Submission Flow
|
| 41 |
-
- End-of-game prompt for acronym entry
|
| 42 |
-
- 3-letter validation (A-Z only)
|
| 43 |
-
- Profanity filter implementation
|
| 44 |
-
- Success/error feedback
|
| 45 |
-
|
| 46 |
-
### 2.3 Visual Elements
|
| 47 |
-
- Trophy icons for top 3 positions
|
| 48 |
-
- Animated score counter
|
| 49 |
-
- Level badges display
|
| 50 |
-
|
| 51 |
-
## Phase 3: Security & Performance (Week 3-4)
|
| 52 |
-
|
| 53 |
-
### 3.1 Anti-Cheat Measures
|
| 54 |
-
- Server-side score validation
|
| 55 |
-
- Rate limiting (1 submission per 5 minutes per IP)
|
| 56 |
-
- Score feasibility checks (max possible score per level)
|
| 57 |
-
- Request signing with session tokens
|
| 58 |
-
|
| 59 |
-
### 3.2 Caching Strategy
|
| 60 |
-
- Redis cache for top 100 scores
|
| 61 |
-
- 5-minute TTL for leaderboard queries
|
| 62 |
-
- Real-time updates for top 10 changes
|
| 63 |
-
|
| 64 |
-
### 3.3 Data Persistence
|
| 65 |
-
- PostgreSQL for primary storage
|
| 66 |
-
- Daily backups of leaderboard data
|
| 67 |
-
- Archived monthly snapshots
|
| 68 |
-
|
| 69 |
-
## Phase 4: Advanced Features (Week 4-5)
|
| 70 |
-
|
| 71 |
-
### 4.1 Achievement System
|
| 72 |
-
- "First Timer" - First leaderboard entry
|
| 73 |
-
- "Vocabulary Master" - 10+ correct in a row
|
| 74 |
-
- "Speed Reader" - Complete round < 30 seconds
|
| 75 |
-
- "Persistent Scholar" - Play 7 days straight
|
| 76 |
-
|
| 77 |
-
### 4.2 Social Features
|
| 78 |
-
- Share score to social media
|
| 79 |
-
- Challenge link generation
|
| 80 |
-
- Friend acronym tracking
|
| 81 |
-
|
| 82 |
-
### 4.3 Analytics Dashboard
|
| 83 |
-
- Player retention metrics
|
| 84 |
-
- Popular acronym analysis
|
| 85 |
-
- Score distribution graphs
|
| 86 |
-
|
| 87 |
-
## Technical Implementation Details
|
| 88 |
-
|
| 89 |
-
### Backend Changes Required
|
| 90 |
-
|
| 91 |
-
1. **FastAPI Endpoints** (`app.py`):
|
| 92 |
-
```python
|
| 93 |
-
@app.post("/api/leaderboard/submit")
|
| 94 |
-
async def submit_score(score_data: ScoreSubmission)
|
| 95 |
-
|
| 96 |
-
@app.get("/api/leaderboard/top/{period}")
|
| 97 |
-
async def get_leaderboard(period: str, limit: int = 10)
|
| 98 |
-
```
|
| 99 |
-
|
| 100 |
-
2. **Database Models** (`models.py` - new file):
|
| 101 |
-
```python
|
| 102 |
-
class LeaderboardEntry(Base):
|
| 103 |
-
__tablename__ = "leaderboard"
|
| 104 |
-
# Schema implementation
|
| 105 |
-
```
|
| 106 |
-
|
| 107 |
-
3. **Validation Service** (`validation.py` - new file):
|
| 108 |
-
- Acronym format validation
|
| 109 |
-
- Profanity checking
|
| 110 |
-
- Score feasibility verification
|
| 111 |
-
|
| 112 |
-
### Frontend Changes Required
|
| 113 |
-
|
| 114 |
-
1. **Game Engine Integration** (`clozeGameEngine.js`):
|
| 115 |
-
- Track game metrics for scoring
|
| 116 |
-
- Call submission API on game end
|
| 117 |
-
- Store session data for validation
|
| 118 |
-
|
| 119 |
-
2. **UI Updates** (`app.js`):
|
| 120 |
-
- Add leaderboard button to main menu
|
| 121 |
-
- Integrate submission modal
|
| 122 |
-
- Handle API responses
|
| 123 |
-
|
| 124 |
-
3. **New Modules**:
|
| 125 |
-
- `leaderboardService.js` - API communication
|
| 126 |
-
- `scoreCalculator.js` - Client-side scoring logic
|
| 127 |
-
- `leaderboardUI.js` - UI component management
|
| 128 |
-
|
| 129 |
-
## Deployment Considerations
|
| 130 |
-
|
| 131 |
-
### Infrastructure Requirements
|
| 132 |
-
- Database: PostgreSQL 14+
|
| 133 |
-
- Cache: Redis 6+
|
| 134 |
-
- API rate limiting: nginx or API Gateway
|
| 135 |
-
- SSL certificate for secure submissions
|
| 136 |
-
|
| 137 |
-
### Environment Variables
|
| 138 |
-
```
|
| 139 |
-
DATABASE_URL=postgresql://...
|
| 140 |
-
REDIS_URL=redis://...
|
| 141 |
-
LEADERBOARD_SECRET=... # For request signing
|
| 142 |
-
PROFANITY_API_KEY=... # Optional external service
|
| 143 |
-
```
|
| 144 |
-
|
| 145 |
-
### Migration Strategy
|
| 146 |
-
1. Deploy database schema
|
| 147 |
-
2. Enable API endpoints (feature flagged)
|
| 148 |
-
3. Gradual UI rollout (A/B testing)
|
| 149 |
-
4. Full launch with announcement
|
| 150 |
-
|
| 151 |
-
## Success Metrics
|
| 152 |
-
|
| 153 |
-
- **Engagement**: 30% of players submit scores
|
| 154 |
-
- **Retention**: 15% return to beat their score
|
| 155 |
-
- **Performance**: <100ms leaderboard load time
|
| 156 |
-
- **Security**: Zero validated cheating incidents
|
| 157 |
-
|
| 158 |
-
## Timeline Summary
|
| 159 |
-
|
| 160 |
-
- **Week 1-2**: Backend infrastructure
|
| 161 |
-
- **Week 2-3**: Frontend integration
|
| 162 |
-
- **Week 3-4**: Security hardening
|
| 163 |
-
- **Week 4-5**: Advanced features
|
| 164 |
-
- **Week 6**: Testing & deployment
|
| 165 |
-
|
| 166 |
-
## Open Questions
|
| 167 |
-
|
| 168 |
-
1. Should we allow Unicode characters in acronyms?
|
| 169 |
-
2. Reset frequency for periodic leaderboards?
|
| 170 |
-
3. Maximum entries per player per day?
|
| 171 |
-
4. Prize/reward system for top performers?
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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