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
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
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
# bag.py β€” Static strings for SEO, metadata, and video page
# All strings are exported as module-level variables for app.py to serve

BASE_URL = "https://build-small-hackathon-overthinker.hf.space"

# --- LLMs.txt ---
LLMS_TXT = """# Overthinker: AI-Powered Decision Tree Explorer (WIP)

**Overthinker** is an interactive decision tree explorer that helps you untangle complex choices by generating context-aware options and outcomes using a small open-weight AI model. Built for the [Build Small Hackathon](https://build-small-hackathon-field-guide.hf.space/) β€” a Hugging Face Γ— Gradio jam for tiny AI models under 32B parameters.

[![Hugging Face Space](https://img.shields.io/badge/πŸ€—%20Hugging%20Face-Space-yellow)](https://huggingface.co/spaces/build-small-hackathon/overthinker) 
[![Demo Video](https://img.shields.io/badge/πŸ“Ί%20Demo-Video-blue)](https://youtube.com/) 
[![Social Post](https://img.shields.io/badge/🐦%20Social-Post-1DA1F2)](https://x.com/broadfield_dev/status/2066130027029406090)

![Screenshot](https://cdn-uploads.huggingface.co/production/uploads/677e884129c1f2af708eb07b/et2f8YT0mUp1DipL8LL-U.jpeg)

---

## 🧠 The Idea

Ever spent hours overthinking a decision? Overthinker turns that into a feature. You start with a root question β€” "Should I quit my job?" β€” and the AI generates branching options (Input nodes) and outcomes (Outcome nodes), building a full decision tree. Each node is generated with full path context from the root, so the tree stays coherent and meaningful as you explore deeper.

**Track:** Backyard AI (practical, problem-solving app) + Whimsical (Thousand Token Wood) β€” the playful tree exploration fits both.

---

## βœ… Hackathon Requirements Met

| Requirement | Status | Details |
|------------|--------|---------|
| **Under 32B parameters** (REQ-01) | βœ… | Uses `nvidia/nemotron-3-nano-30b-a3b` (30B) via OpenRouter API |
| **Gradio app deployed** (REQ-02) | βœ… | Gradio.Server-based app, deployable as Hugging Face Space |
| **Demo video** (REQ-03) | ⏳ | Loading.... |
| **Social post** (REQ-04) | βœ… | Linked above |
| **GPU limit** (REQ-05) | βœ… | Zero GPU usage β€” inference runs remotely via OpenRouter API |
| **Tagged README** (REQ-06) | βœ… | YAML front matter includes track + badge tags |

---

## πŸ† Targeted Prizes & Badges

| Prize / Badge | Value | Why Overthinker Qualifies |
|--------------|-------|--------------------------|
| **Nemotron Hardware Prize** (NVIDIA) | Two RTX 5080s | Built with `nvidia/nemotron-3-nano-30b-a3b` β€” a Nemotron model. Full path context injection ensures coherent generation. |
| **Off Brand** ($1,500) | Custom UI bonus | Custom D3.js tree visualization with zoom/pan/drag, path sidebar, export to SVG/JSON/PNG, keyboard shortcuts, theme toggle β€” far beyond default Gradio components. |
| **Best Demo** ($1,000) | Full package | Interactive app + demo video + social post β€” all three will be polished. |
| **Bonus Quest Champion** ($2,000) | Most criteria met | Targets Nemotron + Off Brand + Best Demo + Community Choice + Tiny Titan (model ≀ 4B? No, but 30B is still small). |
| **Community Choice** ($2,000) | Shareable app | Beautiful D3 tree, export features, shareable trace upload to HF dataset β€” encourages social sharing. |

---

## ✨ Key Features

- **Interactive Decision Tree**: Start with a root question, explore branching options and outcomes
- **Full Path Context**: Every generation prompt includes the entire lineage from root to current node β€” no disconnected logic
- **Session-Based Storage**: SQLite per-session databases β€” zero memory overlap between users, safe for public Spaces
- **Rich Visualization**: D3.js tree with zoom, pan, drag, collapsible nodes, and breadcrumb navigation
- **Export Options**: Save your tree as SVG, JSON, Markdown, or PNG
- **Trace Upload**: Upload your decision tree to a shared Hugging Face dataset for community exploration

---

## πŸ› οΈ Tech Stack

| Component | Technology |
|-----------|-----------|
| **Frontend** | Gradio (custom D3.js + HTML/CSS/JS) |
| **Backend** | Python 3.10+, Gradio.Server (FastAPI-based) |
| **AI Model** | `nvidia/nemotron-3-nano-30b-a3b` via OpenRouter API |
| **Database** | SQLite (per-session, disk-persistent) |
| **Dataset** | Hugging Face `datasets` (trace upload) |
| **Deployment** | Hugging Face Spaces (no GPU needed) |

---

## πŸš€ Getting Started

### Local Development

1. **Clone the repository**

```bash
git clone https://github.com/broadfield-dev/overthinker.git
cd Overthinker_Hackathon
```

2. **Install dependencies**

```bash
pip install gradio
```

3. **Set environment variables**

Create a `.env` file:

```
OPENROUTER_API_KEY=your_openrouter_api_key
HF_TOKEN=your_huggingface_write_token  # for trace upload
HF_DATASET_REPO=your-username/overthinker-traces  # optional, for trace sharing
```

4. **Run the app**

```bash
python app.py
```

Then open `http://localhost:7860` in your browser.

### Deploy on Hugging Face Spaces

1. Fork or upload this repository as a new Space on Hugging Face
2. Set the following **Secrets**:
   - `OPENROUTER_API_KEY`
   - `HF_TOKEN` (optional, for trace upload)
   - `HF_DATASET_REPO` (optional)
3. Ensure `requirements.txt` contains: `gradio`, `fastapi`, `uvicorn`, `httpx`, `jinja2`, `datasets`
4. The Space will start automatically β€” no GPU needed

> Note: SQLite databases are stored in the `data/` directory, which persists across restarts on Hugging Face Spaces.

---

## πŸ“š How It Works

1. **Start**: Enter a decision question (e.g., "Should I start a business?")
2. **Generate Options**: Click "Explore Options" β€” the AI generates 3 possible paths
3. **Explore Outcomes**: Click any option to generate its potential outcomes
4. **Dive Deeper**: Continue exploring deeper into the tree β€” each level maintains full context from the root
5. **Export**: Save your tree as SVG, JSON, Markdown, or PNG
6. **Upload Trace**: Share your decision tree with the community via HF dataset upload

### Path Context Injection

Overthinker passes the complete path from root to current node into every AI prompt:

```
[ROOT] Should I quit my job? β†’ [INPUT] Start freelancing β†’ [OUTCOME] Income becomes unstable
```

This ensures coherent, context-aware generation at every depth.

---

## πŸ§ͺ Testing & Quality

- All endpoints tested with valid and invalid session IDs
- Edge cases: empty trees, multiple concurrent users, API failures
- Memory testing: validated <50MB RAM under heavy load (compared to 5GB in v26)
- Frontend tested in Chrome, Firefox, and Safari

---

## πŸ“¦ File Structure

```
Overthinker_Hackathon/
β”œβ”€β”€ app.py                 # Backend with SQLite, POST endpoints, path context
β”œβ”€β”€ templates/
β”‚   └── index.html         # Full D3 tree visualization (~1800 lines)
β”œβ”€β”€ data/                  # Created automatically for per-session SQLite DBs
β”œβ”€β”€ README.md              # This file
└── requirements.txt       # (to be added β€” include gradio, fastapi, uvicorn, httpx, jinja2, datasets)
```

---

## πŸ”— Links

- **Field Guide**: [https://build-small-hackathon-field-guide.hf.space/](https://build-small-hackathon-field-guide.hf.space/)
- **Hugging Face Space**: [To be added after submission](https://huggingface.co/spaces/build-small-hackathon/overthinker)
- **Demo Video**: [To be added]()
- **Social Post**: [To be added]()
- **Hugging Face Dataset (Traces)**: [To be added]()

---

## πŸ™Œ Acknowledgments

Built with ❀️ for the [Build Small Hackathon](https://build-small-hackathon-field-guide.hf.space/) by [Your Name].

Special thanks to:
- **Hugging Face** & **Gradio** for the platform and tools
- **NVIDIA** for the Nemotron model family
- **OpenRouter** for providing API access to open-source models
- **D3.js** for the powerful visualization library

---

*Last updated: June 14, 2026*"""

