# BLS mini-service

Drop this folder at `/var/www/html/bls`.

## Files
- `config.php` — DB connection (uses your constants + PDO wrapper), points to DB `bls`
- `api.php` — endpoints: ?action=events|brands|metrics|data
- `index.html` — quick sanity links

## SQL bootstrap
Create DB/tables first (run in MySQL):

```sql
CREATE DATABASE IF NOT EXISTS bls DEFAULT CHARACTER SET utf8mb4 DEFAULT COLLATE utf8mb4_unicode_ci;
USE bls;
CREATE TABLE IF NOT EXISTS bls_scores (
  id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
  Event   VARCHAR(255) NOT NULL,
  BRAND   VARCHAR(255) NOT NULL,
  Metric  VARCHAR(255) NOT NULL,
  Control DECIMAL(16,4) NULL,
  Exposed_Pre DECIMAL(16,4) NULL,
  Exposed_Post DECIMAL(16,4) NULL,
  created_at DATETIME NULL,
  updated_at DATETIME NULL,
  PRIMARY KEY (id),
  UNIQUE KEY uniq_event_brand_metric (Event, BRAND, Metric),
  KEY idx_event_brand (Event, BRAND)
);
```

## Permissions
```
sudo chown -R www-data:www-data /var/www/html/bls
sudo find /var/www/html/bls -type d -exec chmod 755 {} \;
sudo find /var/www/html/bls -type f -exec chmod 644 {} \;
```

## Sample request
`/bls/api.php?action=data&event=Australia%20Women%20Tour%20of%20India,%202025&brand=SBI%20LIFE`
