File size: 7,038 Bytes
b2806e8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
---
title: WagerKit
emoji: ๐Ÿ“Š
colorFrom: purple
colorTo: blue
sdk: docker
pinned: false
license: mit
---

# WagerKit ๐ŸŽฏ

**Real-time prediction market analysis with integrity scoring**

WagerKit aggregates data from multiple prediction market sources (Polymarket, Kalshi, PredictIt) and provides comprehensive integrity analysis for each market.

## โœจ Features

- ๐Ÿ“ˆ **Multi-Source Aggregation**: Compare odds across leading prediction markets
- ๐ŸŽฏ **Integrity Scoring**: 4-component analysis (Clarity, Liquidity, Agreement, Volatility)
- ๐Ÿ“Š **Visual Analytics**: Real-time odds history charts with Chart.js
- ๐Ÿ“ฅ **Export Tools**: PDF dossiers, CSV data exports, JSON metadata
- โšก **Background Processing**: BullMQ-powered workers for instant dashboard loads
- ๐ŸŽจ **Modern UI**: Dark theme, responsive design with Tailwind CSS

## ๐Ÿ—๏ธ Architecture

```
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚      Docker Container (HF Space)    โ”‚
โ”‚                                     โ”‚
โ”‚  Redis โ”€โ”€โ–บ NestJS Backend (BullMQ) โ”‚
โ”‚              โ†“                      โ”‚
โ”‚         Next.js Frontend            โ”‚
โ”‚           (Port 7860)               โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
```

## ๐Ÿš€ Quick Start

### On Hugging Face Spaces

Simply clone this Space or visit the live demo!

### Local Development

```bash
# Clone the repository
git clone <your-repo-url>
cd wagerkit

# Start with Docker Compose
docker-compose up

# Or run individually:
# Terminal 1: Redis
docker run -d -p 6379:6379 redis:7-alpine

# Terminal 2: Backend
cd backend && npm install && npm run start:dev

# Terminal 3: Frontend
cd frontend && npm install && npm run dev
```

Access at: http://localhost:3000

## ๐Ÿ“Š Integrity Score Formula

**Overall Score** = 100 ร— (0.40ร—C + 0.30ร—L + 0.20ร—A + 0.10ร—V)

- **C** (Market Clarity): Resolution criteria quality, source coverage
- **L** (Liquidity Depth): Trading volume, update frequency
- **A** (Cross-Source Agreement): RMSE between sources
- **V** (Volatility Sanity): Price stability, spike detection

## ๐Ÿ› ๏ธ Tech Stack

**Backend:**
- NestJS 10 (TypeScript)
- BullMQ (background jobs)
- Redis (job queue & cache)

**Frontend:**
- Next.js 14 (App Router)
- React 18
- Chart.js (visualization)
- Tailwind CSS (styling)
- jsPDF (PDF export)

## ๐Ÿ“ฆ Deployment

See [DEPLOYMENT.md](./DEPLOYMENT.md) for detailed instructions on:
- Hugging Face Spaces setup
- Docker configuration
- Environment variables
- Local development

## ๐ŸŽฎ Usage

1. **Dashboard**: View all markets with processing status badges
2. **Click any card**: Navigate to detailed market analysis
3. **View Charts**: Compare historical odds across 4 sources
4. **Export Data**: Download PDF dossiers, CSV odds history, or JSON metadata

## ๐Ÿ“ Project Structure

```
wagerkit/
โ”œโ”€โ”€ backend/                 # NestJS backend
โ”‚   โ”œโ”€โ”€ src/
โ”‚   โ”‚   โ”œโ”€โ”€ markets/        # Markets module (BullMQ workers)
โ”‚   โ”‚   โ”œโ”€โ”€ auth/           # Auth module (unused in demo)
โ”‚   โ”‚   โ””โ”€โ”€ main.ts
โ”‚   โ”œโ”€โ”€ Dockerfile          # Backend Docker image
โ”‚   โ””โ”€โ”€ package.json
โ”œโ”€โ”€ frontend/               # Next.js frontend
โ”‚   โ”œโ”€โ”€ src/
โ”‚   โ”‚   โ”œโ”€โ”€ app/           # App router pages
โ”‚   โ”‚   โ”œโ”€โ”€ components/    # Reusable components
โ”‚   โ”‚   โ””โ”€โ”€ lib/           # API client
โ”‚   โ”œโ”€โ”€ Dockerfile         # Frontend Docker image
โ”‚   โ””โ”€โ”€ package.json
โ”œโ”€โ”€ Dockerfile             # Multi-stage build (HF Spaces)
โ”œโ”€โ”€ docker-compose.yml     # Local development
โ”œโ”€โ”€ DEPLOYMENT.md          # Detailed deployment guide
โ””โ”€โ”€ README.md
```