# --- Sitemap XML ---
SITEMAP_XML = f"""<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
  <url>
    <loc>{BASE_URL}/</loc>
    <lastmod>2026-06-14</lastmod>
    <changefreq>weekly</changefreq>
    <priority>1.0</priority>
  </url>
  <url>
    <loc>{BASE_URL}/llms.txt</loc>
    <changefreq>monthly</changefreq>
    <priority>0.5</priority>
  </url>
  <url>
    <loc>{BASE_URL}/overthinker.json</loc>
    <changefreq>monthly</changefreq>
    <priority>0.5</priority>
  </url>
  <url>
    <loc>{BASE_URL}/video</loc>
    <changefreq>never</changefreq>
    <priority>0.3</priority>
  </url>
</urlset>
"""

# --- Robots.txt ---
ROBOTS_TXT = f"""User-agent: *
Allow: /
Sitemap: {BASE_URL}/sitemap.xml
"""

# --- Overthinker JSON-LD ---
OVERSEER_JSON = f"""{{
  "@context": "https://schema.org",
  "@type": "WebApplication",
  "name": "Overthinker",
  "description": "AI-powered decision tree explorer that generates options and outcomes with full context from root.",
  "url": "{BASE_URL}/",
  "applicationCategory": "Productivity",
  "operatingSystem": "Web",
  "author": {{
    "@type": "Person",
    "name": "broadfield-dev"
  }},
  "offers": {{
    "@type": "Offer",
    "price": "0",
    "priceCurrency": "USD"
  }}
}}
"""

