# MyAli — Install (Phase 0)

## Prerequisites
- Node.js 18+
- MySQL 5.7+ (or MariaDB 10.3+) running locally
- Google Chrome / Chromium / Edge

## 1. Database

```bash
cd backend
npm install
cp .env.example .env
# edit .env with your DB user/password
npm run migrate
```

Creates the database `myali` (if missing) and applies `schema.sql`.
A default store is seeded with API token `myali-dev-token-change-me`.

## 2. Backend

```bash
npm start
```

Open http://localhost:3000/installer.html — the health check should be green.

## 3. MyAli Importer (Chrome Extension)

1. Open `chrome://extensions`
2. Enable **Developer mode** (top-right toggle)
3. Click **Load unpacked** → select the `extension/` folder
4. Click the **MyAli Importer** icon in the toolbar → set:
   - **Backend URL**: `http://localhost:3000`
   - **API Token**: `myali-dev-token-change-me`
   - Click **Save & Test** → status should be **Backend reachable ✓**

## 4. Test an import

1. Visit any AliExpress product page, e.g.
   `https://www.aliexpress.com/item/1005006789012345.html`
2. A red **📥 Import to MyAli** button appears at bottom-right
3. Click it. It turns green on success.
4. Open http://localhost:3000/admin.html — paste your token → your product appears.

## Production notes
- Change the seeded API token in MySQL before deploying.
- Add your production domain to `extension/manifest.json` → `host_permissions`.
- Never commit `.env` or `node_modules/`.
