Files
co-lite/docs/deployment.md
T

474 lines
55 KiB
Markdown

# Co-Lite Deployment Handover
This is for whoever deploys Co-Lite to the Kubernetes cluster. CI builds and publishes the images. The manifests are in `deploy/k8s/` (Kustomize: a `base` and a `prod` overlay); the deployer fills in the cluster facts and Secrets and applies them. The database package goes to the DBA.
Spec: `openspec/specs/release-packaging/spec.md`. Local stack for comparison: `local/README.md`.
## 1. Images
CI (`.gitea/workflows/ci.yml`) builds every module on each push to `main`, runs all tests, and only then pushes. Each image is tagged with the commit SHA and with `latest`. Deploy SHA tags. Roll back by deploying the previous SHA.
| Image (`gitea.containerverse.dev/solvway/…`) | Kubernetes Service name (must match) | Port | Exposed |
|---|---|---|---|
| `co-lite-admin-portal` | `admin-portal` | 3000 | Yes, through Traefik |
| `co-lite-mobile-api` | `mobile-api` | 80 | No, internal only |
| `co-lite-api-gateway` | `api-gateway` | 80 | No, internal only |
| `co-lite-service-auth` | `service-auth` | 80 | No |
| `co-lite-service-system` | `service-system` | 80 | No |
| `co-lite-service-counter` | `service-counter` | 80 | No |
| `co-lite-service-member` | `service-member` | 80 | No |
| `co-lite-service-log` | `service-log` | 80 | No |
| `co-lite-service-email` | `service-email` | 80 | No |
| `co-lite-service-whatsapp` | `service-whatsapp` | 80 | No (Meta reaches mobile-api's webhook, section 8) |
The Service names matter:
- The gateway routes to `http://service-auth`, `http://service-system` and so on, on port 80. The names are fixed in its config.
- mobile-api and the portal find the gateway and mobile-api through `APIGATEWAYURL` and `MOBILE_API_BASE_URL`.
**Health probes:**
- **Java services:** liveness `GET /actuator/health/liveness`, readiness `GET /actuator/health/readiness`. mobile-api does not switch these on by itself (measured: 404 without the setting), so the prod settings set `MANAGEMENT_HEALTH_PROBES_ENABLED=true` for every Java pod. Use the liveness path for the startup probe too: `GET /actuator/health` is 503 on service-email while no mail server is set.
- **Admin portal:** it has no health endpoint. Use a TCP probe on port 3000, or `GET /login`, which returns 200 without a session.
**The Java images run as root and listen on port 80** (the base image sets no user). A cluster that enforces `runAsNonRoot` or the restricted Pod Security level must allow them.
**Images carry no configuration or secrets.** Everything below is supplied at runtime. CI fails a build whose image holds a key file or a secret with a built-in default (`local/image-check.sh`). Leave `BUILD_PROFILE` unset. `JAVA_OPTS` is optional, for example `-Xmx512m`.
## 2. Order of setup
Everything below runs from the repository root, on `main`, with `kubectl` pointed at the cluster. The checks need only Docker.
1. The DBA prepares MySQL (section 3).
2. Create the Pub/Sub topics and the service-account key (section 5).
3. **Fill in the cluster facts.** Replace every `<…>` in `deploy/k8s/overlays/prod/`:
- `settings.env`: `MYSQLHOST` (from the DBA) and `REDISHOST` (the existing Redis);
- `gcp.env`: `GCP_PROJECT`;
- `routes.yaml`: the Traefik cert resolver, in both routes.
The namespace is `co-lite` (`kustomization.yaml` and `namespace.yaml`). Commit these files: they hold no secrets.
4. **Create the Secrets.** Copy `deploy/k8s/secrets.example/` to `deploy/k8s/secrets/`. Git ignores that folder, so never commit it. Fill in every `<…>` (sections 6 and 7 say what each value is). Then:
```sh
deploy/create-secrets.sh --dry-run # checks every key is filled in; prints names, never values
deploy/create-secrets.sh # creates or updates the Secrets in the co-lite namespace
```
The script creates the `co-lite` namespace if it is missing. Leave `co-lite-whatsapp.env` out until WhatsApp is connected (step 9).
5. **Pick the release.** Choose a commit on `main` whose CI run pushed the images, and pin it:
```sh
deploy/set-release.sh <40-character commit sha>
deploy/check.sh --release # refuses any <…> left, a public route to an internal service, latest, or a second service-counter
```
6. **Apply:**
```sh
kubectl apply -k deploy/k8s/overlays/prod
kubectl -n co-lite rollout status deploy --timeout=10m
```
All ten Deployments start together; each Java pod gets up to 5 minutes to start. Starting them together has not been tried on the cluster yet. If a pod keeps restarting, apply in the old order instead and wait for each step to be ready:
1. `service-system`, `service-auth`, `service-counter`, `service-member`, `service-log`, `service-email`, `service-whatsapp`;
2. `api-gateway`;
3. `mobile-api`;
4. `admin-portal`.
Use `kubectl -n co-lite rollout restart deploy/<name>` once the services it calls are ready.
7. Commit the overlay with the new SHA, so `main` records what runs.
8. Check the Custom HTML frame header (section 8).
9. Connect WhatsApp in Meta (section 11) whenever you are ready. Until then the inbox says "WhatsApp is not configured". To switch it on: fill in `whatsapp.env` in the overlay and `co-lite-whatsapp.env` in `secrets/`, then run `create-secrets.sh` and apply again.
10. Sign in as the first admin at `https://co-lite.containerverse.dev` and set the real password. Then create the staff users under Users. The admin types each user's first password and passes it on in person. Each user must choose their own password at first sign-in. No email is needed.
**Rollback.** Run `deploy/set-release.sh <the previous sha>`, then `deploy/check.sh --release`, then apply again and wait for the rollout. The SHA history of `deploy/k8s/overlays/prod/kustomization.yaml` on `main` lists the releases. Database changes only go forward: roll back only to a SHA that works with the schema now in place. Each change's SQL in section 3 says whether older code still runs on it.
**Changing a setting.** Edit the `.env` file in the overlay and apply again. The settings ConfigMaps get a new name for each new content, so the pods that read them restart by themselves. **Changing a secret:** edit `deploy/k8s/secrets/`, run `create-secrets.sh`, then `kubectl -n co-lite rollout restart deploy/<name>` for the pods that read it. mobile-api needs no restart for the WhatsApp secrets (section 6).
**Left unset on purpose.** These settings keep their built-in defaults:
- the email provider keys (section 10);
- `SMSS360_EMAIL` and `CUSTOMER_PORTAL_BASE_URL`, which still point at Tastefully (section 10);
- `JUMIO_TOKEN` and `JUMIO_SECRET`;
- `XXL_JOB_TOKEN`.
**Cluster facts still to confirm before the first apply:**
- the Traefik cert resolver name;
- the Redis host and the MySQL host;
- the Pub/Sub project;
- whether the pull secret can be `co-lite-registry`, or the cluster already has one;
- whether the separate public-pages hostname (section 8) is wanted at go-live (it would be a third route in `routes.yaml`).
## 3. Database (for the DBA)
**Server:** MySQL 8.0, with these two settings:
- `log_bin_trust_function_creators = 1`. The schema creates functions and triggers, and with binary logging on that otherwise needs the SUPER privilege, which managed MySQL does not grant.
- `innodb_strict_mode = OFF`. Some inherited tables are wide `utf8mb3` tables that strict mode rejects.
**Connections:** the services connect without TLS (`useSSL=false` in their datasource URL), so the server must accept non-TLS connections from the cluster. To require TLS instead, override `SPRING_DATASOURCE_URL` on each database service.
**Package:** this package sets up an empty server once. Later changes ship their own SQL, which is applied on top of it. The files are in `openspec/changes/archive/2026-11-30-add-release-ci-packaging/sql/`. Run the files in this order, on an empty server:
| File | What it does |
|---|---|
| `00-schemas.sql` | Creates the five schemas: `service-counter`, `service-email`, `service-log`, `service-member`, `service-system` |
| `01-schema.sql` | All tables, functions and triggers. No data. |
| `02-reference.sql` | Reference data: countries, currencies, banks, messages, settings, roles, modules. No customer data. |
| `03-colite.sql` | The Co-Lite company, the lead and event tables, the lead index, and the back-office modules. |
| `04-first-admin.sql` | The first administrator. Fill in `<ADMIN_EMAIL>` and `<BCRYPT_HASH>` first (see below). |
**Making the hash.** The password never has to appear in shell history:
```sh
read -rs PW; printf '%s' "$PW" | docker run --rm -i httpd:2.4-alpine htpasswd -inBC 10 "" | tr -d ':\n'; unset PW
```
After running `04`, `SELECT LENGTH(password) FROM \`service-system\`.\`user\` WHERE id = 1;` must return 60. The administrator signs in as `admin` and must set a new password before anything else.
**Later SQL, after the package, in this order:**
| File | What it does |
|---|---|
| `openspec/changes/archive/2026-11-30-add-admin-email-listing/sql/01-email-module.sql` | Adds the Emails back-office module (`BO_EMAILS`). |
| `openspec/changes/archive/2026-11-30-add-admin-login-security/sql/01-login-audit.sql` | Creates the `login_audit` table (admin login history; the lockout reads it). DDL: run it with a user that may create tables, not the services' user. |
| `openspec/changes/archive/2026-11-30-add-admin-login-security/sql/02-lockout-settings.sql` | Adds `ADMIN_LOGIN_MAX_ATTEMPT` (5) and sets the admin block period to 15 minutes: 5 failed sign-ins in 15 minutes lock the username. |
| `openspec/changes/archive/2026-11-30-add-admin-login-security/sql/03-login-security-module.sql` | Adds the Login security back-office module (`BO_LOGIN_SECURITY`). |
`99-rollback.sql` in the same folder undoes the three and deletes the login history.
| File | What it does |
|---|---|
| `openspec/changes/archive/2026-11-30-add-admin-audit-log/sql/01-audit-event.sql` | Creates `service-log`.`audit_event` (the admin audit trail). DDL: run it with a user that may create tables, not the services' user. |
| `openspec/changes/archive/2026-11-30-add-admin-audit-log/sql/02-audit-log-module.sql` | Adds the Audit log back-office module (`BO_AUDIT_LOG`). No role gets it; super admins grant it under Roles. |
`99-rollback.sql` in the same folder undoes the two and deletes the audit trail.
| File | What it does |
|---|---|
| `openspec/changes/archive/2026-11-30-add-company-scoping/sql/01-company-code-status.sql` | Gives each company a sign-in code and a status. Company 1 becomes `INS` (code `ins`) and a second company `CV` (code `cv`) is added. DDL. |
| `openspec/changes/archive/2026-11-30-add-company-scoping/sql/02-company-columns.sql` | Adds the company to events and emails (existing rows go to INS) and makes interests one list shared by every company. DDL. |
| `openspec/changes/archive/2026-11-30-add-company-scoping/sql/03-admin-login-names.sql` | Super admins (role 1) get no company and keep their username. Every other admin moves to INS and is renamed `username@ins`. It stops without changing anything if an admin username already contains `@`. |
Run the three in order, with a user that may alter tables. File `03` ends every admin session: everyone signs in again, staff with company `ins`. `99-rollback.sql` in the same folder undoes the three. It fails on the username unique key once two companies have a user with the same username; rename one of them first.
| File | What it does |
|---|---|
| `openspec/changes/archive/2026-12-01-add-lead-dashboard/sql/01-status-change.sql` | Creates `service-counter`.`event_lead_status_change` (every event-lead status change with its time and user) and an index on `event_lead` for the dashboard. DDL. |
| `openspec/changes/archive/2026-12-01-add-lead-dashboard/sql/02-status-change-backfill.sql` | Gives event leads captured before this release a history: OPEN at capture, and the current status at the last update. These times are approximate. Safe to run twice. |
| `openspec/changes/archive/2026-12-01-add-lead-dashboard/sql/03-dashboard-module.sql` | Adds the Dashboard back-office module (`BO_DASHBOARD`). No role gets it; super admins grant it under Roles. |
Run the three in order before the new images go live: the new services-counter writes to the table from `01` on every capture and status edit, and fails without it. `01` needs a user that may create tables. `99-rollback.sql` in the same folder undoes them and deletes the status history.
| File | What it does |
|---|---|
| `openspec/changes/archive/2026-12-01-add-qr-self-registration/sql/01-registration-link.sql` | Creates `service-counter`.`registration_link` (QR registration codes) and adds `source`, `consent_at` and `consent_notice_id` to `event_lead`. Existing event leads become `STAFF`. DDL. |
| `openspec/changes/archive/2026-12-01-add-qr-self-registration/sql/02-company-privacy-notice.sql` | Creates `service-system`.`company_privacy_notice` and gives every existing company the default English and Bahasa Malaysia privacy notice, with the company's name filled in. DDL. |
Run both before the new images go live: the new services-counter reads the new `event_lead` columns on every lead query and fails without them. Both need a user that may create tables. `99-rollback.sql` in the same folder undoes them and deletes the codes, the notices and the consent records.
| File | What it does |
|---|---|
| `openspec/changes/archive/2026-12-01-uppercase-company-codes/sql/01-uppercase-codes.sql` | Turns every company code and every staff login name to capitals (`ins` becomes `INS`, `sales9@cv` becomes `sales9@CV`). Safe to run twice. |
Run it when the new services-system and mobile-api go live. Staff who are signed in keep working until their session needs a refresh, then sign in again. Sign-in still ignores case, so staff may keep typing `ins` or `cv`. `99-rollback.sql` in the same folder turns codes and login names back to lowercase.
| File | What it does |
|---|---|
| `openspec/changes/archive/2026-12-01-add-event-invitations/sql/01-event-guests.sql` | Creates `service-counter`.`event_guest` (each event's invitation list), adds `capacity`, `invitation_cap` and `checkin_token` to `event`, and `attended_at` to `event_lead`. DDL. |
| `openspec/changes/archive/2026-12-01-add-event-invitations/sql/02-event-guests-module.sql` | Adds the Event guests back-office module (`BO_EVENT_GUESTS`). No role gets it; super admins grant it under Roles. |
Run both, in order, before the new images go live: the new services-counter reads the new columns on every event and event lead query and fails without them. `01` needs a user that may alter tables. If `01` stops partway, check which columns already exist before running it again: only its `CREATE TABLE` is safe to repeat. `99-rollback.sql` in the same folder undoes them and deletes the guest lists and attendance times.
| File | What it does |
|---|---|
| `openspec/changes/archive/2026-12-02-add-whatsapp-inbox/sql/01-whatsapp-schema.sql` | Creates the schema `service-whatsapp` with the conversation, message, read-marker and template tables. DDL: run it with a user that may create databases and tables. |
| `openspec/changes/archive/2026-12-02-add-whatsapp-inbox/sql/02-whatsapp-modules.sql` | Adds the WhatsApp modules `BO_WHATSAPP` (the inbox) and `BO_WHATSAPP_ADMIN` (every chat of the company, assigning owners, template sync). No role gets them; super admins grant them under Roles. |
Run both before `service-whatsapp` starts. Give the services' database user the same rights on `service-whatsapp` as on the other schemas. `99-rollback.sql` in the same folder removes the modules and drops the schema with every stored chat.
| File | What it does |
|---|---|
| `openspec/changes/archive/2026-12-02-add-zh-cn-messages/sql/01-locales.sql` | Creates `service-system`.`supported_locale` (the languages staff can pick: English and 简体中文 on; Malay, Traditional Chinese and Indonesian off) and `catalog_meta` (the label catalog version). DDL. |
| `openspec/changes/archive/2026-12-02-add-zh-cn-messages/sql/02-modules.sql` | Adds the back-office modules `BO_MESSAGES` (Translations) and `BO_LOCALES` (Languages) under System. No role gets them; super admins grant them under Roles. |
| `openspec/changes/archive/2026-12-02-add-zh-cn-messages/sql/03-zh-cn-messages.sql` | Loads the first-pass Chinese for every back-office label into `service-system`.`message`: inserts the labels that are missing, sets their Chinese, gives four rows (`LogIn`, `Member`, `Tree`, `Wallet`) the back office's English, and bumps the catalog version. Generated; run it once. |
| `openspec/changes/archive/2026-12-02-add-messages-colite-filter/sql/01-colite-filter-labels.sql` | Adds the "Co-Lite labels only" label. Run it only where the 03 file above already ran before this change; the regenerated 03 already includes it. |
Run the three in order before the new services-system, gateway and mobile-api go live. `01` needs a user that may create tables. Run `03` once only: it overwrites the Chinese of every back-office label, so running it again after staff have edited translations undoes their edits. `99-rollback.sql` in the same folder drops the two tables and removes the modules; the Chinese stays in `message`, which the previous images never read.
| File | What it does |
|---|---|
| `openspec/changes/archive/2026-12-02-add-landing-pages/sql/01-pages.sql` | Creates `service-counter`.`cms_page` (landing pages, blocks as JSON, slug unique per company) and `page_image` (uploaded images, at most 2 MB each). DDL. |
| `openspec/changes/archive/2026-12-02-add-landing-pages/sql/02-event-lead-web.sql` | Adds `page_path`, `utm_source`, `utm_medium` and `utm_campaign` to `event_lead`, for sign-ups from a landing page (source `WEB`). DDL. |
| `openspec/changes/archive/2026-12-02-add-landing-pages/sql/03-company-branding.sql` | Adds `logo_image_id` and `accent_color` to `service-system`.`company`. DDL. |
| `openspec/changes/archive/2026-12-02-add-landing-pages/sql/04-module.sql` | Adds the Pages back-office module (`BO_PAGES`) under Events. No role gets it; super admins grant it under Roles. |
| `openspec/changes/archive/2026-12-02-add-landing-pages/sql/05-page-labels.sql` | Adds the landing-page labels in English and Chinese. Run it only where `add-zh-cn-messages/sql/03` already ran before this change; the regenerated 03 already includes them. |
| `openspec/changes/archive/2026-12-03-add-custom-html-block/sql/01-hide-header.sql` | Adds `hide_header` to `service-counter`.`cms_page`, the "Hide page header" option. DDL. |
| `openspec/changes/archive/2026-12-03-add-custom-html-block/sql/02-html-block-labels.sql` | Adds the Custom HTML block labels in English and Chinese. Same rule as `05-page-labels.sql`: only where `add-zh-cn-messages/sql/03` already ran. |
| `openspec/changes/archive/2026-12-03-add-lead-notifications/sql/01-notification-columns.sql` | Turns the unused `service-system`.`notification` table into the staff bell: converts it to utf8mb4 and adds the recipient, company, type, link, collapse and read columns and two indexes. DDL. |
| `openspec/changes/archive/2026-12-03-add-lead-notifications/sql/02-notification-labels.sql` | Adds the bell's labels in English and Chinese. Same rule as `05-page-labels.sql`: only where `add-zh-cn-messages/sql/03` already ran. |
| `openspec/changes/archive/2026-12-03-add-page-anchor-links/sql/01-anchor-labels.sql` | Adds the "Link name" labels and updates the link hint and the bad-link message, in English and Chinese. Same rule as `05-page-labels.sql`: only where `add-zh-cn-messages/sql/03` already ran. No DDL: link names live in the page's blocks JSON. |
| `openspec/changes/archive/2026-12-03-add-page-sections/sql/01-section-labels.sql` | Adds the labels for the new page sections (feature cards, steps, trust strip, call to action), section looks and icons, in English and Chinese. Same rule as `05-page-labels.sql`: only where `add-zh-cn-messages/sql/03` already ran. No DDL: sections live in the page's blocks JSON. |
Run them in order before the new services-counter, services-system and mobile-api go live: the new services read the new columns on every event lead and company query. `01` to `03` need a user that may alter tables. `99-rollback.sql` in the same folder removes the module and drops the two tables and the columns, which deletes every page, image, page address and campaign tag.
**Review the privacy notice before go-live.** The seeded text is a starting template written for the PDPA, not legal advice. INS and CV should each have theirs checked; a super admin changes it under **Companies → Privacy notice**. A company with no notice has no working QR codes.
**Lead notifications (`add-lead-notifications`).** Run `01` before the new services-system goes live; it reads the new columns on every inbox query. Check first that the table is empty (`SELECT COUNT(*) FROM `service-system`.`notification`` returns 0). `01` needs a user that may alter tables. `99-rollback.sql` in the same folder drops the columns, the indexes and the labels, which deletes every notification's read state.
**Database user:**
- Create one user with `SELECT, INSERT, UPDATE, DELETE, EXECUTE` on the five schemas, and on `service-whatsapp` once that exists. EXECUTE is needed: service-member calls a stored function.
- Every Java service reads the same variables (section 6): `MYSQLHOST`, `MYSQLPORT`, `MYSQLUSER`, `MYSQLPWD`.
- Each service connects to its own schema.
## 4. Redis
Use the existing Redis. Every Java service reads `REDISHOST`; the port is fixed at 6379.
## 5. Google Pub/Sub
The services publish and subscribe through Google Pub/Sub. It is not replaced in phase 1.
- **Project:** use a Google Cloud project, and give its id as `GCP_PROJECT`.
- **Service account:** create one with the Pub/Sub Publisher and Pub/Sub Subscriber roles, and download a JSON key. Mount the key into every Java image except `api-gateway` (section 7), and set `GCP_CREDENTIAL_FILE=file:/var/secrets/gcp/key.json`.
- **Topics and subscriptions:** use `local/pubsub/topics.txt`. Each line is a topic name, optionally followed by a subscription name. Some topics appear on several lines with different subscriptions (e.g. `update-sync-topic`): create each topic once, then every subscription listed for it. Subscriptions use default settings.
- **Audit log:** `audit-event-topic` with `audit-event-subscription` carries admin audit events from mobile-api to service-log. It is in `topics.txt`; service-log also creates both at startup if they are missing. Keep the subscription's default of not retaining acknowledged messages: the events carry admin usernames and IPs. `AUDIT_RETENTION_DAYS` (section 6) must be at least 1, or service-log does not start.
## 6. Environment variables
**Secret** values go in a Kubernetes Secret. **Plain** values can go in a ConfigMap or straight into the Deployment.
**Shared by the six services (auth, system, counter, member, log, email) and mobile-api** (every Java image except `api-gateway`, which needs only `JWT_TOKEN`):
| Variable | Kind | Value |
|---|---|---|
| `JWT_TOKEN` | Secret | HS512 signing key, at least 32 characters. Must be the same value as `JWT_SECRET` on mobile-api. |
| `GCP_PROJECT` | Plain | Google Cloud project id |
| `GCP_CREDENTIAL_FILE` | Plain | `file:/var/secrets/gcp/key.json` (the mounted key) |
| `REDISHOST` | Plain | Redis host |
| `XXL_JOB_TOKEN` | Secret | Optional. Leave unset. |
**Also read by `service-system`, `service-counter`, `service-member`, `service-log` and `service-email`:**
| Variable | Kind | Value |
|---|---|---|
| `MYSQLHOST` | Plain | MySQL host |
| `MYSQLPORT` | Plain | `3306` |
| `MYSQLUSER` | Secret | Database user (section 3) |
| `MYSQLPWD` | Secret | Its password |
**`service-system` only:** `JUMIO_TOKEN` and `JUMIO_SECRET` (Secret). These are for identity checks Co-Lite does not use. Leave them unset.
**`service-auth` only:**
| Variable | Kind | Value |
|---|---|---|
| `AES_SECRET_KEY` | Secret | Random, 32 characters |
| `USER_AUTH_API_SECRET` | Secret | Random, at least 32 characters |
**`service-email` only.** No email or SMS provider has been chosen yet (see section 10). Choosing one takes more than its key: the provider, the sender addresses and the SMTP host are written in `application.yml` with Tastefully and Containerverse values. Spring lets an environment variable override any setting (upper-cased, `.` becomes `_` and `-` is dropped). So when a provider is chosen, also set:
- `EMAIL_PROVIDER`: one of `MAIL_JET`, `SEND_GRID`, `MAIL_GUN`, `SMTP` (today it is `MAIL_JET`);
- `EMAIL_SENDER` and `EMAIL_SENDERNAME`: the From address and name;
- for Mailjet, `MAILJET_SENDER`; for SendGrid, `SENDGRID_SENDER`;
- for SMTP, `SPRING_MAIL_HOST`, `SPRING_MAIL_PORT` and `SPRING_MAIL_USERNAME`;
- for Mailgun, `MAILGUN_API_BASE_URL` and `MAILGUN_API_MESSAGES_URL`, if the domain is not `mail.containerverse.dev`.
The keys:
| Variable | Kind |
|---|---|
| `MAILGUN_API_KEY` | Secret |
| `SENDGRID_API_KEY` | Secret |
| `MAILJET_API_KEY` | Secret |
| `MAILJET_SECRET_KEY` | Secret |
| `SMTP_PASSWORD` | Secret |
| `SMSS360_APIKEY` | Secret |
| `SMSS360_EMAIL` | Plain |
**`mobile-api`:**
| Variable | Kind | Value |
|---|---|---|
| `APIGATEWAYURL` | Plain | `http://api-gateway` |
| `APIKEY` | Secret | The key mobile-api sends to the gateway. Must equal the `key` of an entry in `appkeys.json` (section 7). |
| `AUTH_API_KEYS` | Secret | The keys mobile-api accepts from its clients, comma-separated, each `<key>:APP`. The admin portal's `MOBILE_API_KEY` must be one of them. |
| `JWT_SECRET` | Secret | Same value as `JWT_TOKEN` |
| `CUSTOMER_PORTAL_BASE_URL` | Plain | The customer portal is not deployed in phase 1. When unset, it falls back to a Tastefully address that only the member referral link uses, which Co-Lite does not use. Set it once a customer portal exists. |
| `ADMIN_PORTAL_BASE_URL` | Plain | Required. The public address of the admin portal, with no trailing slash (for example `https://admin.example.com`). Invite emails link to `<this>/i/<token>`. Links that staff copy or print in the portal (guest links, event and personal codes, the check-in code) use the address the staff member has open, so keep the two the same. mobile-api does not start without it. |
**`mobile-api` and `service-whatsapp`, for WhatsApp.** Both read the same variables; set them identically on both. Leave `WHATSAPP_COMPANIES` unset to keep WhatsApp off. A company whose four values are not all set is skipped with a warning in the log.
| Variable | Kind | Value |
|---|---|---|
| `WHATSAPP_COMPANIES` | Plain | The company codes that use WhatsApp, comma-separated, e.g. `INS,CV`. Each must match a company code in Co-Lite. |
| `WHATSAPP_<CODE>_PHONE_NUMBER_ID` | Plain | The company's WhatsApp phone number id from Meta (WhatsApp, API Setup) |
| `WHATSAPP_<CODE>_WABA_ID` | Plain | The company's WhatsApp Business Account id |
| `WHATSAPP_<CODE>_ACCESS_TOKEN` | Secret | A permanent System User token with `whatsapp_business_messaging` and `whatsapp_business_management` on that account. Not the 24-hour test token. |
| `WHATSAPP_<CODE>_APP_SECRET` | Secret | The Meta app's App Secret (App settings, Basic). It checks Meta's signature on every webhook call. Two companies in one Meta app share it. |
| `WHATSAPP_VERIFY_TOKEN` | Secret | Random, at least 32 characters. Typed into Meta once, when the webhook is set up. |
| `WHATSAPP_GRAPH_BASE_URL` | Plain | Optional (default `https://graph.facebook.com/v21.0`). Only `service-whatsapp` reads it. |
`service-whatsapp` also reads `MYSQLHOST`, `MYSQLPORT`, `MYSQLUSER` and `MYSQLPWD`. It uses no Pub/Sub, Redis or `key.json`. mobile-api reads the secrets on each request, so a rotated secret needs no restart there; `service-whatsapp` reads them at startup.
**`service-counter`, optional:** `LEADS_FOLLOWUPNOTICE_CRON` overrides when the daily follow-up summary runs (Spring cron, six fields, Malaysia time). Default `0 0 8 * * *`, 08:00. Run one service-counter replica, or the summary is sent once per replica; a second send on the same day only refreshes an unread summary.
**`service-log`:**
| Variable | Kind | Value |
|---|---|---|
| `AUDIT_RETENTION_DAYS` | Plain | Optional (default 730). Admin audit events older than this many days are deleted daily at 03:30. |
**`api-gateway`:** only `JWT_TOKEN` (same value as everywhere). No Pub/Sub, Redis or database settings, and no `key.json` mount. It reads its client keys from the mounted `appkeys.json` (section 7).
**`admin-portal`:**
| Variable | Kind | Value |
|---|---|---|
| `MOBILE_API_BASE_URL` | Plain | `http://mobile-api` (no trailing slash) |
| `MOBILE_API_KEY` | Secret | One of the keys in mobile-api's `AUTH_API_KEYS` (without the `:APP` suffix) |
| `SESSION_SECRET` | Secret | Required. Random, at least 32 characters. Signs the session cookie. If it is unset, the portal falls back to `MOBILE_API_KEY`, which ties the two together. |
| `SESSION_COOKIE_NAME` | Plain | Optional (default `colite_admin`). The cookie is always `__Host-` prefixed and Secure, so the portal must be served over HTTPS. |
| `SESSION_IDLE_TTL` | Plain | Optional, seconds (default 3600) |
| `SESSION_ABSOLUTE_TTL` | Plain | Optional, seconds (default 28800) |
| `SESSION_REFRESH_GRACE` | Plain | Optional, seconds (default 300) |
Generate each random value separately, for example with `openssl rand -base64 48`.
## 7. Mounted files
| File | Mounted into | Path | Content |
|---|---|---|---|
| `appkeys.json` | `api-gateway` | `/deployments/appkeys/appkeys.json` | The clients allowed to call the gateway (example below) |
| `key.json` | every Java image except `api-gateway` | `/var/secrets/gcp/key.json` | The Pub/Sub service-account key (section 5) |
`appkeys.json` holds one entry, for mobile-api. Keep it that way: mobile-api is what checks who may change whose password, so no other client may get a key that reaches the gateway's `/user/` routes.
```json
[
{
"key": "<the APIKEY value given to mobile-api>",
"name": "Co-Lite mobile-api",
"desc": "mobile-api calls to the gateway",
"type": "BO",
"allowList": ["/"],
"ipList": ["<pod CIDR of the cluster, or 0.0.0.0/0>"]
}
]
```
- `type`, `allowList` and `ipList` are required. The gateway reads all three on every request, and a missing one fails every call.
- `allowList` entries are matched anywhere in the request URL (`["/"]` allows everything). `ipList` is a list of CIDR ranges.
- `type` is one of `BO`, `APP`, `MB`, `SK`, `TP`, `PG`, `RS`, `KYC`. Use `BO`. **Never use `TP`: it skips login-token checks entirely.**
## 8. Traefik
The routes below are in `deploy/k8s/overlays/prod/routes.yaml`; `deploy/check.sh` fails if a route reaches anything else.
Route `co-lite.containerverse.dev` to the `admin-portal` Service on port 3000, with TLS. Only the admin portal is public: the browser talks to the portal, and the portal talks to `mobile-api` inside the cluster. Do not expose `mobile-api`, `api-gateway` or the services.
**WhatsApp webhook.** Meta must reach exactly one mobile-api path from the internet. Add a second route on the same host, for the path `/api/public/whatsapp/webhook` only (Traefik rule `Host(\`co-lite.containerverse.dev\`) && Path(\`/api/public/whatsapp/webhook\`)`), to the `mobile-api` Service on port 80. Expose no other mobile-api path. Every call on it is checked: a GET needs the verify token, and a POST needs Meta's signature under one of the configured app secrets (mobile-api checks it, and `service-whatsapp` checks it again).
QR registration pages (`/r/<code>`) are served by the admin portal on the same host, so nothing new is routed. mobile-api rate-limits visitors by the address the portal sends: the last entry of `X-Forwarded-For`, which is the one Traefik adds. That works whether Traefik appends to or replaces the header. If another proxy or load balancer sits in front of Traefik, the last entry is that proxy's address and every visitor shares one limit; the portal's `clientIp` would then have to change (or use the PROXY protocol). If the portal sees no `X-Forwarded-For` and no `X-Real-Ip` at all, every visitor shares the portal pod's limit.
**Public pages on their own hostname.** The owner wants the public pages (`/r`, `/i`, `/c`) served on their own hostname, for example `go.<domain>`, so that printed QR links survive a later move to the customer portal. Route that hostname to the same `admin-portal` Service with TLS, and set `ADMIN_PORTAL_BASE_URL` to the address the invitation links should carry.
**Landing pages.** Published pages live at `/p/<company-code>/<slug>` on the admin portal, with their images at `/api/public/page-images/<id>` and their form at `/api/public/pages/...`. They need no new route: serve them on the public-pages hostname above, so printed and shared page links survive a later move to the customer portal.
**Custom HTML frames.** A Custom HTML block loads in a sealed frame from `/p/<company-code>/<slug>/frame/<n>`, and staff preview a draft one at `/pages/<id>/preview/frame/<n>`. Both are portal routes on the same hostname as the page. Their responses carry their own `Content-Security-Policy: sandbox allow-scripts allow-popups allow-popups-to-escape-sandbox; frame-ancestors 'self'`. The proxy (Traefik or any other layer) must not replace or strip that header, and must not add `X-Frame-Options: DENY` to these paths. Without the sandbox header, pasted scripts would run as the portal's own origin when the address is opened directly. After deploy, open a frame address and check the response header.
## 9. Secret templates
The templates are in `deploy/k8s/secrets.example/`, one file per Secret, with placeholders only:
| Template | Secret | Read by |
|---|---|---|
| `co-lite-shared.env` | `co-lite-shared`: `JWT_TOKEN`, `MYSQLUSER`, `MYSQLPWD` | every Java service (api-gateway only `JWT_TOKEN`) |
| `co-lite-service-auth.env` | `co-lite-service-auth` | service-auth |
| `co-lite-mobile-api.env` | `co-lite-mobile-api` | mobile-api |
| `co-lite-admin-portal.env` | `co-lite-admin-portal` | admin-portal |
| `co-lite-whatsapp.env` | `co-lite-whatsapp` (optional) | mobile-api and service-whatsapp |
| `co-lite-registry.env` | `co-lite-registry`, the image pull secret | every pod |
| `co-lite-gateway-appkeys/appkeys.json` | `co-lite-gateway-appkeys` | api-gateway (section 7) |
| `co-lite-gcp-key/key.json` | `co-lite-gcp-key` | every Java service except api-gateway and service-whatsapp |
`deploy/create-secrets.sh` turns the filled-in copy into Secrets (section 2, step 4). It refuses to change anything while any key is missing, empty or still a placeholder. There is still no template for `service-email` (its keys wait for the email provider) or `service-system` (its Jumio keys stay unset).
## 10. Known gaps at go-live
- **No email provider yet.** Staff onboarding does not need one: the admin types each new user's first password, and "Set temporary password" on a user's page unlocks a user who forgot theirs. Both force a password change at the next sign-in. Forgot-password and "Send password reset" still create an email with a temporary password. Nobody receives it, but `service-email` saves every email first, so a super admin (or a role granted Emails) can read it under **Emails** and pass the password on in person. The user must change it at the next sign-in. Grant Emails narrowly: it shows every saved email, including other users' temporary passwords, member email-verification codes, and contact or distributor form submissions with the sender's personal data.
- **Sign-in lockout.** 5 failed sign-ins within 15 minutes lock a username, even with the right password, until 15 minutes after the first of those failures, and unknown usernames are counted too. Anyone who knows a username can therefore lock it on purpose. An admin with **Login security** can unlock it at once (Locked tab), and can change the limits there. If every super admin is locked, wait out the period. The lock check fails open: if `service-system` is down, sign-in still works without the lockout.
- **Companies and super admins.** INS and CV each see only their own leads, events, event leads, users, emails, login history and audit log. Staff sign in with their company code, username and password. A super admin leaves Company blank, sees every company (with a company picker in the header), and is the only one who can manage companies, roles, interests, lockout settings and password rules. Changing a company's code renames its staff's sign-in names and signs them out; deactivating a company blocks its staff from signing in. Emails sent from public forms and other system emails have no company, so only super admins see them. Do not give a company's old code to another company while sessions opened under the old code may still be valid: such a session token would resolve to the new company's user of the same name. When in doubt, never reuse a code.
- **Lead dashboard.** Users whose role has the Dashboard module see lead captures, wins, conversion and overdue follow-ups on the home page, for this month, last month or a custom range of up to two years in Malaysian time. A lead counts as converted when its status at an event is WON. Wins and days to win come from the status history, which starts with this release; for older leads it is approximate (see section 3).
- **QR self-registration.** Visitors scan a code and register themselves as a lead at an event. Each event has an event code, and each team member has a personal code that assigns the visitor to them; staff with Events see and switch them off on the event page, and every staff user finds their own under **My QR codes** in the user menu. Codes work until the event's end date (Malaysian time). A registration never edits an existing lead: differences go into that event lead's notes for staff to check. Each visitor IP may load 120 registration pages in 10 minutes across all events, and submit 60 registrations per event in 10 minutes; there is no CAPTCHA. For a reprintable code with scan counts, paste the code's link into the dynamic-qr console and print that code instead; no visitor data reaches dynamic-qr.
- **Invitations and check-in.** Staff with **Event guests** add guests to an event (one by one or by pasting a list), set the event's capacity and invitation cap, and send invitations. Without an email provider, a sent invitation is only saved under **Emails**; staff copy each guest's link and send it themselves. A guest registers through their own link (`/i/<token>`) and checks in at the door by the event's check-in code (`/c/<token>`), by mobile or email, or as a walk-in. Before the event, registration stops at capacity; on the event days nobody is refused. Staff with Events see the guest list read-only and the invited, registered, attended and walk-in numbers. Grant Event guests to the office admins who run invitations, together with Events (the guest actions need both); it is a permission only, with no menu entry of its own. Door check-in allows 300 lookups and walk-in registrations per visitor IP per event in 10 minutes; a large event where every visitor shares one venue Wi-Fi address can reach that, so ask visitors to use mobile data if check-ins start to be refused.
- **Error codes between services.** services-counter answers a refused request (for example `EVENT_FULL`) with a ProblemDetail whose `detail` is the reason code; mobile-api reads the code from there. Keep the core error handler in services-counter as it is.
- **Email sender.** services-email fills in its default sender when a request has none. Override the default sender address as in section 6 before email delivery is switched on.
- **Gateway paths open to the public registration.** The internal gateway lets a few exact read paths and the registration write through without a user token, so mobile-api can serve visitors who are not signed in. The invitations release adds five more, each an exact method and path: `GET /counter/eventGuest/findByToken/<22-character token>`, `POST /counter/eventGuest/register`, `GET /counter/checkin/findEvent/<22-character token>`, `POST /counter/checkin/lookup` and `POST /counter/checkin/byGuest`. Keep the gateway unexposed (above); the design notes in the change folder list the paths and the risk.
- **Time zone.** The Java images run with `TZ=Asia/Kuala_Lumpur` (set in the `docker-java-21` base image), and stored times such as capture, consent and notice times are Malaysian local time. Do not override `TZ` on the services.
- **Reference data from Tastefully.** It still holds some Tastefully business text (message templates with a phone number, bank account and form links; a public image bucket URL; Tastefully usernames in audit columns). Review it before go-live.
- **Other Tastefully defaults.** The sender addresses in `service-email` and the `CUSTOMER_PORTAL_BASE_URL` fallback point at Tastefully. Override them as described in section 6.
- **Leaked SMS key.** An SMS360 API key from Tastefully was in `service-email`'s config and is in git history. It has been removed from the config, but it must be rotated with SMS360 before go-live, by whoever owns that Tastefully account.
- **Deploy by SHA, not `latest`.** CI pushes the images one by one, so if a push fails halfway, `latest` can differ between images. `deploy/check.sh` refuses `latest`.
- **Chinese labels.** Staff switch the back office to 简体中文 with the language switcher, including on the sign-in page. The Chinese is a first pass, not checked by a native speaker. Grant `BO_MESSAGES` to the reviewer's role: under **Translations**, the **Missing Chinese** filter lists labels with no Chinese or with English copied in, and a saved change shows on the next page load. The list also holds about 3,400 labels inherited from Tastefully that Co-Lite never shows; the **Co-Lite labels only** box, ticked by default, hides them, and unticking it lists every label. Export and Import move all labels through a JSON file for review offline; import matches labels by code and never adds or removes languages. Grant `BO_LOCALES` only to whoever decides which languages staff can pick: English cannot be switched off. Only the back office is translated; visitor pages and emails keep their own wording.
- **Gateway paths for labels.** The gateway used to let every `/message/` path through without a user token. It now lets through only the label reads (`/message/catalogVersion`, `/message/getAllMessages/<area>`, `/message/getMessageJsonByAreaAndLocale/<area>/<locale>`, `/message/getMessageJsonForMobile/...`, the code lookups) and `GET /locale/findAllEnabled`. Saving, searching and the language writes need the user token mobile-api forwards. The gateway also gains a `/locale/**` route to services-system.
- **WhatsApp roles.** Staff need `BO_WHATSAPP` to see the inbox and their own chats. A WhatsApp admin needs both `BO_WHATSAPP` and `BO_WHATSAPP_ADMIN`: the menu entry and the page need the first, and the second adds every chat of the company, owner changes and template sync. A chat's owner is set automatically to the salesperson of the newest lead with that mobile number; an admin can set an owner by hand, which sticks until "Automatic" is chosen again. A user who is disabled or loses `BO_WHATSAPP` loses their chats to Unassigned.
- **WhatsApp limits at go-live.**
- Lists and chats refresh by polling (30 s for the list and the badge, 10 s for an open chat), not instantly.
- Meta keeps media for about 30 days; older photos and documents show "Media expired".
- The chat list shows the contact's WhatsApp name and number, not the lead's name; the chat itself links to the lead.
- For a WhatsApp admin the sidebar badge counts unread messages in every chat they can see, not only their own. For a super admin it counts every company, whichever company is picked in the header.
- A super admin who syncs templates with no company picked gets nothing back; pick the company first (the inbox does this by itself when syncing from a chat).
- A send that Meta accepts without a message id is stored as failed. A send that never gets an answer stays "Sending"; nothing sweeps it.
- Media is streamed with `;charset=UTF-8` added to its content type; browsers ignore it.
- Meta's media download address is not checked to be a Meta host before the access token is sent with it.
- **WhatsApp webhook and outages.** If `service-whatsapp` is down or answers with an error, the webhook answers 503 and Meta sends the event again, for up to 7 days; a message is never stored twice. The same happens right after `service-whatsapp` starts while `service-system` is unreachable. So on the first apply, check that `service-system` is ready before Meta starts sending (section 2, step 6).
- **Client addresses for rate limits.** mobile-api takes a caller's address for its rate limits from the first entry of `X-Forwarded-For` when the header is present (`HttpReqRespUtils` in core-libs). On the webhook route, a caller can set that header itself and so pick its own limit bucket. The webhook still rejects anything Meta did not sign, so this only weakens the flood limit (6000 calls per 10 minutes per address). Check that Traefik replaces an `X-Forwarded-For` sent by an untrusted caller instead of passing it on (`forwardedHeaders.insecure` off, `trustedIPs` limited to real proxies).
- **Landing pages.**
- Images live in MySQL (`page_image`), at most 2 MB each. That suits a few hundred images; past that, move them to object storage.
- Image ids are sequential and every image is public by id, so an image uploaded for a draft page can be read before the page is published. Do not upload anything confidential as a page image.
- An image removed from a page stays stored; nothing deletes unused images.
- The editor warns about unsaved edits only on reload or close, not when staff click another link in the back office.
- A standing enquiries event (section 12) appears in event lists and dashboards like any event.
- Links accept only `https://`, `mailto:`, `tel:`, a path starting with `/`, or `#` plus a block's link name.
## 11. Connecting WhatsApp (Meta)
Do this per company, after the services run with the variables of section 6. A Meta admin of the company's WhatsApp Business Account does it in Meta's developer console.
1. **Number and account.** In the Meta app, add the WhatsApp product and the company's business number. Note the phone number id and the WhatsApp Business Account id (WhatsApp, API Setup) for `WHATSAPP_<CODE>_PHONE_NUMBER_ID` and `_WABA_ID`.
2. **Token.** In Business Settings, create a System User, give it the WhatsApp account and the app, and generate a token that does not expire, with `whatsapp_business_messaging` and `whatsapp_business_management`. That is `WHATSAPP_<CODE>_ACCESS_TOKEN`.
3. **App secret.** App settings, Basic, App Secret: `WHATSAPP_<CODE>_APP_SECRET`.
4. **Webhook.** WhatsApp, Configuration, Webhook:
- Callback URL: `https://co-lite.containerverse.dev/api/public/whatsapp/webhook` (the route of section 8);
- Verify token: the value of `WHATSAPP_VERIFY_TOKEN`;
- Verify and save. Meta calls the URL once; mobile-api answers only when the token matches.
- Under Webhook fields, subscribe to `messages`. That one field carries incoming messages and the sent, delivered, read and failed updates.
If INS and CV use two Meta apps, set the same callback URL and verify token in both. mobile-api accepts a call signed with either app's secret.
5. **Templates.** Create the message templates in WhatsApp Manager and wait for Meta to approve them. Only approved templates appear in Co-Lite; a template Co-Lite cannot fill in (a media header or a header with a parameter, buttons with a parameter or copy-code buttons, named parameters) is listed but cannot be sent. Use numbered body parameters (`{{1}}`, `{{2}}`) only. Co-Lite syncs them nightly at 03:30; a WhatsApp admin can sync at once with **Sync from Meta** in the template picker.
6. **Roles.** Grant `BO_WHATSAPP` to the sales roles, and `BO_WHATSAPP` with `BO_WHATSAPP_ADMIN` to the roles that manage the inbox (section 10).
7. **First real message.** From a personal phone, send a WhatsApp message to the company's number. It must appear under WhatsApp within 30 seconds, in the right company only. Reply from Co-Lite and check that it arrives. Outside 24 hours after the customer's last message, Meta allows only templates; Co-Lite then offers only the template picker.
If nothing arrives: the mobile-api log says `WhatsApp webhook forward failed: <status>` when it could not hand an event on, and Meta's webhook page shows failed deliveries. A 401 there means the app secret does not match the app that sends.
## 12. Landing pages
Marketing builds public pages under **Events → Pages**. Each page has blocks (hero, text, image with text, feature cards, steps, trust strip, call to action, FAQ, sign-up form and custom HTML) and is a draft until published. Every block except custom HTML has a look: Default, Light grey, Dark or Company colour; the last three draw the block as a full-width band. In dark mode the Dark band shows light, as the page's colours invert. Its address is `/p/<company-code>/<slug>`.
1. **Module.** Grant `BO_PAGES` to the roles that build pages.
2. **Branding.** A super admin sets each company's logo and accent colour under **Companies → Branding**. Buttons on the company's pages use the accent colour, with black or white text, whichever is easier to read. Without them the page shows the company name and the default blue.
3. **Standing enquiries event.** A sign-up form always belongs to an event. For general enquiries, each company creates one event, for example "INS website enquiries", with a far-off end date and its sales team, and picks it in the form block. Sign-ups from a landing page are never marked as attended, so this event does not inflate attendance. Name it clearly: it shows in event lists and dashboards.
4. **The INS page.** The INS proof of concept (`ins-landing-page`, never deployed) is content, not code: rebuild it by hand in the editor after deploy. Its test leads are not imported.
- **Rebuild it as sections.** The INS page is pasted HTML today, which only a developer can maintain. Rebuild it from sections (hero, trust strip, feature cards, steps, FAQ, sign-up form, call to action) so marketing can edit it, then delete the Custom HTML block.
- **Jump to the form.** To make a button jump to the sign-up form, give the form block a link name, for example `signup`, and link the button to `#signup`. Links inside a Custom HTML block work the same way: on the INS page, change the HTML's `#consult` links to `#signup`. A `#name` link inside the HTML that matches an `id` in that same HTML (such as `#top`) scrolls to that spot instead.
5. **Drafts of published pages.** Once a page is published, Save keeps the changes as a draft: visitors still see the published version, and the editor shows **Publish changes** and **Discard changes**. Preview shows the draft. The pages list marks such pages "Unpublished changes". Publish changes checks the page again (an ended event, for example, is refused at its field). Switching the status back to Draft and saving takes the page offline and drops the separate draft. Two people saving the same page overwrite each other's draft, last save wins.
6. **Templates and Duplicate.** New page offers a blank page, **Event sign-up** and **Service showcase**. A template fills the editor with sections and placeholder text; staff replace the text and choose the form's event before saving. **Duplicate** (on the list and in the editor) opens a copy titled "… (copy)" with slug "…-copy" as a new draft; nothing is stored until Save.
7. **The on-page editor.** On a screen 1024 px or wider, the editor shows the page itself on a canvas, as visitors see it, with **Desktop** (a 1280 px screen scaled to fit) and **Phone** (390 px). Staff click a heading, text, button label, card or FAQ entry and type; rich text gets a small toolbar; clicking an image opens the file picker. Clicking a section selects it: its settings (look, link name, button link, event) show in the side panel, and its toolbar moves, duplicates, deletes or drags it. **Add section** sits under each section. Undo and redo (Ctrl+Z, Ctrl+Shift+Z) go back up to 50 steps and survive Save. A refused save selects the section and shows the message at its field in the panel. Narrower windows keep the form editor; resizing switches between them without losing unsaved edits. Leaving with unsaved edits, by a menu link too, asks first.
8. **Custom HTML on the canvas.** The canvas shows a Custom HTML block as last saved, marked **Save to update** while its HTML has unsaved edits; it shows the new HTML after Save. Preview always shows the saved version.
9. **Check.** Publish a page, open its address signed out, sign up through its form with `?utm_source=test` on the address, and check that the event lead shows source **Web page**, the page address and the campaign. Delete that test lead afterwards.
A form stops taking sign-ups when its event is disabled, its end date has passed (Malaysia time), or the company has no privacy notice; the page then says sign-up is closed and still shows its other blocks. Sign-ups share the QR pages' rate limits.
**Release add-page-drafts-and-templates (SQL, in its OpenSpec change folder):** run `sql/01-page-draft.sql` (adds `cms_page.draft`) before the new services-counter starts, then deploy services-counter, mobile-api and the portal, then run `sql/02-draft-template-labels.sql`. Rollback: previous images, then `sql/99-rollback.sql`, which drops every unpublished draft, so publish or note them first.
**Release add-page-visual-editor (SQL, in its OpenSpec change folder):** portal only. Deploy the portal, then run `sql/01-visual-editor-labels.sql`. Rollback: the previous portal image, then `sql/99-rollback.sql` (labels only). No data changes.
**Release add-hero-signup-form (SQL, in its OpenSpec change folder):** deploy services-counter, mobile-api and the portal (any order), then run `sql/01-hero-form-labels.sql` (labels only). A hero section can now carry the sign-up form for an event, beside its text. Rollback: the previous images. A hero saved with an event keeps it in its JSON. The old code ignores it and shows the hero without a form, so add a Sign-up form section to those pages if you roll back.
**Release add-hero-full-width (SQL, in its OpenSpec change folder):** deploy services-counter, then the portal, then run `sql/01-hero-full-width-labels.sql` (labels only). Deploy services-counter first, because the portal's editor saves the new hero fields. A hero can now run full width, carry bullet points, and give its form card a heading. Custom HTML frames now shrink to fit short content and no longer leave a gap next to a full-width hero. Rollback: the previous images. Saved heroes keep the new fields in their JSON; the old code ignores them and shows the boxed hero. The old services-counter refuses to save a hero that has points or a form heading, so remove them before saving such a page.
**Release add-html-image-upload (SQL, in its OpenSpec change folder):** deploy the portal, then run `sql/01-html-image-labels.sql` (labels only). A Custom HTML block's panel can now upload an image and show its link to copy. Rollback: the previous portal image.
**New portal dependencies:** `@tiptap/react`, `@tiptap/pm`, `@tiptap/starter-kit` and `@tiptap/extension-text-align` (the editor, loaded only on the editor screens), and `sanitize-html` (cleans page text on the server before it reaches a visitor). The image build installs them from `package-lock.json`; nothing to do by hand.