# Taking Urgent Rishta online

This is the whole path from "works on my computer" to "live on the internet,"
in plain steps. You do not need to code. Set aside an afternoon.

There are two separate things here:

1. **The website + admin** — put the files on a web host so anyone can visit.
2. **The Android app (APK)** — wrap the live website into an installable app.

Do them in that order. The app needs the website to exist first.

---

## Part 1 — Put the site online

### What you need to buy

- **A domain name** (e.g. urgentrishta.pk) — from any registrar, ~Rs 3,000/year.
- **Shared hosting with PHP 8 and MySQL** — Hostinger, Namecheap, or a local
  Pakistani host all work. Pick a plan that says **PHP 8.1+** and **MySQL**.
  ~Rs 500–1,500/month is plenty to start.

Almost every host gives you **cPanel**, which is what these steps assume.

### Step 1 — Create the database

In cPanel, open **MySQL Databases**:

1. Create a database (note its full name, like `youruser_rishta`).
2. Create a database user with a **strong password** (save it).
3. Add that user to the database with **All Privileges**.

### Step 2 — Upload the files

In cPanel **File Manager**, go into `public_html`:

- Upload the whole `rishta` folder's contents here (or into a subfolder like
  `public_html/rishta` if you want the app at yourdomain.com/rishta).
- Make sure the `uploads` folder is writable: right-click it → Permissions →
  set to **755** (or 775 if 755 doesn't allow uploads).

### Step 3 — Set your settings

In `api/`, copy `config.local.example.php` to a new file named
**`config.local.php`** and edit it (right-click → Edit in File Manager):

- Put in the database name, user, and password from Step 1.
- Set `APP_URL` to your real address, e.g. `https://yourdomain.com`.
- Fill in the email settings so members can receive their sign-up code.

Save. This one file is what makes everything point at your live server.

### Step 4 — Turn on HTTPS (the padlock)

In cPanel, find **SSL/TLS Status** and enable the free **Let's Encrypt**
certificate for your domain. Wait a few minutes. Your site should now load
with `https://`. **This matters** — the Android app in Part 2 will not work
without https, and cameras/microphones (photos, voice notes) need it too.

### Step 5 — Load your data and set up

Visit these once, in your browser:

1. `https://yourdomain.com/db/migrate.php` — sets up all the database tables.
   Wait for **all done**. (If the big member import times out, that's a host
   limit — ask support to raise `max_execution_time`, or import the SQL via
   cPanel's phpMyAdmin.)
2. `https://yourdomain.com/db/check.php` — the green/red health check. Fix any
   red items (usually a database or email typo in config.local.php).
3. `https://yourdomain.com/admin/` — log in and open **Setup**. Work through
   anything marked with a ⚠️.

### Step 6 — Secure the old passwords

Your imported members have old plain-text passwords. Once email works:

1. Visit `https://yourdomain.com/db/migrate_passwords.php` once.
2. Then edit `config.local.php` and set `ALLOW_LEGACY_LOGIN` to `false`.

That's it — the site is live. Test it: open the app URL on your phone, sign up
a test account, approve it in admin, and send a message.

---

## Part 2 — The Android app (APK)

Your app is already a **PWA** — a website that installs like an app. There are
two ways to get it onto phones. Start with the easy one.

### Option A — "Add to Home Screen" (works today, free, no build)

Once the site is live over https, anyone can install it:

- **Android (Chrome):** open your app URL, tap the **⋮** menu → **Install app**
  (or "Add to Home screen"). It installs with your icon and opens full-screen,
  no browser bar — indistinguishable from a normal app for most people.
- **iPhone (Safari):** Share button → **Add to Home Screen**.

Tell members to do this. For many businesses this is all you ever need, and it
updates automatically when you update the site.

### Option B — A real installable .apk (for the Play Store or to share directly)

An `.apk` file has to be *built* with Android's tools, which can't run inside
this project. But because your app is a proper PWA, you don't have to write any
Android code — a free tool wraps your live URL into a signed APK. This is
called a **TWA** (Trusted Web Activity), the same technique big companies use.

**Easiest — PWABuilder (Microsoft, free, no install):**

1. Go to **https://www.pwabuilder.com**
2. Enter your live app URL (e.g. `https://yourdomain.com/app/`) and click Start.
3. It scores your PWA (yours should pass — it has a manifest, icons, and a
   service worker). Click **Package for stores → Android**.
4. Download the package. It contains a **signed `.apk`** (and an `.aab` for the
   Play Store) plus a `signing-key-info` file — **keep that key safe forever**;
   you need the same key to publish updates.
5. The download includes an `assetlinks.json` file with a short instruction:
   upload it to `yourdomain.com/.well-known/assetlinks.json`. That's what
   removes the browser address bar and makes it feel fully native.

Now you have an `.apk` you can send to anyone (they enable "install from
unknown sources"), or upload the `.aab` to the **Google Play Console** (one-time
$25 developer fee) to publish it properly.

**Alternative — Bubblewrap (command line):** if you prefer doing it yourself,
Google's `bubblewrap` CLI does the same thing. See
`https://github.com/GoogleChromeLabs/bubblewrap`. You'll need Java and the
Android SDK on your own machine; PWABuilder avoids all that.

### Which should you do?

- Just getting started, sharing with people you know → **Option A** today.
- Want it on the Google Play Store with a real download → **Option B**, and
  I've made sure your PWA passes PWABuilder's checks so it'll go smoothly.

---

## After you're live — the short maintenance list

- **Back up** your database weekly (cPanel → phpMyAdmin → Export). This is your
  members; treat it like cash in a safe.
- When a developer sends you updated files, upload them, then visit
  `db/migrate.php` once (Setup → "Open the updater") to finish any update.
- Keep `config.local.php` private. Never share it, never put it in any public
  place. It holds your database password.
