# TTPID Ads Manager — KLIQ-Only SSO & Core Architecture Guide

## 1. KLIQBD-Only Authentication Flow
1. Users visit `https://ads.ttpid.app/` (`public/index.php`), which states **Login Only with Your KLIQ Account**.
2. Clicking **Continue with KLIQ Account** goes to `/auth/kliq-login.php`, which redirects to `https://kliqbd.com/sso/ads-authorize.php`.
3. Upload `kliqbd-sso/ads-authorize.php` to `kliqbd.com/sso/ads-authorize.php` and set the same `kliq_sso_secret` on both `kliqbd.com` and `ads.ttpid.app/config/app.php`.
4. After KLIQBD verifies the user's session (or logs them in), it redirects back to `https://ads.ttpid.app/auth/kliq-callback.php` with a signed HMAC-SHA256 token, creating/updating their linked account in `users` (`kliq_user_id`) and opening `/dashboard.php`.

## 2. cPanel Deployment (`ads.ttpid.app`)
1. Point `ads.ttpid.app` DocumentRoot to `public/`.
2. Import `database/schema.sql` and `database/seed.sql` into MySQL.
3. Copy `config/database.example.php` to `config/database.php` and enter your MySQL credentials.
4. Set `signing_secret` and `kliq_sso_secret` in `config/app.php`.
