{
  "markdown": "# 🏇 Strike Tips\n\n**South African Horse Racing Intelligence System**\n\n<img src=\"screenshots/hud-screenshot.png\" width=\"100%\" alt=\"Strike Tips Dashboard\" />\n\nA modular, AI-powered betting assistant that identifies value bets in South African horse racing using probability edge analysis and disciplined bankroll management.\n\n**3-Layer Architecture:** Cloudflare edge (always-free) → Modal serverless backend → Vercel frontend, with an OKF (On-Device Knowledge) bundle of 12 curated SA racing docs.\n\n![Python](https://img.shields.io/badge/Python-3.9+-blue.svg)\n![License](https://img.shields.io/badge/License-MIT-green.svg)\n![Status](https://img.shields.io/badge/Status-Production-green.svg)\n\n---\n\n## 🎯 What is Strike Tips?\n\nStrike Tips is a \"God Mode\" betting intelligence system built on a modular architecture:\n\n- **🏇 Race Analysis** - Identifies value bets using probability edge (not tips, *mathematical advantage*)\n- **💰 Smart Bankroll Manager** - Enforces disciplined staking (max 5% per bet, daily loss limits)\n- **🤖 AI Agents** - Model Pipeline with specialist models for fast responses\n- **📱 Telegram Notifications** - Sends tips and updates directly to your phone\n- **🔧 Self-Healing Parsers** - Adapts when racing websites change structure\n- **⏰ Automated Scheduling** - Daily scans at your preferred time\n- **🧠 Dual Memory System** - Combines ChromaDB for race intelligence RAG (local/cloud) and Honcho for user/agent memory with background reasoning, using local Ollama embeddings with Gemini fallback\n- **🔄 Auto-Result Updates** - Automatically settles bets when races complete\n- **🧠 Bayesian Learning Engine** - Beta-Binomial updating blends simulated dreams with real settled outcomes; `decay = e^{-0.15 × real_bets}` makes simulation influence fade with real-world data\n- **🎲 Deterministic Dream Engine** - Physical adjustments (Going/Rain, Wind, Scratches) replace random shifts; persisted to ChromaDB with metadata tags\n- **📊 Dream Stress Index (DSI)** - Scales Half-Kelly staking defensively: DSI < 20% → 1.0x, 20-50% → 0.75x, > 50% → 0.50x (Quarter-Kelly)\n- **🌐 WebGPU Search Grounding** - Local browser models fetch live context (odds, runners, ChromaDB insights, DDG search) via `/api/agent/context` before inference\n- **📱 Telegram `/dream` Command** - `/dream <track> race <num> - <scenario>` runs custom simulations and returns edge change reports directly to chat\n- **📰 Racing News Feed** - Zero-cost live headlines from BBC Sport, The Guardian & Daily Mirror RSS — polled by the Swarm Researcher, streamed to the HUD over SSE with a lazy image proxy (no API keys)\n- **🐝 Swarm Researcher (All-Region Form Insights)** - Backfills form commentary for every region Betway's Timeform doesn't cover (USA, Japan, South Africa, Australia, NZ, Hong Kong…): free deterministic field blurbs for all runners, web-grounded Groq summaries gated to aiSelections/movers/short-priced (max 6 calls/cycle), persisted to ChromaDB learning memory and surfaced in the HUD with region chips + reliability badges\n- **📡 Live Ops Telemetry** - Dedicated sidebar tab streaming real-time engine activity (Swarm Researcher, News RAG, Dreaming Engine, Governor DSI adjustments) over SSE — engine status cards + live activity stream, zero polling ([docs](docs/LIVE_OPS_TELEMETRY.md))\n- **📊 RaceCard Table Upgrades** - Sortable columns, full-width collapsible insight banners, per-row model Edge column, one-click ⚡ per runner into AI chat, and a live Dream Stress Index chip on the race header\n- **🔒 Security Hardening (2026-09-02)** - Cloudflare Worker fail-closed `isAuthorized` + `ALLOWED_ORIGINS` allowlist + `OPTIONS` preflight, Vercel middleware `100 req/min` rate limiting + `401` kill-switch protection, `BACKEND_API_KEY`/`STRIKE_TIPS_API_KEY` rotation ([docs](docs/RELEASE_2026_09_02_SECURITY_BETFAIR_MOBILE.md))\n- **📊 Betfair Enriched Form (All Regions)** - 12 fields per runner (`gear`, `daysSinceRun`, `official_rating`, `pedigree` via `SIRE x DAM`, `owner`, `trainer`, `age`, `weight`, `form`, `jockey_claim`, `runner_comments`, `verdict`) across RSA/AUS/USA/GB/IRE/FRA/NZL (`_COUNTRY_FILTER=None`, case-insensitive `WEARING`/`DAYS_SINCE_LAST_RUN`, `marketId`/`id` fix; 169 events for TOMORROW vs 0 before)\n---\n\n## 🏛️ Architecture\n\n## 3-Layer Architecture (v2.1)\n\n```\n                    ┌─────────────────────────────────────┐\n                    │     VERCEL HUD (Frontend)           │\n                    │  https://strike-tips-hud.vercel.app  │\n                    │                                     │\n                    │  Vite + React 19 + Three.js         │\n                    │  middleware.ts routes API calls      │\n                    └──────────────┬──────────────────────┘\n                                   │\n                    ┌──────────────┴──────────────────────┐\n                    │           MIDDLEWARE.TS              │\n                    │  Cloudflare paths → CF Worker        │\n                    │  All other paths → Modal             │\n                    └──────┬──────────────────────┬────────┘\n                           │                      │\n              ┌────────────▼────────┐    ┌────────▼───────────────────┐\n              │  CLOUDFLARE EDGE    │    │  MODAL BACKEND             │\n              │  (Always Free)      │    │  (Serverless, ~$30/mo)     │\n              │                     │    │                            │\n               │  ● 16 MCP tools     │    │  ● FastAPI (serve-api)     │\n               │  ● 13 REST endpoints│    │  ● Telegram bot            │\n               │  ● OKF knowledge    │    │  ● AI analysis (Gemini)    │\n               │  ● D1 database      │    │  ● Dream engine (Bayesian) │\n               │  ● KV odds cache    │    │  ● DSI Kelly scaling       │\n               │  ● Web search tool  │    │  ● ChromaDB memory         │\n               │                     │    │  ● Odds processing         │\n               │                     │    │  ● Context API/WebGPU      │\n               └─────────────────────┘    └────────────────────────────┘\n```\n\n---\n\n---\n\n## ☁️ Cloudflare Edge Layer\n\nThe Cloudflare Worker (`cloudflare_mcp_edge/`) handles all compute-light operations at zero cost:\n\n### OKF Knowledge Bundle\n12 curated SA racing knowledge files compiled to TypeScript at build time:\n\n| Category | Files | Contents |\n|----------|-------|----------|\n| **Tracks** | 7 files | Kenilworth, Durbanville, Fairview, Turffontein, Vaal, Scottsville, Greyville — real data (founded, features, draw bias) |\n| **Conditions** | 1 file | Going & track conditions explained |\n| **Strategies** | 2 files | Value betting & Kelly Criterion with SA context |\n\nSearch ranks by keyword match (10x title/tags, 5x body, + per-occurrence).\n\n### MCP Tools (16 total)\n\n| Category | Tools |\n|----------|-------|\n| **Original** (11) | probability edge, Kelly staking, circuit breakers, Bayesian calibration, keyword scan, race evaluation, card verification, HTML patch, form search, dream sim, odds fetch |\n| **OKF** (4) | search, list, get by path, get track by name |\n| **Web** (1) | web search (requires `SEARCH_API_KEY` secret) |\n\n### REST Endpoints (13)\n`/api/health`, `/api/edge`, `/api/kelly`, `/api/circuit`, `/api/bayesian`, `/api/keywords`, `/api/evaluate`, `/api/verify-card`, `/api/patch-html`, `/api/racing/form`, `/api/racing/odds`, `/api/knowledge`, `/api/knowledge/search`, `/api/knowledge/tracks`\n\n### Data Layer\n- **D1 Database**: 244 form insights, parameterized queries\n- **KV Cache**: Live odds pushed by Docker odds-monitor (TTL 300s)\n- **Ingestion**: `POST /api/ingest-snapshot` for odds, `POST /api/ingest-insight` for form\n\nSee [`docs/CLOUDFLARE_MCP_EDGE.md`](docs/CLOUDFLARE_MCP_EDGE.md) for full details.\n\n---\n\n## 📰 Racing News Pipeline\n\nZero-cost, key-free news pipeline powering the HUD **News** sidebar (`/news`):\n\n```\nRSS Feeds (BBC Sport / Guardian / Mirror)\n        │  poll_news() — every 10 min (Swarm Researcher background loop,\n        │  started by AdaptiveOddsMonitor; no LLM calls on the news path)\n        ▼\ndata/news_latest.json  (deduped, capped, atomic tmp+rename writes)\n        │\n        ├─► GET /api/news            → { items: [...], count }   (REST, initial hydration)\n        ├─► GET /api/monitoring/stream → SSE event: news          (live updates on change)\n        └─► GET /api/news/images?url= → lazy image proxy          (allow-listed CDN hosts,\n                                       fetched on first view, cached to disk 7 days)\n```\n\n**Frontend flow:** `DataBridge` is the single source of truth — it hydrates the store via REST on startup, then keeps it fresh from the SSE `news` event. `NewsView` renders from the store only (no duplicate fetching). Summaries are HTML-stripped client-side (Guardian embeds markup).\n\nBoth `/api/news`, `/api/news/images` and the SSE stream are in `SAFE_PATHS` (no API key) since `EventSource` cannot send custom headers.\n\n---\n\n## 📡 Live Ops — Engine Telemetry\n\nDedicated sidebar tab (`/telemetry`, 📡 next to News) streaming real-time background-engine activity:\n\n```\nemit(engine, message) from Swarm Researcher / News poller / Dream heartbeat / Governor\n        │  core_agent/core/telemetry.py — in-memory ring buffer (100 events)\n        │  + best-effort Redis fanout on agent:telemetry\n        ▼\nGET /api/monitoring/stream → SSE event: telemetry   (one shared connection)\nGET /api/telemetry         → REST hydration         (newest-first, max 30)\n        ▼\nDataBridge → hudStore.telemetry → Live Ops tab\n```\n\nThe tab shows one **status card per engine** (Active/Idle + relative time + latest message) for the four engines — Swarm Researcher, News RAG, Dreaming Engine, Governor — plus a chronological activity stream. The Governor's DSI adjustments are also persisted per track:race (`data/dsi_cache.json`) and stamped onto snapshot events, rendering a stress chip (🟢 <20% / 🟠 20–50% / 🔴 >50%) on RaceCards. Full details: [`docs/LIVE_OPS_TELEMETRY.md`](docs/LIVE_OPS_TELEMETRY.md).\n\n---\n\n## 🔌 Backend Routing (Modal primary · optional self-hosted fallback)\n\nThe HUD keeps **Modal as the primary backend** at all times, with an optional\nopt-in fallback for developers who want extra resilience (e.g. Cloud Run):\n\n- **`middleware.ts`** — Modal is first and wins whenever healthy. A fixed set of\n  read/MCP endpoints goes to the always-on **Cloudflare Worker**; everything else\n  goes to Modal. Each backend is validated with a real `/api/system/health`\n  probe (a suspended Modal answers 404 fast — that's *not* healthy). An explicit\n  `BACKEND_FALLBACK_ORIGIN` env var (never hard-coded) adds a fallback origin.\n- **`data-bridge.ts`** — SSE probes origins in order (dev same-origin → Modal →\n  optional `VITE_SSE_FALLBACK_ORIGIN`) with a 60s negative cache on dark origins.\n- No Cloudflare **quick-tunnel** is used in the active path. Cloud Run remains an\n  **optional** companion — deploy script ready in `deploy-cloud-run.sh`.\n\n⚠️ During a failover window, bet history/analytics shown come from the fallback's\ndata copy — the canonical Modal Volume (`strike-tips-data`) and ChromaDB Cloud\npersist untouched and return automatically when Modal does. Full details (with\nplaceholders, no hardcoded URLs): [`docs/FAILOVER_BRIDGE.md`](docs/FAILOVER_BRIDGE.md).\n\n---\n\n## 🐝 Swarm Researcher — Form Insights for Every Region\n\nBetway only publishes Timeform prose (`timeForm`) + star ratings for **UK/Ireland** cards — USA, Japan, South Africa, Australia, NZ and Hong Kong runners arrive with empty commentary. The Swarm Researcher (`core_agent/skills/swarm_researcher.py`) fills that gap for **all regions**, on a strict no-waste budget:\n\n```\nAdaptiveOddsMonitor (every 10 min, alongside heartbeat)\n        │\n        ├─ Pass A: backfill_form_insights()\n        │    1. Chroma freshness gate  — skip horses with today's insight already stored\n        │    2. Field blurb (FREE)     — deterministic facts from live runner fields:\n        │                               form string, draw, age/weight, jockey, trainer, odds\n        │    3. Web grounding (GATED)  — ONLY aiSelections + movers + odds ≤ 6.0:\n        │                               search_racing_data() → Groq factual summary\n        │                               (max 6 Groq calls/cycle, cached by horse+date)\n        │    ▼\n        │    data/swarm_insights.json (per-outcomeId) + ChromaDB form_insights\n        │    metadata {type:\"racing_insight\", region, source:\"field_only\"|\"web\", ts}\n        │    + curated_memory.append_agent_note()\n        │\n        └─ Pass B: poll_news()  → see News Pipeline above\n\nSnapshot enrichment (inline, every monitor cycle):\nenrich_snapshot_with_insights(state) injects per-runner\nregion / swarmInsight / insightSource before set_snapshot → SSE push\n```\n\n**Region detection:** derived from the Betway display prefix (`\"USA: Saratoga\"`, `\"South Africa: Turffontein\"`) with course-keyword fallbacks — covers USA, Japan, South Africa, UK/IRE, Australia, New Zealand, France, Hong Kong, UAE.\n\n**HUD surfaces:**\n- **RaceCard** — region chip + expandable insight (🔥 Timeform for UK/IRE, 🌐 Swarm for everywhere else)\n- **Market Movers** — insight strip + reliability badge (✅ Verified = web-grounded, ⚠️ Baseline = field-only)\n- **Predictor** — LiveMarketStrip shows region + swarm insight in the detail modal and expanded cards\n\n---\n\n## 🚀 Quick Start\n\n### Option A: Deploy Cloudflare Worker + Vercel HUD (Cloud-Native)\n\n```bash\n# 1. Deploy Cloudflare Worker (always-free edge)\ncd cloudflare_mcp_edge\nnode scripts/build-knowledge.js\nnpm run deploy\n\n# 2. Deploy Vercel HUD (frontend)\ncd ../strike-tips-hud\nvercel deploy --prod -y --force\n\n# 3. Visit https://strike-tips-hud.vercel.app\n```\n\n### Option B: Docker (Local Development)\n\n```bash\n# 1. Clone the repository\ngit clone https://github.com/Gmpho/strike-tips-autonomous-.git\ncd strike-tips-autonomous-\n\n# 2. Start all containers (strike-bot, ollama, odds-monitor)\ndocker compose up -d\n\n# 3. Check status\ndocker ps\n\n# 4. View logs\ndocker logs -f strike-bot\n\n# 5. API available at http://localhost:8000\n#    Swagger docs at http://localhost:8000/docs\n```\n\n**What's started:**\n- `strike-bot`: FastAPI on port 8000\n- `ollama`: Local LLM on port 11434\n- `odds-monitor`: Playwright scraper\n\n## 🔌 Betting API Endpoint Map (Canonical)\n\nUse explicit betting endpoints to avoid route drift between backend and frontend.\n\n| Purpose | Method | Endpoint |\n|---------|--------|----------|\n| Betting route index (lightweight discovery) | `GET` | `/api/betting/` |\n| Full bet history | `GET` | `/api/betting/history` |\n| Open bets only | `GET` | `/api/betting/open` |\n| Betting statistics | `GET` | `/api/betting/stats` |\n| Account summary / bankroll state | `GET` | `/api/betting/account-summary` |\n| Place bet | `POST` | `/api/betting/place` |\n| Settle bet | `POST` | `/api/betting/settle` |\n\nNotes:\n- Do **not** depend on implicit root-list behavior for history.\n- Frontend should call explicit endpoints such as `/api/betting/history` and `/api/betting/account-summary`.\n\n---\n\n### Option B: Deploy on Modal (Serverless)\n\n```bash\n# 1. Install Modal\npip install modal\nmodal setup\n\n# 2. Deploy\npython deploy_modal.py\n\n# 3. Done! Runs daily at 11 AM automatically\n```\n\n**Cost:** ~$0.60/month (well within Modal's free $30 credit)\n\nSee [docs/MODAL_README.md](docs/MODAL_README.md) for details.\n\n---\n\n### Option C: Manual Setup (Development)\n\n```bash\n# 1. Clone the repository\ngit clone https://github.com/Gmpho/strike-tips-autonomous-.git\ncd strike-tips-autonomous-\n\n# 2. Start Backend\ncd core_agent\npython -m venv venv\nsource venv/bin/activate  # On Windows: venv\\Scripts\\activate\npip install -r requirements.txt\npython api.py\n\n# 3. Start Frontend (New terminal)\ncd strike-tips-hud\nnpm install\nnpm run dev\n```\n\n### 2. Configuration\n\n```bash\n# Copy environment template\ncp .env.example .env\n\n# Edit .env with your settings\nnano .env\n```\n\n**Required:**\n- `TELEGRAM_BOT_TOKEN` - Get from [@BotFather](https://t.me/botfather)\n- `TELEGRAM_CHAT_ID` - Get from [@userinfobot](https://t.me/userinfobot)\n\n### 3. Test Connection\n\n```bash\npython scheduler.py test\n```\n\n### 4. Run Immediate Scan\n\n```bash\npython scheduler.py scan\n```\n\n### 5. Start Automated Scheduler\n\n```bash\n# Run daily at 11:00 AM (default)\npython scheduler.py start\n\n# Or specify custom time\npython scheduler.py start --time 10:30\n```\n\n---\n\n## 📊 How Value Betting Works\n\n### The Mathematics\n\n```\nImplied Probability = 1 / Decimal Odds\nEdge = Your Estimated Probability - Implied Probability\n\nIf Edge > 5% → VALUE BET\n```\n\n### Example\n\n| Horse | Market Odds | Implied Prob | Your Estimate | Edge | Action |\n|-------|-------------|--------------|---------------|------|--------|\n| Horse A | 5.0 | 20% | 32% | +12% | ✅ VALUE |\n| Horse B | 3.0 | 33% | 30% | -3% | ❌ NO BET |\n| Horse C | 8.0 | 12.5% | 25% | +12.5% | ✅ VALUE |\n\n### Kelly Criterion Staking\n\n```\nFull Kelly = (bp - q) / b\nwhere: b = odds - 1, p = your probability, q = 1 - p\n\nStrike Tips uses Half-Kelly (0.5x) for safety\nCapped at 5% of bankroll per bet\n```\n\n---\n\n## 🏇 South African Tracks Supported\n\n| Track | Location | Racing Days |\n|-------|----------|-------------|\n| **Turffontein** | Johannesburg | Saturday |\n| **Kenilworth** | Cape Town | Wednesday, Saturday |\n| **Vaal** | Vereeniging | Tuesday, Thursday |\n| **Greyville** | Durban | Friday, Sunday |\n| **Fairview** | Port Elizabeth | Monday, Friday |\n| **Flamingo Park** | Kimberley | Thursday, Saturday |\n| **Scottburgh** | KZN | Occasional |\n\n---\n\n## 💰 Bankroll Discipline Rules\n\n### Hard Limits (Non-Negotiable)\n\n```python\nMAX_BET_PERCENT = 5.0        # Never bet more than 5% on single race\nDAILY_LOSS_LIMIT = 20.0      # Stop after 20% daily loss\nMAX_DRAWDOWN = 50.0          # Stop if down 50% from peak\nKELLY_FRACTION = 0.5         # Use Half-Kelly (conservative)\n```\n\n### 🧠 Dream Stress Index (DSI) Kelly Sizing Scale Down\n\nTo protect the bankroll from adverse track/weather scenarios, Strike Tips runs Monte Carlo simulations (dreams) in the background. Before placing any real bet, the Bankroll Governor queries ChromaDB for all simulated dreams today for that specific track and distance to calculate the **Dream Stress Index (DSI)**:\n\n$$\\text{DSI} = \\frac{\\text{Simulations where horse failed to maintain edge}}{\\text{Total simulations}}$$\n\nBased on the DSI, the Half-Kelly stake is scaled down defensively:\n- **DSI < 20%** (Stable Edge): **1.0x** allocation.\n- **20% <= DSI <= 50%** (Moderate Risk): **0.75x** allocation.\n- **DSI > 50%** (High Volatility / Adverse Conditions): **0.50x** allocation (Quarter-Kelly).\n\n### Example Bankroll Management\n\nStarting Bankroll: **R1,000**\n\n| Scenario | Calculation | Stake |\n|----------|-------------|-------|\n| Strong edge (15%+) | 7% of R1,000 | R70 (capped to R50) |\n| Value edge (5-15%) | 5% of R1,000 | R50 |\n| Marginal edge (3-5%) | 3% of R1,000 | R30 |\n\n---\n\n## 🛠️ CLI Commands\n\n### Main Commands\n\n```bash\n# Daily scan of all tracks\npython strike_tips.py scan\n\n# Analyze specific track\npython strike_tips.py track --track turffontein\n\n# Place a bet manually\npython strike_tips.py bet \\\n    --track turffontein \\\n    --race 1 \\\n    --horse \"Horse Name\" \\\n    --odds 5.0 \\\n    --edge 12.5\n\n# Settle a bet\npython strike_tips.py settle --bet-id <bet_id> --won\n\n# Check bankroll status\npython strike_tips.py status\n\n# Generate daily report\npython strike_tips.py report\n```\n\n### Scheduler Commands\n\n```bash\n# Start automated scheduler\npython scheduler.py start\n\n# Run immediate scan\npython scheduler.py scan\n\n# Test connections\npython scheduler.py test\n```\n\n---\n\n## 📱 Telegram Bot Screenshots\n\n<img src=\"screenshots/telegram-1.jpg\" width=\"32%\" /> <img src=\"screenshots/telegram-2.jpg\" width=\"32%\" /> <img src=\"screenshots/telegram-3.jpg\" width=\"32%\" />\n<img src=\"screenshots/telegram-4.jpg\" width=\"32%\" /> <img src=\"screenshots/telegram-5.jpg\" width=\"32%\" /> <img src=\"screenshots/telegram-6.jpg\" width=\"32%\" />\n\n### Message Types\n\n1. **Daily Tips Summary** - Morning scan results\n2. **Value Bet Alerts** - When strong value is found\n3. **Bet Placed Confirmation** - Stake and odds recorded\n4. **Race Results** - Win/loss notifications\n5. **Bankroll Updates** - Daily P&L and status\n6. **Error Alerts** - System issues\n\n### Example Notification\n\n```\n🔥 STRIKE TIPS - VALUE BET\n\n📍 Turffontein - Race 3 (14:30)\n🐎 Speedy Gonzales\n💰 Odds: 6.5 | Edge: +15.2%\n💵 Advised Stake: R50.00\n📊 Confidence: STRONG_VALUE\n\n📝 Analysis:\nRecent form: 1-2-1 | Proven at track/distance\n\n⚠️ Bet responsibly. Max 5% per bet rule applied.\n```\n\n---\n\n## 🔧 Self-Healing Parsers\n\nWhen TAB4Racing changes their website structure:\n\n1. Parser detects selector failures\n2. Tracks success/fail rates per selector\n3. Falls back to pattern matching\n4. Suggests new selectors\n5. Can auto-generate patch code\n\n```python\n# The parser learns and adapts\nparser = SelfHealingParser()\nelement = parser.find_element(soup, \"horse_name\")\n# Automatically tries multiple selectors\n# Updates stats for future use\n```\n\n---\n\n## 📁 Project Structure (June 2026 - v2.1)\n\n```\ncore_agent/                                # Modal backend (Python FastAPI)\n├── agents/                               # AI orchestration layer\n│   ├── ai_pydantic.py                    # ModelPipeline + UnifiedOrchestrator\n│   ├── ai_providers.py                   # AI provider routing\n│   └── intent_classifier.py              # Regex-based intent detection\n├── config/                               # Configuration\n│   ├── model_config.py                   # Centralized model config\n│   └── settings.py                       # Bankroll settings\n├── core/                                 # Core business logic\n│   ├── strike_tips.py                    # Main orchestrator\n│   ├── strike_brain.py                   # Central state manager\n│   ├── engine.py                         # Execution engine\n│   ├── adaptive_odds_monitor.py          # Live odds monitoring\n│   └── api.py                            # FastAPI entry point\n├── skills/                               # Domain skills\n│   ├── race_analysis/                    # Value bet engine\n│   ├── bankroll_manager/                 # Bankroll governor (DSI scaling)\n│   ├── dreamer.py                        # Dream engine (Bayesian sims)\n│   ├── parsers/                          # Tab4, PDF scrapers\n│   ├── memory/                           # ChromaDB memory (embedder fix)\n│   ├── learning/                         # Learning engine (Beta-Binomial)\n│   ├── search_service.py                 # DDG search (thread executor)\n│   └── notifications/                    # Telegram bot\n├── tools/                                # MAF tools\n│   └── maf_tool_registry.py             # 17 gambling-free tools (+dream tools)\n├── agent/                                # AI orchestration\n│   ├── context.py                        # ContextBuilder (WebGPU grounding)\n│   └── loop.py                           # Telegram router (+/dream cmd)\n├── routes/                               # API endpoints\n│   ├── agent.py, betting.py, racing.py\n├── ollama_configs/                       # 5 racing Modelfiles\n├── tests/                                # Test suite\n│   ├── test_governor.py                  # 5 bankroll tests\n│   └── test_dsi_staking.py              # DSI stress test\n└── requirements.txt\n\ncloudflare_mcp_edge/                      # Cloudflare Worker (always-free edge)\n├── src/\n│   ├── index.ts                          # Worker entry (REST + MCP, 564 lines)\n│   └── generated/\n│       └── racing-knowledge.ts           # Auto-generated OKF bundle (12 entries)\n├── knowledge/racing/                     # OKF markdown source\n│   ├── index.md                          # 1 bundle index\n│   ├── conditions/going.md               # Going conditions\n│   ├── strategies/                       # Value betting, Kelly Criterion\n│   └── tracks/                           # 7 SA tracks with real data\n├── scripts/build-knowledge.js            # Markdown → TypeScript compiler\n├── package.json                          # @modelcontextprotocol/sdk v1.29.0\n└── wrangler.jsonc                        # D1 + KV bindings\n\nstrike-tips-hud/                          # Vite + React + Three.js frontend (Vercel)\n├── src/                                  # UI components\n├── middleware.ts                         # Routes API calls: Cloudflare vs Modal\n├── vercel.json                           # SPA rewrites only\n└── package.json\n```\n\n---\n\n## ⚙️ Configuration Options\n\n### Environment Variables\n\n| Variable | Description | Default |\n|----------|-------------|---------|\n| `TELEGRAM_BOT_TOKEN` | Bot token from @BotFather | Required |\n| `TELEGRAM_CHAT_ID` | Your Telegram chat ID | Required |\n| `STARTING_BANKROLL` | Initial bankroll (ZAR) | 1000 |\n| `MAX_BET_PERCENT` | Max % per bet | 5 |\n| `DAILY_LOSS_LIMIT` | Stop after % loss | 20 |\n| `DATA_DIR` | Data storage path | ./data |\n| `CHROMA_API_KEY` | ChromaDB Cloud API key (for cloud storage) | None |\n| `CHROMA_HOST` | ChromaDB Cloud host (e.g., api.trychroma.com) | None |\n| `CHROMA_TENANT` | ChromaDB tenant (optional) | None |\n| `CHROMA_DATABASE` | ChromaDB database name | default_database |\n| `GEMINI_API_KEY` | Gemini API key for embedding fallback | None |\n| `MODEL_EMBEDDER` | Embedding model for Ollama (local) | embeddinggemma:300m |\n\n### Customizing in Code\n\n```python\nfrom config.settings import BankrollConfig\n\n# Custom bankroll settings\ncustom_config = BankrollConfig(\n    total_bankroll=2000.0,\n    max_bet_percent=3.0,      # More conservative\n    daily_loss_limit=15.0,\n    min_edge_threshold=8.0     # Higher edge requirement\n)\n\nstrike = StrikeTips(bankroll_config=custom_config)\n```\n\n---\n\n## 🧪 Testing\n\n```bash\n# Run all tests (30 tests — governor, DSI staking, exotics, selections, pool legs, auto-bet odds)\npytest\n\n# Test specific component\npytest tests/test_governor.py\n\n# DSI stress test\npytest tests/test_dsi_staking.py -v\n\n# Test inside Docker\ndocker exec strike-bot-new pytest core_agent/tests/\n\n# Test with coverage\npytest --cov=core_agent --cov-report=term-missing\n```\n\n---\n\n## 🚨 Important Disclaimer\n\n**Strike Tips is a tool for educational and entertainment purposes.**\n\n- Past performance does not guarantee future results\n- The house always has an edge\n- Never bet more than you can afford to lose\n- Gambling can be addictive - seek help if needed\n- This tool does not guarantee profits\n\n**South African Responsible Gambling:**\n- National Responsible Gambling Programme: 0800 006 008\n- Website: www.responsiblegambling.org.za\n\n---\n\n## 🤝 Contributing\n\n1. Fork the repository\n2. Create a feature branch (`git checkout -b feature/amazing`)\n3. Commit changes (`git commit -m 'Add amazing feature'`)\n4. Push to branch (`git push origin feature/amazing`)\n5. Open a Pull Request\n\n---\n\n## 📜 License\n\nMIT License - see [LICENSE](LICENSE) file\n\n---\n\n## 🙏 Acknowledgments\n\n- South African racing data from [TAB4Racing](https://www.tab4racing.com)\n- Inspired by value betting and Kelly Criterion principles\n- Built for SA racing enthusiasts\n\n---\n\n## 📞 Support\n\n- Issues: [GitHub Issues](https://github.com/Gmpho/strike-tips-autonomous-/issues)\n- Telegram: [@StrikeTipsBot](https://t.me/StrikeTipsBot)\n- HUD: [https://strike-tips-hud.vercel.app/](https://strike-tips-hud.vercel.app/)\n- MCP: `POST https://striketips-mcp.gmphorg379.workers.dev/mcp` (requires `x-api-key` + `Accept: application/json, text/event-stream`)\n\n---\n\n## 📚 Documentation\n\n| Document | Contents |\n|----------|----------|\n| [`docs/PWA_TWA_GUIDE.md`](docs/PWA_TWA_GUIDE.md) | PWA structure, Service Worker caching, and TWA Play Store packaging |\n| [`docs/OLLAMA_BACKGROUND.md`](docs/OLLAMA_BACKGROUND.md) | Ollama background architecture, specialist models, and background workflows |\n| [`docs/CLOUDFLARE_MCP_EDGE.md`](docs/CLOUDFLARE_MCP_EDGE.md) | 3-layer architecture, OKF bundle, MCP tools, REST endpoints |\n| [`docs/AGENTS.md`](docs/AGENTS.md) | Agent coding guidelines, build commands, project structure |\n| [`docs/MCP_INTEGRATION_GUIDE.md`](docs/MCP_INTEGRATION_GUIDE.md) | MCP protocol, n8n integration, Claude Desktop setup |\n| [`docs/MODAL_README.md`](docs/MODAL_README.md) | Modal serverless deployment |\n| [`docs/MODAL_README.md`](docs/MODAL_README.md) | Modal serverless deployment |\n| [`docs/PRIVACY.md`](docs/PRIVACY.md) | Privacy policy |\n| [`docs/TERMS.md`](docs/TERMS.md) | Terms of service |\n| [`docs/DISCLAIMER.md`](docs/DISCLAIMER.md) | Legal disclaimer |\n\n---\n\n**🏇 Bet Smart. Bet Disciplined. Strike Tips. please note this for education and entertainment only**\n",
  "bytes": 28459,
  "sha": "899639584ecd3f8c51c443839caf338d70f599ec5f2975ef2260c9405b3f4ee5",
  "repo_slug": "gmpho/strike-tips-autonomous-",
  "fonte": "repo",
  "truncated": false,
  "api": "https://agentalog.com/api/listings/okf_gmpho_strike_tips_autonomous_cloudflare__c72bf4b8/readme"
}