## ๐Ÿค Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

## ๐Ÿ“„ License

MIT License

## ๐Ÿ™ Acknowledgments

Built with data from leading prediction markets. This is a demonstration project showcasing real-time data aggregation and integrity analysis techniques.

---

**Documentation**: [DEPLOYMENT.md](./DEPLOYMENT.md)
Each market includes:
- **Integrity Score** (0-100) with 4 sub-components:
  - Market Clarity (40% weight)
  - Liquidity Depth (30% weight)
  - Cross-Source Agreement (20% weight)
  - Volatility Sanity (10% weight)
- **Odds History Chart** - 24-hour price trends from 3 sources
- **Data Sources** - Polymarket, Kalshi, PredictIt
- **Export Options**:
  - โœ… Download Dossier (PDF)
  - โœ… Download Dossier (JSON)
  - โœ… Export Odds CSV
  - โœ… Export Integrity CSV

## ๐Ÿ“Š Integrity Score Formula

```
Score = 100 ร— (0.40ร—C + 0.30ร—L + 0.20ร—A + 0.10ร—V)
```

Where:
- **C** = Market Clarity
- **L** = Liquidity Depth
- **A** = Cross-Source Agreement (RMSE-based)
- **V** = Volatility Sanity (includes spike detection)

## ๐Ÿ”ง Tech Stack

### Backend
- NestJS 10
- TypeScript
- JWT Authentication (ready but disabled)
- Express.js

### Frontend
- Next.js 14
- React 18
- TypeScript
- TailwindCSS
- Chart.js (for odds visualization)
- jsPDF (for PDF exports)

## ๐Ÿ“ API Endpoints

### Markets
- `GET /api/markets` - List all markets
- `GET /api/markets/:slug` - Get market detail with integrity scores
- `GET /api/markets/:slug/export/odds-csv` - Export odds history CSV
- `GET /api/markets/:slug/export/integrity-csv` - Export integrity scores CSV
- `GET /api/markets/:slug/export/dossier-json` - Export full dossier JSON

### Authentication (Optional)
- `POST /api/auth/login` - Login endpoint (not required for demo)

## ๐Ÿ”‘ Environment Variables

### Backend (`backend/.env`)
```env
JWT_SECRET=wagerkit-jwt-secret-key-2024
DOME_API_KEY=your-dome-api-key-here
PORT=3001
```

### Frontend (`frontend/.env.local`)
```env
NEXT_PUBLIC_API_URL=http://localhost:3001/api
```

## ๐ŸŽจ Design Theme
- Dark purple/blue gradient background
- Card-based UI with `#12121e` background
- Purple (`#6b21a8`) and blue (`#3b82f6`) accent colors
- Responsive design with Tailwind CSS

## ๐Ÿ”ฎ DOME API Integration (Future)

The app is designed to integrate with the DOME API. To enable real data:

1. **Install SDK**:
   ```bash
   cd backend
   npm install @dome-api/sdk
   ```

2. **Add API Key** to `backend/.env`:
   ```env
   DOME_API_KEY=your-actual-api-key
   ```

3. **Update Service** in `backend/src/markets/markets.service.ts`:
   - Uncomment the DOME SDK import
   - Replace simulated data methods with real API calls

Currently uses simulated data with realistic patterns for demo purposes.

## ๐Ÿšข Deployment

### Build Production
```bash
# Backend
cd backend
npm run build
npm run start:prod

# Frontend
cd frontend
npm run build
npm start
```

## ๐Ÿ“‹ Notes
- Authentication is **disabled** for easy demo access
- Data is **simulated** but follows real market patterns
- All export features are **fully functional**
- Runs entirely locally - no external dependencies required

---

**Built for client demo - February 2026**