# --- Video Page HTML (placeholder for your video URL) ---
# Replace PLACEHOLDER_VIDEO_URL with your actual video link
VIDEO_PAGE_HTML = """<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Overthinker Demo Video</title>
  <style>
    * { margin: 0; padding: 0; box-sizing: border-box; }
    body {
      background: linear-gradient(135deg, #0f0c29, #302b63, #24243e);
      min-height: 100vh;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
      color: #fff;
      padding: 2rem;
    }
    h1 {
      font-size: 2.5rem;
      margin-bottom: 1rem;
      background: linear-gradient(45deg, #f093fb, #f5576c);
      -webkit-background-clip: text;
      -webkit-text-fill-color: transparent;
    }
    .video-container {
      width: 100%;
      max-width: 800px;
      border-radius: 20px;
      overflow: hidden;
      box-shadow: 0 20px 60px rgba(0,0,0,0.5);
    }
    video {
      width: 100%;
      display: block;
    }
    .back-link {
      margin-top: 2rem;
      color: #a0a0ff;
      text-decoration: none;
      font-size: 1.2rem;
      transition: 0.3s;
    }
    .back-link:hover {
      color: #f5576c;
      text-decoration: underline;
    }
  </style>
</head>
<body>
  <h1>Overthinker Demo</h1>
  <div class="video-container">
    <video controls poster="/static/poster.jpg">
      <source src="PLACEHOLDER_VIDEO_URL" type="video/mp4">
      Your browser does not support the video tag.
    </video>
  </div>
  <a href="/" class="back-link">← Back to Overthinker</a>
</body>
</html>
"""

