# FindBetterApp v47 Data Pack Backend

This backend lets you upload small **FBA data-pack zips** instead of replacing the whole FindBetterApp project every time we add 5 new apps.

Admin URL after upload/extract:

`https://timheaven.com/FindBetterApp/fba-admin/`

Temporary importer password for this build:

`FBA-WO4ifGV5AnmrAEAUas`

Change it immediately after upload by editing `public_html/FindBetterApp/fba-admin/config.php` and replacing `admin_password_hash` with a new PHP `password_hash()` value.

## What the importer does

- Reads `findbetterapp-data-pack.json` from the uploaded zip.
- Adds new tools if their canonical ID does not exist.
- Fills missing fields for existing tools without overwriting verified data.
- Adds missing categories/tags automatically.
- Adds/merges relationships without duplicate IDs.
- Generates missing static pages for new apps:
  - `/software/{tool}/`
  - `/software/{tool}/about/`
  - `/software/{tool}/pricing/`
  - `/alternatives/{tool}/`
  - `/compare/{source}-vs-{target}/`
  - new `/categories/{category}/` and `/tags/{tag}/` pages
- Rebuilds:
  - `tools-master-latest.json`
  - `tool-relationships-latest.json`
  - `tool-categories-latest.json`
  - `tool-tags-latest.json`
  - `connected-data-index-latest.json`
  - `alternative-page-engine-latest.json`
  - `search-index-latest.json`
  - `page-routing-latest.json`
  - `sitemap.xml`
- Keeps pages noindex/nofollow/noarchive.
- Saves a backup before every import in `fba-admin/backups/`.

## Data-pack format

The zip must contain:

`findbetterapp-data-pack.json`

Minimum JSON:

```json
{
  "schema_version": "fba-data-pack-v1",
  "pack_name": "five-new-apps-pack",
  "tools": [
    {
      "id": "example-tool",
      "name": "Example Tool",
      "summary": "What the tool does and who it helps.",
      "primary_category": "ai-tools",
      "categories": ["ai-tools"],
      "tags": ["chatgpt-alternative", "noindex-review"],
      "pricing_model": "Needs proof",
      "login_required": "Needs proof"
    }
  ],
  "relationships": [
    {
      "source_tool_id": "example-tool",
      "target_tool_id": "chatgpt",
      "relationship_type": "alternative",
      "score": 80,
      "why": "Why users compare these tools.",
      "contexts": ["ai-tools"]
    }
  ]
}
```

## Important rules preserved

- Compatible with `/FindBetterApp/` subfolder.
- All generated pages stay `noindex,nofollow,noarchive`.
- Existing verified fields are preserved; the importer fills missing data by default.
- Duplicate tool IDs and duplicate relationship IDs are avoided by canonical slug normalization.
- Search, sitemap, categories, tags, routing and relationship indexes regenerate after upload.
- Existing hand-built pages are not overwritten if the file already exists.

## Included sample

- `fba-admin/findbetterapp-data-pack.sample.json`
- `fba-admin/sample-five-app-data-pack.zip`

Use the sample only to test on staging. It contains demo apps, not real public data.
