Files
co-lite/docs/deployment.md

44 KiB

Co-Lite Deployment Handover

This is for whoever deploys Co-Lite to the Kubernetes cluster. CI builds and publishes the images. The deployer writes the manifests and rolls them out. 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. Spring Boot turns these on by itself on Kubernetes. GET /actuator/health also works everywhere.
  • 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

  1. The DBA prepares MySQL (section 3).
  2. Create the Pub/Sub topics and the service-account key (section 5).
  3. Create the Secrets and mounted files (sections 6 and 7).
  4. Deploy, in this order:
    1. service-system, service-auth, service-counter, service-member, service-log, service-email, service-whatsapp;
    2. api-gateway;
    3. mobile-api;
    4. admin-portal.
  5. Add the Traefik routes (section 8).
  6. Connect WhatsApp in Meta (section 11). This can wait: until it is done, the inbox says "WhatsApp is not configured".
  7. 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.

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:

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 asadmin` 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/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/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.

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.

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-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.

[
  {
    "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

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-apiService 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, andservice-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

There is no template yet for service-email (its keys wait for the email provider) or service-system (its Jumio keys stay unset). Kubernetes Secrets hold base64 values. Encode each one with printf '%s' 'value' | base64 -w0. These are templates: replace every <…> and never commit the filled-in files.

apiVersion: v1
kind: Secret
metadata:
  name: co-lite-shared
type: Opaque
data:
  JWT_TOKEN: <base64>
  MYSQLUSER: <base64>
  MYSQLPWD: <base64>
---
apiVersion: v1
kind: Secret
metadata:
  name: co-lite-service-auth
type: Opaque
data:
  AES_SECRET_KEY: <base64>
  USER_AUTH_API_SECRET: <base64>
---
apiVersion: v1
kind: Secret
metadata:
  name: co-lite-mobile-api
type: Opaque
data:
  APIKEY: <base64>
  AUTH_API_KEYS: <base64>
  JWT_SECRET: <base64, same value as JWT_TOKEN>
---
apiVersion: v1
kind: Secret
metadata:
  name: co-lite-admin-portal
type: Opaque
data:
  MOBILE_API_KEY: <base64>
  SESSION_SECRET: <base64>
---
apiVersion: v1
kind: Secret
metadata:
  name: co-lite-whatsapp
type: Opaque
data:
  # mounted into both mobile-api and service-whatsapp; one ACCESS_TOKEN and APP_SECRET pair per company code
  WHATSAPP_INS_ACCESS_TOKEN: <base64>
  WHATSAPP_INS_APP_SECRET: <base64>
  WHATSAPP_CV_ACCESS_TOKEN: <base64>
  WHATSAPP_CV_APP_SECRET: <base64>
  WHATSAPP_VERIFY_TOKEN: <base64>
---
apiVersion: v1
kind: Secret
metadata:
  name: co-lite-gateway-appkeys
type: Opaque
data:
  appkeys.json: <base64 of the whole appkeys.json file>
---
apiVersion: v1
kind: Secret
metadata:
  name: co-lite-gcp-key
type: Opaque
data:
  key.json: <base64 of the service-account JSON key>

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.

  • 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. Keep service-system up before service-whatsapp (section 2).

  • 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: or a path starting with /. A same-page #anchor link (for example a hero button that jumps to the form) is refused; use the page's own path instead.

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, FAQ and a sign-up form) and is a draft until published. 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.
  5. 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.

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.