# OnlyScavs v0.2

A personal Escape from Tarkov database and toolkit. The goal is to maintain a **local SQLite database that I fully control** — tarkov.dev is used only as a one-time (or on-demand) data source to seed it. Once imported, the local DB is the source of truth and can be edited, annotated, and extended freely without relying on any external API being up or accurate.

---

## What it does

- **Key tracker** — full list of keys with personal priority ratings (IGNORE / LOW / MED / HIGH / SUPER), map tagging, notes, and quest flags
- **Collector checklist** — all 255 quests required to unlock *The Collector* (Kappa), with per-quest done/not-done tracking and a progress bar

---

## Setup

### 1. Install dependencies
```bash
pip install flask requests
```

### 2. Initialize the database
Run the imports in order. Each script creates its own tables if they don't exist.

```bash
# Import all keys from tarkov.dev into local DB
python3 import_keys.py

# Import all quests/tasks and their dependency graph
python3 import_quests.py
```

Then apply the maps migration (adds maps table + key–map relationships):
```bash
python3 -c "
import sqlite3
conn = sqlite3.connect('tarkov.db')
conn.executescript(open('migrations_v1.sql').read())
conn.commit()
conn.close()
"
```

> After this, the DB is yours. You don't need tarkov.dev running to use the app.

### 3. Run the app
```bash
python3 app.py
```

Open **http://127.0.0.1:5000**

---

## Re-importing data

The import scripts can be re-run any time to pull fresh data from tarkov.dev (e.g. after a big patch). They use `INSERT OR REPLACE` / `INSERT OR IGNORE` so they won't duplicate records, but **any manual edits to imported fields (name, wiki_link, etc.) will be overwritten**. Personal data (ratings, notes, map tags, quest progress) is stored in separate tables and is safe.

```bash
python3 import_keys.py    # refresh key list
python3 import_quests.py  # refresh quest list + dependency graph
```

---

## Project structure

```
onlyscavs/
├── app.py                  # Flask web app
├── import_keys.py          # Seeds keys table from tarkov.dev
├── import_quests.py        # Seeds quests + quest_deps tables from tarkov.dev
├── migrations_v1.sql       # Maps table + key_maps + used_in_quest flag
├── tarkov.db               # Local SQLite DB (gitignored — stays on your machine)
├── templates/
│   ├── index.html          # Key ratings UI
│   └── collector.html      # Collector checklist UI
└── TARKOV_DEV_API.md       # tarkov.dev GraphQL API reference
```

---

## Database schema

| Table | Purpose |
|---|---|
| `keys` | All key items (seeded from tarkov.dev, then local) |
| `key_ratings` | Personal ratings, notes, quest flags per key |
| `key_maps` | Which maps each key is used on |
| `maps` | Map list |
| `quests` | All tasks/quests (seeded from tarkov.dev) |
| `quest_deps` | Quest prerequisite graph (which quest unlocks which) |
| `quest_progress` | Personal done/not-done state per quest |

---

## Routes

| Route | Description |
|---|---|
| `GET /` | Key list with filters, sorting, and inline rating forms |
| `POST /rate` | Save rating for a single key |
| `POST /rate_all` | Save ratings for all visible keys |
| `GET /collector` | Collector checklist with progress bar |
| `POST /collector/toggle` | Mark a quest done or not done |

---

## Planned

- Weight/loadout tracker (weapons, armor, rigs, backpacks)
- Vendor price comparison
- Key location notes (what's behind the door)
