# Artifis SEO — Hands-Off Automation

Monitor-only dashboard. No clicks required for normal operation.

## URLs

| What | URL |
|------|-----|
| **Home hub (start here)** | https://srv1677041.hstgr.cloud/seo/ |
| Status dashboard | https://srv1677041.hstgr.cloud/seo/dashboard.php |
| Live Artifis site | https://srv1677041.hstgr.cloud/artifis/ |
| Cron log | `/var/www/html/seo/logs/cron.log` on Hostinger |

## Cron schedule (root crontab)

| When | Command | What happens |
|------|---------|--------------|
| Every hour at :00 | `cron.php?mode=hourly` | Optional GSC API fetch (if `GSC_AUTO_FETCH=1`) → Google Trends → merge keywords → generate meta → deploy |
| On demand | `cron.php?mode=gsc` | Search Console API → `data/search_console_export.csv` (last 28 days, top 1000 queries) |
| Every 6 hours at :00 | `cron.php?mode=sniff` | Live crawl of 6 competitor electrician sites → merge new phrases into `keywords.json` (24h cache per domain) |
| Daily 06:30 UTC | `cron.php?mode=daily` | Competitor sniff + generate meta + deploy (backup pass without Trends fetch) |

All runs append to `logs/cron.log` and record success/failure in `data/activity.json`.

## Pipeline (plain English)

1. **Competitor sniff** — reads Yeoman, 786, Leicester Spark, Artisan, Leicester Electricians, LDN Electrical homepages; extracts titles, meta tags, headings; adds new Leicester electrician phrases.
2. **Google Trends** — fetches UK rising/related searches for seed terms; merges into keyword list.
3. **Search Console** — `data/search_console_export.csv` from manual upload or **GSC API** (`cron.php?mode=gsc` / hourly auto-fetch); queries merge on each Trends fetch.
4. **Generate meta** — picks best keywords (competitor + trends first) and writes `data/meta_output.json`.
5. **Deploy** — updates live `artifis/index.php` title, description, keywords; bumps `artifis/sitemap.xml` lastmod.

Deploy target is **locked to live** in `data/settings.json`.

## Search visibility files

- `artifis/robots.txt` — allows indexing, blocks `/crm/`, points to sitemap
- `artifis/sitemap.xml` — homepage URLs; lastmod refreshed on each successful deploy

## Realistic expectations

Meta updates help Google understand your services, but **rankings take weeks to months**. Factors outside this tool: domain age, backlinks, reviews, competition, and whether Google Search Console property is verified for artifis.co.uk.

## Manual test

```bash
curl -fsS "https://srv1677041.hstgr.cloud/seo/cron.php?mode=hourly"
# GSC API only (after credentials on server — see GSC_API_SETUP.md):
curl -fsS "https://srv1677041.hstgr.cloud/seo/cron.php?mode=gsc"
# or on server:
php /var/www/html/seo/cron.php hourly
php /var/www/html/seo/cron.php gsc
tail -20 /var/www/html/seo/logs/cron.log
tail -10 /var/www/html/seo/logs/gsc_fetch.log
grep SEO_DEPLOYED_AT /var/www/html/artifis/index.php
```

## Search Console API (free)

1. Google Cloud project + enable **Search Console API** (no billing for normal owner queries).
2. Service account JSON on server (e.g. `/volume1/web/secrets/gsc-sa.json`) — **not in git**.
3. Add service account email as **Owner/Full** in Search Console → Settings → Users.
4. Env: `GSC_SERVICE_ACCOUNT_JSON`, `GSC_SITE_URL`, optional `GSC_AUTO_FETCH=1`.
5. Full steps: [GSC_API_SETUP.md](GSC_API_SETUP.md) · status page: [gsc_api.php](gsc_api.php).

## Blockers / notes

- **Search Console API** — wired; needs Google Cloud + GSC user step. CSV upload still works without API.
- **Primary domain** — live site is on Hostinger subdomain until artifis.co.uk DNS points here; sitemap lists artifis.co.uk / artifis.uk.
- **Dashboard** — monitor only; automation does not require login or button clicks.