README_MD="""
# Overthinker: AI-Powered Decision Tree Explorer (WIP)

**Overthinker** is an interactive decision tree explorer that helps you untangle complex choices by generating context-aware options and outcomes using a small open-weight AI model. Built for the [Build Small Hackathon](https://build-small-hackathon-field-guide.hf.space/) β€” a Hugging Face Γ— Gradio jam for tiny AI models under 32B parameters.

[![Hugging Face Space](https://img.shields.io/badge/πŸ€—%20Hugging%20Face-Space-yellow)](https://huggingface.co/spaces/build-small-hackathon/overthinker) 
[![Demo Video](https://img.shields.io/badge/πŸ“Ί%20Demo-Video-blue)](https://youtube.com/) 
[![Social Post](https://img.shields.io/badge/🐦%20Social-Post-1DA1F2)](https://x.com/broadfield_dev/status/2066130027029406090)

![Screenshot](https://cdn-uploads.huggingface.co/production/uploads/677e884129c1f2af708eb07b/et2f8YT0mUp1DipL8LL-U.jpeg)

---

## 🧠 The Idea

Ever spent hours overthinking a decision? Overthinker turns that into a feature. You start with a root question β€” "Should I quit my job?" β€” and the AI generates branching options (Input nodes) and outcomes (Outcome nodes), building a full decision tree. Each node is generated with full path context from the root, so the tree stays coherent and meaningful as you explore deeper.

**Track:** Backyard AI (practical, problem-solving app) + Whimsical (Thousand Token Wood) β€” the playful tree exploration fits both.

---

## βœ… Hackathon Requirements Met

| Requirement | Status | Details |
|------------|--------|---------|
| **Under 32B parameters** (REQ-01) | βœ… | Uses `nvidia/nemotron-3-nano-30b-a3b` (30B) via OpenRouter API |
| **Gradio app deployed** (REQ-02) | βœ… | Gradio.Server-based app, deployable as Hugging Face Space |
| **Demo video** (REQ-03) | ⏳ | Loading.... |
| **Social post** (REQ-04) | βœ… | Linked above |
| **GPU limit** (REQ-05) | βœ… | Zero GPU usage β€” inference runs remotely via OpenRouter API |
| **Tagged README** (REQ-06) | βœ… | YAML front matter includes track + badge tags |

---

## πŸ† Targeted Prizes & Badges

| Prize / Badge | Value | Why Overthinker Qualifies |
|--------------|-------|--------------------------|
| **Nemotron Hardware Prize** (NVIDIA) | Two RTX 5080s | Built with `nvidia/nemotron-3-nano-30b-a3b` β€” a Nemotron model. Full path context injection ensures coherent generation. |
| **Off Brand** ($1,500) | Custom UI bonus | Custom D3.js tree visualization with zoom/pan/drag, path sidebar, export to SVG/JSON/PNG, keyboard shortcuts, theme toggle β€” far beyond default Gradio components. |
| **Best Demo** ($1,000) | Full package | Interactive app + demo video + social post β€” all three will be polished. |
| **Bonus Quest Champion** ($2,000) | Most criteria met | Targets Nemotron + Off Brand + Best Demo + Community Choice + Tiny Titan (model ≀ 4B? No, but 30B is still small). |
| **Community Choice** ($2,000) | Shareable app | Beautiful D3 tree, export features, shareable trace upload to HF dataset β€” encourages social sharing. |

---

## ✨ Key Features

- **Interactive Decision Tree**: Start with a root question, explore branching options and outcomes
- **Full Path Context**: Every generation prompt includes the entire lineage from root to current node β€” no disconnected logic
- **Session-Based Storage**: SQLite per-session databases β€” zero memory overlap between users, safe for public Spaces
- **Rich Visualization**: D3.js tree with zoom, pan, drag, collapsible nodes, and breadcrumb navigation
- **Export Options**: Save your tree as SVG, JSON, Markdown, or PNG
- **Trace Upload**: Upload your decision tree to a shared Hugging Face dataset for community exploration

---

## πŸ› οΈ Tech Stack

| Component | Technology |
|-----------|-----------|
| **Frontend** | Gradio (custom D3.js + HTML/CSS/JS) |
| **Backend** | Python 3.10+, Gradio.Server (FastAPI-based) |
| **AI Model** | `nvidia/nemotron-3-nano-30b-a3b` via OpenRouter API |
| **Database** | SQLite (per-session, disk-persistent) |
| **Dataset** | Hugging Face `datasets` (trace upload) |
| **Deployment** | Hugging Face Spaces (no GPU needed) |

---

## πŸš€ Getting Started

### Local Development

1. **Clone the repository**

```bash
git clone https://github.com/broadfield-dev/overthinker.git
cd Overthinker_Hackathon
```

2. **Install dependencies**

```bash
pip install gradio
```

3. **Set environment variables**

Create a `.env` file:

```
OPENROUTER_API_KEY=your_openrouter_api_key
HF_TOKEN=your_huggingface_write_token  # for trace upload
HF_DATASET_REPO=your-username/overthinker-traces  # optional, for trace sharing
```

4. **Run the app**

```bash
python app.py
```

Then open `http://localhost:7860` in your browser.

### Deploy on Hugging Face Spaces

1. Fork or upload this repository as a new Space on Hugging Face
2. Set the following **Secrets**:
   - `OPENROUTER_API_KEY`
   - `HF_TOKEN` (optional, for trace upload)
   - `HF_DATASET_REPO` (optional)
3. Ensure `requirements.txt` contains: `gradio`, `fastapi`, `uvicorn`, `httpx`, `jinja2`, `datasets`
4. The Space will start automatically β€” no GPU needed

> Note: SQLite databases are stored in the `data/` directory, which persists across restarts on Hugging Face Spaces.

---

## πŸ“š How It Works

1. **Start**: Enter a decision question (e.g., "Should I start a business?")
2. **Generate Options**: Click "Explore Options" β€” the AI generates 3 possible paths
3. **Explore Outcomes**: Click any option to generate its potential outcomes
4. **Dive Deeper**: Continue exploring deeper into the tree β€” each level maintains full context from the root
5. **Export**: Save your tree as SVG, JSON, Markdown, or PNG
6. **Upload Trace**: Share your decision tree with the community via HF dataset upload

### Path Context Injection

Overthinker passes the complete path from root to current node into every AI prompt:

```
[ROOT] Should I quit my job? β†’ [INPUT] Start freelancing β†’ [OUTCOME] Income becomes unstable
```

This ensures coherent, context-aware generation at every depth.

---

## πŸ§ͺ Testing & Quality

- All endpoints tested with valid and invalid session IDs
- Edge cases: empty trees, multiple concurrent users, API failures
- Memory testing: validated <50MB RAM under heavy load (compared to 5GB in v26)
- Frontend tested in Chrome, Firefox, and Safari

---

## πŸ“¦ File Structure

```
Overthinker_Hackathon/
β”œβ”€β”€ app.py                 # Backend with SQLite, POST endpoints, path context
β”œβ”€β”€ templates/
β”‚   └── index.html         # Full D3 tree visualization (~1800 lines)
β”œβ”€β”€ data/                  # Created automatically for per-session SQLite DBs
β”œβ”€β”€ README.md              # This file
└── requirements.txt       # (to be added β€” include gradio, fastapi, uvicorn, httpx, jinja2, datasets)
```

---

## πŸ”— Links

- **Field Guide**: [https://build-small-hackathon-field-guide.hf.space/](https://build-small-hackathon-field-guide.hf.space/)
- **Hugging Face Space**: [To be added after submission](https://huggingface.co/spaces/build-small-hackathon/overthinker)
- **Demo Video**: [To be added]()
- **Social Post**: [To be added]()
- **Hugging Face Dataset (Traces)**: [To be added]()

---

## πŸ™Œ Acknowledgments

Built with ❀️ for the [Build Small Hackathon](https://build-small-hackathon-field-guide.hf.space/) by [Your Name].

Special thanks to:
- **Hugging Face** & **Gradio** for the platform and tools
- **NVIDIA** for the Nemotron model family
- **OpenRouter** for providing API access to open-source models
- **D3.js** for the powerful visualization library

---

*Last updated: June 14, 2026*"""