117 lines
6.5 KiB
Markdown
117 lines
6.5 KiB
Markdown
# Hub 2.0.0 — plan
|
||
|
||
**Done:** all eight steps, released as **2.0.0** on 2026-11-05 (CHANGELOG.md). Before deploying it the
|
||
first time, see `deployment.md` → "Upgrading to 2.0". Step 7 also added the install page's list of
|
||
the church's other products; step 4 added the next-invoice preview planned for step 7.
|
||
|
||
Cross Events Hub becomes **Cross Code Hub**: every product's customers, licences, stats, AI and
|
||
billing in one place (ROADMAP-v3 §5, phase 1, in `crosscode-platform/docs/ROADMAP-v3.md`). Planned
|
||
2026-11-04. Each step is its own branch (`feat/hub2-<step>`), merged with its tests into
|
||
**`release/2.0`** when it's done; `release/2.0` is merged into `main` and tagged **2.0.0** only when
|
||
every step is in (as Cross Events 2.0 was built). `main` stays at 1.7.x until then, so
|
||
`scripts/deploy.sh` (which deploys the latest `main` by default) never ships half of 2.0.
|
||
|
||
**Cross Events 2.1.x installs keep working unchanged:** protocol v1 replies stay identical. Events
|
||
moves to protocol v2 in Events 2.4.0.
|
||
|
||
## Where 1.7.0 stands
|
||
|
||
- One product everywhere: `Release` has no product, `latest_version` is one setting, release sync
|
||
reads `v1.2.3` tags from `hope-events` only.
|
||
- One licence = one install. Billing schedule, AI cap and markup, and invoices
|
||
(`@@unique([licenceId, periodStart])`) are all per licence.
|
||
- Protocol v1 only (`PROTOCOL_VERSIONS = [1]`), bodies checked by hand.
|
||
- Licence keys are `CEH-…`; prices are the Cross Events tiers only; UI and emails say "Cross
|
||
Events Hub".
|
||
|
||
## Decisions (2026-11-04)
|
||
|
||
| # | Question | Decision |
|
||
|---|----------|----------|
|
||
| 1 | Founding and bundle together | **Both apply:** founding prices first, then the bundle discount on them (Events Seed R230 + Website R64 = R294, less 15% = R250) |
|
||
| 2 | Add-ons on yearly billing | **12 × the monthly price** (add-ons are never discounted: no founding, bundle or yearly discount) |
|
||
| 3 | A product added to a customer already billed | Its **free month**, then a **prorated line** up to the customer's next invoice date, after which it's on every invoice |
|
||
| 4 | Licence key prefixes | `CEH-` Events (unchanged), `CCA-` Accounts, `CCW-` Website, `CCP-` App |
|
||
| 5 | Accounts licence | Created automatically (free, never invoiced) with a customer's first product licence |
|
||
| 6 | AI cap and markup | Per **customer** (moved from the licence); usage counted over all its installs, shown per product |
|
||
|
||
## Steps
|
||
|
||
### 1. Products foundation
|
||
|
||
- `@crosscode/contracts` vendored as `backend/vendor/crosscode-contracts-1.0.0.tgz`
|
||
(`file:` dependency; ROADMAP-v3 §2).
|
||
- `Product` enum (`events`, `accounts`, `website`, `app`): `Licence.product` and
|
||
`Install.product` (existing rows → `events`), `Install.publicKey`.
|
||
- One active licence per product per customer: a partial unique index on
|
||
`(customerId, product)` for licences that aren't revoked (a revoked one can be replaced).
|
||
- Key prefix per product (decision 4); the Accounts licence created with the first product
|
||
licence (decision 5).
|
||
- Until protocol v2 (step 2): only Events licences can register (`409 WRONG_PRODUCT`), and only
|
||
Events licences can be billed (step 4).
|
||
- "Cross Code Hub" in the UI and emails. The `hel1.` token prefix stays (it's protocol).
|
||
|
||
### 2. Protocol v2 (v1 still accepted)
|
||
|
||
- `PROTOCOL_VERSIONS = [1, 2]`. v2 bodies validated with the contracts' zod schemas; v1 keeps
|
||
today's handling as `product: "events"`.
|
||
- Register: the licence's product must match (`409 WRONG_PRODUCT`); the install's public key is
|
||
stored. Heartbeat: stats per product (Website storage and the App's active-member band feed
|
||
billing).
|
||
- v2 replies add `linkedProducts` (the church's other installs: product, URL, public key, nothing
|
||
else); v1 replies unchanged. Licence token gains `customerId` and `product`.
|
||
- Tests run every contract sample (`hub-register-*.json`, `hub-heartbeat-*.json`) through the routes.
|
||
|
||
### 3. Releases per product, with requirements
|
||
|
||
- `Release.product`, unique `(product, version)`; latest version per product.
|
||
- Release sources per product (Settings → Releases): repo, tag pattern, notes file, plus the
|
||
legacy `hope-events` `v…` source for Events. The sync only removes a release missing from its
|
||
own source.
|
||
- `— requires accounts 1.2.0` in a `WHATS-NEW.md` heading is stored on the release; Request
|
||
update answers `409 REQUIREMENT_NOT_MET` until the church's Accounts install reports that version,
|
||
and the Hub shows it on the install page.
|
||
- `releases`, `latestVersion` and update requests per product in the install API.
|
||
- Contracts **1.1.0**: optional `requires` on `releaseSchema`.
|
||
|
||
### 4. Billing per customer
|
||
|
||
- The schedule (cycle, billing start, next invoice date, review date) moves from `Licence` to
|
||
`Customer` (migrated); invoices unique `(customerId, periodStart)`.
|
||
- One invoice per customer per period: a line per product at its tier → founding → bundle (15%
|
||
two products, 25% three; Accounts doesn't count) → add-ons, undiscounted (decisions 1, 2).
|
||
- Prices: Events tiers (event income, unchanged); Website R99 + R20 per 5 GB above 5 GB (heartbeat
|
||
`storage`); App R99 / R249 / R399 / R649 / R999 / from R1 500 on `activeMembers90d`. Each
|
||
product's tier reviewed at the customer's yearly review.
|
||
- A product added mid-cycle: decision 3.
|
||
- Prices in step in `tiers.js`, `frontend/src/lib/tiers.ts` and crosscode-site `pricing.mjs`.
|
||
- Before deploying: a check that lists customers with two active licences for the same product
|
||
(the migration would fail on them). Run it against production first.
|
||
|
||
### 5. Address per customer
|
||
|
||
- Own domain (R0), Cross Code address (R10) or domain included (R25), with domain name and
|
||
renewal date. One line per invoice, never discounted. An email 30 days before an included domain
|
||
renews.
|
||
|
||
### 6. AI per customer
|
||
|
||
- Cap and markup move to the customer (decision 6); usage over all its installs, shown per product.
|
||
Nothing changes for installs.
|
||
|
||
### 7. Dashboard and pages
|
||
|
||
- Dashboard: installs per product, versions behind, health, licence status, monthly recurring
|
||
revenue after discounts, overdue invoices.
|
||
- Customer page: products, licences, address, a billing preview (the next invoice with its
|
||
discounts). Install page: product, linked products, requirements.
|
||
|
||
### 8. Docs and release
|
||
|
||
- `docs/hub-protocol.md` v2 (pointing to the contracts for the formats), README, CHANGELOG,
|
||
`deployment.md`.
|
||
- `hub.crosscode.co.za` with `events-hub.crosscode.co.za` kept as an alias (nginx and certificate,
|
||
done on the server).
|
||
- crosscode-site: bundle and address prices in `pricing.mjs`, Website and App still "coming".
|
||
- Tag `v2.0.0`.
|