# IRIS Chat — Temporary Test Hosting (for IT)

**What this is.** IRIS Chat is a working app we are about to test on a handful of
our own phones. Before that, two small things need to live somewhere reachable
(not on a laptop). This sheet tells you how to stand them up **from our repo**,
exactly as they are. This is a **temporary test host** — it lives just long
enough to run the phone testing, then it can come down. It is **not** the final
production home.

**Please don't redesign anything.** Hosting means running a copy of what's in the
repo. Improvements come from the project's repo and flow out to you; you run the
copy and re-host updated copies when we send them. That's the whole job.

---

## What you're standing up (two things) → what to send back (two links)

| You host | It is | You send back |
|---|---|---|
| The **middleman** (`/server`) | A small Python server that holds the secret API key, forwards the app's already-masked messages to the AI, and stores the codes-only filed reports. | **Proxy URL** — the address the app calls. |
| The **admin console** (`/admin`) | A single static web page the back office opens to see filed reports. | **Admin console URL** — where we watch reports arrive. |

Those **two links** are all we need back. **Do not send the API key** — see the
hard requirements below.

---

## Before you start

- Access to the repo: `github.com/vsguarino/iris-chat`.
- A host that can run a **Python 3.8+** process or container (a small VM, a
  container platform, or a Python-capable app host). **No packages to install** —
  the server uses only Python's standard library.
- A place to serve one **static HTML file** (can be the same host, or any static
  web host).
- Your own **Anthropic API key** for the test — see hard requirements.

---

## 1. Host the middleman (the `/server` proxy + its database)

The proxy is the shared backend: it holds the secret key, forwards the AI call,
and stores the codes-only filed reports (plays, stock alerts, feedback, requests),
the back-office review channel, cost metering, and the admin sign-in. It reads all
its settings from the **environment** — nothing sensitive lives in the repo.

1. Deploy the repo's **`server/`** folder. Start command: `python3 proxy.py`.
2. Set these in the host's **secret store / environment** (not in a file in the repo):

   | Variable | Required | What to set |
   |---|---|---|
   | `ANTHROPIC_API_KEY` | **yes** | Your test key (see hard requirements). The server refuses to start without it. |
   | `IRIS_ADMIN_USERS` | **yes (before it's reachable)** | Real sign-in accounts — see hard requirements. Format `user:password:role,user:password:role`; role is `admin` or `viewer`. |
   | `PORT` | as your host needs | The port the server listens on (the code reads it; default 8765). |
   | `DATA_DB` | recommended | Path to the reports database file, on a **persistent disk/volume** so filed reports survive a restart. Defaults to `./iris_data.db` beside the server — fine, but on a host with throwaway disk a redeploy resets the test data. |
   | `ALLOWED_ORIGIN` | optional | Leave unset (`*`) for this temporary test. |

3. Put it behind **HTTPS/TLS** (your load balancer or reverse proxy).
4. Check it's alive: open `https://<your-proxy-host>/health` → it returns
   `{"ok": true, ...}`.

That address — `https://<your-proxy-host>` — is the **Proxy URL** to send back.

> Note: the older `server/README.md` describes only the first version of this
> server (just the AI call + review channel). Since then it also serves the
> codes-only reports the admin console reads. This sheet is the current one for
> hosting.

## 2. Host the admin console (`/admin`)

`admin/index.html` is a **single static file** — no build step, no dependencies.

1. Serve `admin/index.html` on any static host (or the same box as the proxy).
2. Point it at the proxy in one of two ways:
   - open it with the proxy address in the link:
     `https://<your-admin-host>/?base=https://<your-proxy-host>`, **or**
   - add one line before it loads: `window.IRIS_BACKEND_BASE = "https://<your-proxy-host>";`
3. Sign-in uses the `IRIS_ADMIN_USERS` you set on the proxy.

The resulting address is the **Admin console URL** to send back. (If you used the
`?base=` method, include it in the link you send.)

## 3. Point the doctor app at the proxy (one value)

So the phone-test build (next step) calls your proxy: in the repo, open
`mobile/www/config.js` and set

```js
window.IRIS_PROXY_BASE = "https://<your-proxy-host>";
```

That is the only value the app needs. (Actually building the app onto phones is
the next step; this just prepares it.)

---

## HARD REQUIREMENTS (please don't skip)

**1. The API key is a secret you hold.**
- Generate it yourself in the Anthropic console. Use a **dedicated, spending-capped
  test key** you can disable or delete the moment testing ends.
- It lives **only** in the host's secret store. **Never** in the repo, **never** in
  a chat/email, **never** sent to anyone — not to the project team, not to me. If
  anyone asks you to send a key, the answer is no.

**2. Real admin logins before the console is reachable.**
- The console ships with **demo logins** (`admin`/`admin-demo`, `viewer`/`viewer-demo`)
  that are public in the repo. If `IRIS_ADMIN_USERS` is unset, the server seeds
  those demo logins and prints a warning.
- Set `IRIS_ADMIN_USERS` with **real accounts** so the demo logins stop working —
  **before** the console is reachable by anyone. Treat these credentials like the
  API key: only in the host's environment, never in the repo or a message.
- **If the console would be reachable with the demo logins still active, stop** and
  set real ones first.

---

## Send back

Reply with just the **two links**:
- Proxy URL: `https://<your-proxy-host>`
- Admin console URL: `https://<your-admin-host>/…`

Not the key. Not the passwords.

---

## Keeping the hosted copy up to date (the update loop)

When the project improves the app, the changes land in the **repo**, and you
re-host the updated copy — the hosted copy is never edited directly.

- **Server change:** pull the latest repo, restart the proxy.
- **Admin console change:** re-upload the new `admin/index.html`.
- **App change:** re-run the app build (that's part of the phone-test step).

Your secrets (the key, the admin logins) stay set across updates — you don't
re-enter them each time.

---

## Done checklist (temporary test host)

- [ ] Proxy reachable over HTTPS; `/health` returns `{"ok": true}`.
- [ ] `ANTHROPIC_API_KEY` set as a secret; server started (it refuses to start without it).
- [ ] `IRIS_ADMIN_USERS` set with **real** accounts; the demo logins no longer work.
- [ ] Admin console reachable and pointed at the proxy; an admin account can sign in.
- [ ] `mobile/www/config.js` set to the proxy URL (for the phone-test build).
- [ ] The **two links** sent back to the project team. The key was never sent.
