Initial commit: BlackDice site rebuild with integrated CMS
Rebuilds content management around a single admin route (/admin — "BlackDice Studio"), replacing blackdice-studio.html. Publishing writes one JSON content document instead of regenerating HTML files, so it can no longer overwrite hand-made site changes the way the old tool did. - /admin: click-to-edit copy/images, article CRUD with a Word-safe rich text editor, demo clip management, per-page SEO, enquiry log, publish history with rollback - Real per-page URLs for all pages and articles, each with its own meta/canonical/OG/JSON-LD - Newsroom + article pages driven by the CMS post library, seeded from the old studio's export (17 articles) plus a drafted GSMA Open Gateway press release awaiting approval - Demo sections on Mobile SDK and Halo CPE, interactive by default and upgradable to an uploaded clip per slot - Dependency-free Node API server (auth, publish, uploads, snapshots, leads, live sitemap) - Deployment configs for Node/nginx/IIS, Vercel and Netlify See docs/ARCHITECTURE.md, docs/PROJECT-STRUCTURE.md, docs/CMS-GUIDE.md and docs/DEPLOYMENT.md. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,353 @@
|
||||
# BlackDice Website — Architecture
|
||||
|
||||
This document explains how the system is put together: the runtime pieces, how
|
||||
content flows from the CMS to a visitor's browser, and why the design avoids the
|
||||
failure mode that broke the old `blackdice-studio.html` tool.
|
||||
|
||||
For editors, see [CMS-GUIDE.md](CMS-GUIDE.md). For hosting, see
|
||||
[DEPLOYMENT.md](DEPLOYMENT.md). For a directory-by-directory reference, see
|
||||
[PROJECT-STRUCTURE.md](PROJECT-STRUCTURE.md).
|
||||
|
||||
---
|
||||
|
||||
## 1. System overview
|
||||
|
||||
```
|
||||
┌─────────────────────────────┐
|
||||
│ Visitor's browser │
|
||||
│ ┌─────────────────────────┐ │
|
||||
│ │ React app (Vite build) │ │
|
||||
│ │ src/main.tsx router │ │
|
||||
│ └───────────┬─────────────┘ │
|
||||
└──────────────┼─────────────────┘
|
||||
│ HTTPS
|
||||
┌──────────────────┴───────────────────┐
|
||||
│ server/index.mjs │
|
||||
│ (Node, zero dependencies) │
|
||||
│ │
|
||||
│ • serves dist/ (the built SPA) │
|
||||
│ • serves /content/site-content.json │
|
||||
│ • serves /content/uploads/* │
|
||||
│ • /api/* (auth, publish, leads, …) │
|
||||
│ • /sitemap.xml, /robots.txt (generated) │
|
||||
└──────────────────┬───────────────────┘
|
||||
│ reads / writes
|
||||
┌──────────────────┴───────────────────┐
|
||||
│ content/ │
|
||||
│ site-content.json ← published copy │
|
||||
│ versions/*.json ← one per publish │
|
||||
│ uploads/* ← images & clips │
|
||||
│ leads.jsonl ← form submissions │
|
||||
└────────────────────────────────────────┘
|
||||
```
|
||||
|
||||
Two things run in production:
|
||||
|
||||
1. **A static build** (`dist/`) — the React app, compiled once.
|
||||
2. **A small Node server** (`server/index.mjs`) — serves that build, serves the
|
||||
published content document, and exposes the API that `/admin` calls to publish.
|
||||
|
||||
There is no database. The published state is one JSON file plus a folder of
|
||||
uploaded media, both on disk.
|
||||
|
||||
---
|
||||
|
||||
## 2. The core design decision: content is data, not markup
|
||||
|
||||
The previous tool (`blackdice-studio.html`) worked by **exporting HTML** — every
|
||||
save cloned the live DOM into a new `index.html` and rebuilt `blog.html` from a
|
||||
template string. The export *was* the site. Anything a developer had hand-edited
|
||||
into those files — contact-form wiring, SEO tags, routing — was silently discarded
|
||||
on the next export, because there was only one copy of the truth and the CMS owned
|
||||
it entirely.
|
||||
|
||||
This project splits that single copy into two layers that never overwrite each
|
||||
other:
|
||||
|
||||
| Layer | What it holds | Who owns it | Where it lives |
|
||||
|---|---|---|---|
|
||||
| **Markup & code** | Page structure, CSS, the router, the enquiry-form logic, the demo players | Developers, via git | `src/`, built into `dist/` |
|
||||
| **Content** | Copy, images, articles, demo clips, SEO text, settings | Editors, via `/admin` | `content/site-content.json` |
|
||||
|
||||
`/admin` never writes to `src/` or regenerates any HTML file. Publishing writes
|
||||
**one JSON document**. A developer can change the page structure at any time
|
||||
without touching content, and an editor can change all the content at any time
|
||||
without touching structure. Requirement 1 (publishing wiping developer work)
|
||||
is therefore impossible by construction, not by discipline.
|
||||
|
||||
### How the two layers merge
|
||||
|
||||
`src/cms/store.tsx` resolves content in three ordered layers, each overriding the
|
||||
one before:
|
||||
|
||||
1. **The build** — `src/site/siteMarkup.txt` (page HTML with CMS hooks baked in)
|
||||
and `src/cms/pages.ts` (routes, default SEO, demo slot definitions).
|
||||
2. **Factory content** — `src/cms/generated/seedContent.json`, the one-time import
|
||||
of the old studio's article library. This is what a fresh install shows before
|
||||
anyone publishes anything.
|
||||
3. **Published content** — `content/site-content.json`, fetched at page load and
|
||||
merged over the first two.
|
||||
|
||||
If the API is unreachable (offline, static hosting with no server), the site still
|
||||
renders layers 1–2 rather than failing — see §7.
|
||||
|
||||
---
|
||||
|
||||
## 3. The CMS hook system
|
||||
|
||||
Every editable region in the page markup carries a stable attribute, injected once
|
||||
by a script rather than hand-added:
|
||||
|
||||
| Attribute | Marks | Example |
|
||||
|---|---|---|
|
||||
| `data-cms="cNNNN"` | An editable rich-text region (its `innerHTML`) | `<h1 data-cms="c0013">` |
|
||||
| `data-cms-img="imgNNN"` | A replaceable image (its `src`) | `<img data-cms-img="img001">` |
|
||||
| `data-cms-num="nNNN"` | An animated statistic (`data-count` / `data-suffix`) | `<div data-cms-num="n001">` |
|
||||
|
||||
**`scripts/inject-cms-ids.mjs`** parses `siteMarkup.txt`, walks the DOM tree, and:
|
||||
|
||||
- Assigns an id to every heading, paragraph, list item, button label, image and
|
||||
animated stat that isn't already inside another editable region (so a `<button>`
|
||||
containing only text becomes one field, not one field per nested `<span>`).
|
||||
- Skips elements the runtime rewrites itself (the live threat feed, React mount
|
||||
points) — editing them there would be silently discarded.
|
||||
- **Is idempotent**: re-running it after a markup edit keeps every existing id and
|
||||
only assigns new ones to new elements. This is verified in CI-equivalent fashion
|
||||
by asserting the stripped output is byte-identical to the pre-injection source.
|
||||
- Emits `src/cms/generated/cmsFields.json` — a manifest of every field (id, page,
|
||||
tag, text preview) that the admin's Pages panel uses to list and jump to fields.
|
||||
|
||||
652 fields exist today across 12 pages (625 text, 15 image, 12 animated stats).
|
||||
|
||||
Content editing therefore never touches `siteMarkup.txt` — it only ever writes
|
||||
`{ "c0013": "<b>new copy</b>" }` into the published JSON, which is applied at
|
||||
render time by `applyContent()` (`src/cms/store.tsx`) doing
|
||||
`el.innerHTML = override` for each id present in the document.
|
||||
|
||||
---
|
||||
|
||||
## 4. Runtime rendering: legacy markup + React islands
|
||||
|
||||
The site's page markup was originally a single hand-authored HTML body (from the
|
||||
Claude-built prototype). Rather than rewrite ~4,000 lines of markup into JSX
|
||||
(high risk of visual regression, no material benefit), `SiteApp.tsx` renders it
|
||||
as a raw string via `dangerouslySetInnerHTML`, then:
|
||||
|
||||
1. **Applies CMS overrides** into that DOM (`applyContent`).
|
||||
2. **Boots the ported vanilla controller** (`siteController.js` — page
|
||||
show/hide, nav highlighting, the enquiry-form modal, the live threat-feed
|
||||
animation, count-up animations). Its functions are exposed on `window` because
|
||||
the legacy markup's inline `onclick="goPage(event)"` handlers need to resolve.
|
||||
3. **Portals React components into named mount points** left in the markup —
|
||||
`<div id="news-grid-mount">`, `<div id="demos-p2-mount">`, etc. — using
|
||||
`createPortal`. This is how genuinely dynamic UI (the newsroom grid, article
|
||||
pages, demo tabs, the embedded threat-demo slider) lives inside the legacy DOM
|
||||
as idiomatic React, sharing the router and the CMS content context.
|
||||
|
||||
```tsx
|
||||
// src/site/SiteApp.tsx (shape, simplified)
|
||||
<div dangerouslySetInnerHTML={{ __html: siteHtml }} />
|
||||
{mounts['news-grid-mount'] && createPortal(<NewsGrid />, mounts['news-grid-mount'])}
|
||||
{mounts['demos-p2-mount'] && createPortal(<DemoSection page="p2" .../>, mounts['demos-p2-mount'])}
|
||||
{articleSlug && createPortal(<ArticlePage slug={articleSlug} />, mounts['pg-article'])}
|
||||
```
|
||||
|
||||
`/admin` reuses the exact same `SiteApp` component to render its live preview,
|
||||
passing the in-memory draft instead of the published document
|
||||
(`previewContent={draft}`). **The preview is not a simulation — it is the real
|
||||
site**, which is why "what you see in Studio is what visitors get" is literally
|
||||
true rather than a design goal.
|
||||
|
||||
---
|
||||
|
||||
## 5. Routing
|
||||
|
||||
`src/main.tsx` defines one real `<Route>` per page (from `src/cms/pages.ts`), plus
|
||||
`/blog/:slug` for articles, `/admin` for the CMS, and the standalone demo routes
|
||||
inherited from the original Angel demo build.
|
||||
|
||||
Within the legacy markup, all twelve "pages" are `<div id="pg-p1">` … `<div
|
||||
id="pg-p12">` siblings that were originally shown/hidden by a hash-router. That
|
||||
internal switch is preserved (`showPage()` in `siteController.js`, driven by
|
||||
`data-page` attributes and `id="pg-*"`), but it now sits **behind** the real
|
||||
router rather than being the only router:
|
||||
|
||||
- Clicking a nav item calls the legacy `go('p2')` →
|
||||
`siteController.js` calls `history.pushState` via the injected navigator
|
||||
(`setSiteNavigator`, wired to `useNavigate()`).
|
||||
- React Router owns the URL; a route change re-renders `<SiteApp pageId="p2">`;
|
||||
an effect calls `showPage('p2')` to do the actual show/hide in the DOM.
|
||||
- Back/forward, direct URL loads and shared links all go through React Router
|
||||
first, so they work correctly without any special-casing in the legacy code.
|
||||
|
||||
Every route updates `document.title`, the meta description, canonical link, and
|
||||
OG/Twitter tags via `src/cms/seo.ts`, and pushes a HubSpot virtual pageview.
|
||||
Articles additionally emit `BlogPosting` JSON-LD; the home page emits
|
||||
`Organization` JSON-LD.
|
||||
|
||||
Because these are real paths (not hash fragments), a host needs an SPA fallback
|
||||
for deep links — provided for `server/index.mjs`, Vercel (`vercel.json`), Netlify
|
||||
(`public/_redirects`) and IIS (`public/web.config`).
|
||||
|
||||
---
|
||||
|
||||
## 6. The API server
|
||||
|
||||
`server/index.mjs` is a single file with **no npm dependencies**, using only
|
||||
Node's `http`, `fs`, `crypto` and `path` built-ins. That constraint is deliberate:
|
||||
it can run anywhere Node runs, with no install step beyond Node itself, no
|
||||
supply-chain surface, and no framework version to keep patched.
|
||||
|
||||
| Route | Auth | Purpose |
|
||||
|---|---|---|
|
||||
| `POST /api/login` | — | Password → session token (throttled 10/15min/IP) |
|
||||
| `GET /api/content` | — | Published content document |
|
||||
| `POST /api/content` | session | Publish a new content document (snapshots the previous one first) |
|
||||
| `GET/POST /api/versions*` | session | List / load publish snapshots |
|
||||
| `POST /api/upload` | session | Store a base64 data-URL as a file, return its URL |
|
||||
| `POST /api/leads` | — | Record an enquiry-form submission |
|
||||
| `GET /api/leads` | session | List recorded enquiries |
|
||||
| `GET /sitemap.xml` | — | Generated live from published + factory posts |
|
||||
| `GET /content/uploads/*` | — | Serves uploaded media (range requests supported, for `<video>` seeking) |
|
||||
| `*` (fallback) | — | Serves `dist/index.html` — the SPA fallback |
|
||||
|
||||
**Sessions** are HMAC-signed `expiry.signature` tokens (`crypto.createHmac`), not
|
||||
JWTs — there's exactly one claim (an expiry), so a JWT library would be pure
|
||||
overhead. **Publishing is atomic**: the new document is written to a `.tmp` file
|
||||
and `rename()`'d into place, so a reader can never observe a half-written file,
|
||||
and the previous document is snapshotted to `content/versions/` before being
|
||||
replaced (last 60 kept), which is what powers one-click rollback in the History
|
||||
tab.
|
||||
|
||||
**Uploads** are capped at 32MB, restricted to images/video/PDF by content type,
|
||||
and images are downscaled client-side before upload (`fileToOptimisedDataUrl` in
|
||||
`src/cms/api.ts`) — the old studio embedded 8000px camera originals as base64
|
||||
directly in the HTML, which is most of why its exports were 20–27MB.
|
||||
|
||||
---
|
||||
|
||||
## 7. Resilience
|
||||
|
||||
The site is designed to degrade gracefully rather than fail hard:
|
||||
|
||||
- **API unreachable** (`fetchPublished()` in `src/cms/api.ts`) → the site renders
|
||||
factory content instead of a blank page. A 4-second timeout prevents a slow or
|
||||
hung API from blocking first paint indefinitely.
|
||||
- **Nothing published yet** → same fallback; a fresh install is a working site
|
||||
from the moment `npm run build` finishes.
|
||||
- **Editor's browser closes mid-edit** → the draft is mirrored to `localStorage`
|
||||
~600ms after each change (`useDraft.ts`) and restored on next visit, keyed to
|
||||
the published document it was based on (so a stale local draft from before
|
||||
someone else's publish is never silently reapplied).
|
||||
- **A field is deleted from the markup** (e.g. a section is removed by a
|
||||
developer) → its override in the content document simply has no matching
|
||||
element and is a no-op; nothing throws.
|
||||
- **Two editors publish at once** → last write wins (there is no lock), but every
|
||||
publish is snapshotted, so the loser's work is one click away in History, not
|
||||
gone.
|
||||
|
||||
---
|
||||
|
||||
## 8. Content model
|
||||
|
||||
`src/cms/types.ts` defines the single document every publish writes:
|
||||
|
||||
```ts
|
||||
interface SiteContent {
|
||||
content: Record<string, string> // data-cms id → innerHTML
|
||||
images: Record<string, string> // data-cms-img id → src
|
||||
numbers: Record<string, {value:number,suffix?:string}> // data-cms-num id → value
|
||||
posts: Post[] // the article library
|
||||
demos: Record<string, DemoSlot> // demo-slot key → clip config
|
||||
seo: Record<string, PageSeo> // page id → title/description/OG image
|
||||
settings: SiteSettings // form recipient, site URL, ...
|
||||
}
|
||||
```
|
||||
|
||||
A `Post` carries `slug`, `title`, `category` (insights/news/press/events), `date`,
|
||||
`author`, `excerpt`, `hero`, sanitised HTML `body`, and `status`
|
||||
(`draft`/`published`). Drafts are reachable by direct link (for review) but
|
||||
excluded from listings, the sitemap, and get a `noindex` robots tag.
|
||||
|
||||
---
|
||||
|
||||
## 9. Article body sanitisation
|
||||
|
||||
Editors paste directly from Word and Outlook, which carries `MsoNormal` classes,
|
||||
`Aptos` fonts, and black-on-transparent inline colours that fight the site's dark
|
||||
theme. Two sanitisers — kept in step — strip this:
|
||||
|
||||
- `scripts/seed-content.mjs` (regex-based) for the one-time bulk import from the
|
||||
old studio's JSON export, where no DOM is available (a plain Node script).
|
||||
- `src/cms/sanitise.ts` (`DOMParser`-based) for live editing in the browser,
|
||||
run on paste and again on blur.
|
||||
|
||||
Both keep only semantic tags (`h2`–`h4`, `p`, lists, `strong`/`em`, links, images,
|
||||
tables, blockquotes), strip every inline style and class, demote `h1`→`h2` (an
|
||||
article shouldn't compete with the page's own heading), and collapse empty
|
||||
elements left behind by unwrapping `<span>`/`<div>` wrappers.
|
||||
|
||||
---
|
||||
|
||||
## 10. The demo system
|
||||
|
||||
Two things exist for demos so a page is never empty and a video can be added
|
||||
without a code change:
|
||||
|
||||
- **Interactive fallback** — the Mobile SDK's five detections (scam call, scam
|
||||
SMS, SIM swap, per-device DNS, permissions) reuse `ThreatCinematic`
|
||||
(`src/demo/threats/ThreatDemo.tsx`), the same phone-mockup component used in the
|
||||
standalone `/threat-demos` slider, rendered in a `bare` mode with no frame or
|
||||
backdrop.
|
||||
- **CMS clip** — once a video is uploaded in Studio → Demos for a slot, `DemoSlot`
|
||||
gains a `video` URL and `DemoSection` (`src/site/demos/DemoSection.tsx`) switches
|
||||
from the interactive fallback to `<video>` for that tab, no redeploy needed.
|
||||
|
||||
`src/cms/pages.ts` declares the slot ↔ page ↔ interactive-scenario mapping once,
|
||||
shared by the site and by the Demos admin panel.
|
||||
|
||||
---
|
||||
|
||||
## 11. Build & tooling
|
||||
|
||||
| Tool | Role |
|
||||
|---|---|
|
||||
| **Vite** | Dev server + production bundler. `SiteApp`, `DemoScreen`, `DemoVideoPage` and `AdminApp` are separate lazy chunks so the site's CSS/JS never loads on demo-only routes, and vice versa. |
|
||||
| **TypeScript** (`strict`) | `npm run build` runs `tsc --noEmit` first — a type error fails the build before Vite even starts. |
|
||||
| **React Router v6** | Client-side routing (§5). |
|
||||
| **Framer Motion** | Animation in the demo components only. |
|
||||
| **No CSS framework** | The site's look is the original hand-authored `styles.css`; Studio's chrome is a separate, fully namespaced (`.bdcms-`) stylesheet so the two can never collide. |
|
||||
|
||||
No test runner is configured; correctness is currently established by
|
||||
`tsc --noEmit` plus the manual/browser verification described in
|
||||
[DEPLOYMENT.md](DEPLOYMENT.md)'s release checklist.
|
||||
|
||||
---
|
||||
|
||||
## 12. Threat model / trust boundaries
|
||||
|
||||
- `/admin` is the only privileged surface. It is password-gated
|
||||
(`ADMIN_PASSWORD`), sessions expire after 12 hours, and failed logins are
|
||||
throttled per-IP.
|
||||
- Article bodies and inline text are sanitised on the way *in* (§9), not just
|
||||
escaped on the way out — an editor pasting a compromised Word document can't
|
||||
inject a `<script>` into the published site.
|
||||
- Uploads are type-checked by declared MIME (not by trusting the filename
|
||||
extension) and size-capped.
|
||||
- There is deliberately no way for the CMS to write into `src/` or execute
|
||||
arbitrary code — the API's write surface is exactly `content/`.
|
||||
|
||||
---
|
||||
|
||||
## 13. Deliberate non-goals
|
||||
|
||||
- **No database.** A JSON file plus a folder of uploads is sufficient at this
|
||||
scale, is trivial to back up (`docs/DEPLOYMENT.md`), and removes an entire class
|
||||
of operational dependency.
|
||||
- **No multi-user editing / locking.** Last publish wins; snapshots make that an
|
||||
acceptable trade-off for a small editorial team rather than a public wiki.
|
||||
- **No SSR/SSG.** The site is client-rendered; this trades some first-paint SEO
|
||||
performance for radical simplicity in the content pipeline. If that trade-off
|
||||
needs revisiting (e.g. Core Web Vitals pressure), the content model in
|
||||
`src/cms/types.ts` does not need to change — only the rendering entry point
|
||||
would.
|
||||
@@ -0,0 +1,145 @@
|
||||
# BlackDice Studio — editor's guide
|
||||
|
||||
Studio is the one place the website is changed. It lives at
|
||||
**https://www.blackdice.ai/admin** (locally: <http://localhost:5173/admin>).
|
||||
|
||||
Nothing you do is visible to the public until you press **Publish changes**.
|
||||
|
||||
---
|
||||
|
||||
## The screen
|
||||
|
||||
- **Left:** the Studio panel — tabs, lists and settings.
|
||||
- **Right:** the real website, showing your unpublished draft. What you see is what
|
||||
visitors will get once you publish.
|
||||
- **Bottom left:** the Publish button, and a status line telling you whether you
|
||||
have unsaved changes.
|
||||
|
||||
Your work is saved in your browser as you type, so closing the tab by accident does
|
||||
not lose it. Reopen Studio and it comes back.
|
||||
|
||||
---
|
||||
|
||||
## Changing words and pictures — the Pages tab
|
||||
|
||||
1. Pick a page from the list (Home, Mobile SDK, News, Contact…).
|
||||
2. Make sure the toggle says **Edit page**.
|
||||
3. **Click any text on the page and type.** Enter makes a line break within the same
|
||||
heading or paragraph.
|
||||
4. **Click any image** to replace it. Pick a file — it is resized automatically, so
|
||||
photos straight from a camera are fine.
|
||||
5. Press **Publish changes**.
|
||||
|
||||
Useful details:
|
||||
|
||||
- The search box lists every piece of copy on the page. Click a line to jump
|
||||
straight to it on the page.
|
||||
- A line with an orange edge has been changed. Its **undo** button restores the
|
||||
original wording.
|
||||
- **Headline numbers** (the figures that count up as you scroll) are edited in the
|
||||
panel, as a number plus a suffix — e.g. `76` and `%`.
|
||||
- **Preview** turns editing off so you can click through the page like a visitor.
|
||||
|
||||
---
|
||||
|
||||
## Publishing an article — the Articles tab
|
||||
|
||||
Articles cover four categories: Insights, News, Press and Events. They appear in the
|
||||
newsroom at `/news`, in the "Latest news and insights" strip on the home page, and
|
||||
each gets its own page at `blackdice.ai/blog/<url>` that you can share.
|
||||
|
||||
**To add one:**
|
||||
|
||||
1. **+ New article**.
|
||||
2. Fill in the title, then press **from title** next to the URL so the web address
|
||||
matches the headline.
|
||||
3. Choose the category and date.
|
||||
4. **Author** — a credit in brackets is shown under the image, not next to the date.
|
||||
For example `Paul Hague (Image by Jorge Fernández Salas on Unsplash)`.
|
||||
5. **Excerpt** — the summary shown on cards and in Google results. Keep it under
|
||||
about 300 characters, or press "Use the opening of the article".
|
||||
6. **Hero image** — upload one; it is resized for you.
|
||||
7. **Body** — write in the editor, or paste straight from Word or Outlook. Pasted
|
||||
formatting is cleaned automatically so the article picks up the site's own fonts
|
||||
and colours. Use the toolbar for headings, lists, links and pull quotes.
|
||||
8. Leave the article as **Draft** while it is being reviewed. Draft articles are not
|
||||
listed anywhere and are kept out of Google, but you can still send the
|
||||
`/blog/<url>` link to a colleague for approval.
|
||||
9. Switch it to **Published**, then press **Publish changes**.
|
||||
|
||||
**Awaiting approval:** the GSMA Open Gateway press release is already in the library
|
||||
as a draft. It needs the approved quotes, the release and availability dates, a hero
|
||||
image, and the review note at the bottom removed — then switch it to Published.
|
||||
|
||||
**To remove an article:** open it and press Delete, then publish. Its URL will show
|
||||
a "that article has moved" page rather than an error.
|
||||
|
||||
---
|
||||
|
||||
## Demo clips — the Demos tab
|
||||
|
||||
Two pages carry demos:
|
||||
|
||||
- **Mobile SDK** — scam call (voice/VOIP), scam SMS, SIM swap, per-device DNS
|
||||
analytics, permissions checking. Until a clip is uploaded, each tab plays the
|
||||
interactive demo built into the site, so the page is never empty.
|
||||
- **Halo CPE** — the Retina dashboard and Angel web UI walkthroughs. These appear
|
||||
under the existing screenshots once a clip is uploaded.
|
||||
|
||||
For each slot you can set the title and caption, upload the clip (MP4 or WebM, up to
|
||||
32MB — for anything larger, host it and paste the URL), upload a poster still, and
|
||||
hide the slot entirely.
|
||||
|
||||
---
|
||||
|
||||
## Titles, Google and where enquiries go — the SEO tab
|
||||
|
||||
Per page: the browser/search title (aim for under 60 characters), the meta
|
||||
description (under 160), and an optional share image for LinkedIn and X.
|
||||
|
||||
Site-wide:
|
||||
|
||||
- **Enquiry forms send to** — every form on the site, currently
|
||||
`campbell.ferrier@blackdice.ai`.
|
||||
- **Copy enquiries to** — an optional second address.
|
||||
- **Public contact address** and the **canonical site URL**.
|
||||
|
||||
`sitemap.xml` is rebuilt automatically from whatever is published, so new articles
|
||||
become crawlable as soon as you publish them.
|
||||
|
||||
---
|
||||
|
||||
## Enquiries tab
|
||||
|
||||
Every form submission is recorded here — name, email, company, phone, the page they
|
||||
were on and their message — as well as being emailed. Export the list as CSV for
|
||||
HubSpot.
|
||||
|
||||
---
|
||||
|
||||
## History tab
|
||||
|
||||
- **Snapshots** — a copy of the site content is taken every time you publish. Click
|
||||
one to load it back into the editor; review it, then publish to roll back.
|
||||
- **Discard my draft** — throw away your unpublished edits and show exactly what is
|
||||
live.
|
||||
- **Download this draft** — a single JSON backup of all copy, articles, demos and
|
||||
settings.
|
||||
- **Import a file** — accepts one of those backups, or an old
|
||||
`blackdice-studio.json` draft (which brings its articles across).
|
||||
|
||||
---
|
||||
|
||||
## Questions people ask
|
||||
|
||||
**Will publishing undo the developers' work?**
|
||||
No. Studio only writes content — the copy, articles, images and settings. The page
|
||||
structure, links and forms live in the code and are never overwritten. That is the
|
||||
key difference from the old `blackdice-studio.html`.
|
||||
|
||||
**Two of us editing at once?**
|
||||
Avoid it. Studio publishes the whole content document, so the last publish wins.
|
||||
Agree who is editing, or publish in turns.
|
||||
|
||||
**Something looks wrong after publishing.**
|
||||
Open History, load the previous snapshot, and publish it.
|
||||
@@ -0,0 +1,126 @@
|
||||
# Deployment and operations
|
||||
|
||||
The app ships as a static build plus one small Node process. The Node process is
|
||||
what makes `/admin` able to publish, so **host it wherever the CMS is needed**.
|
||||
|
||||
```bash
|
||||
npm ci
|
||||
npm run build # → dist/
|
||||
ADMIN_PASSWORD='…' npm start # serves dist/ + the API on port 8787
|
||||
```
|
||||
|
||||
## Environment
|
||||
|
||||
| Variable | Default | Purpose |
|
||||
| --- | --- | --- |
|
||||
| `ADMIN_PASSWORD` | `blackdice` | Password for `/admin`. **Set this** — the server logs a warning while it is unset. |
|
||||
| `ADMIN_SECRET` | derived from the password | Signs session tokens. Set it to invalidate all sessions independently of the password. |
|
||||
| `PORT` | `8787` | Listen port. |
|
||||
| `CONTENT_DIR` | `./content` | Published content, uploads, snapshots, enquiries. Put this on persistent storage. |
|
||||
| `DIST_DIR` | `./dist` | The built site. |
|
||||
| `SITE_URL` | `https://www.blackdice.ai` | Canonical origin used in `sitemap.xml`. |
|
||||
|
||||
Sessions last 12 hours. Failed logins are throttled at 10 per IP per 15 minutes.
|
||||
Uploads are capped at 32MB and limited to images, MP4/WebM and PDF.
|
||||
|
||||
## What lives where
|
||||
|
||||
```
|
||||
content/
|
||||
site-content.json the published site: copy, articles, demos, settings
|
||||
versions/ one snapshot per publish (latest 60 kept)
|
||||
uploads/ images and clips uploaded through Studio
|
||||
leads.jsonl enquiry form submissions
|
||||
dist/ the built site (safe to delete and rebuild)
|
||||
public/content/posts/ article heroes imported from the old studio (in git)
|
||||
```
|
||||
|
||||
**Back up `content/`.** It is the only thing that cannot be rebuilt from the repo.
|
||||
A nightly copy of the directory is enough; `site-content.json` is a single small
|
||||
JSON file. Editors can also take their own backup from Studio → History → *Download
|
||||
this draft*.
|
||||
|
||||
## Behind IIS or nginx
|
||||
|
||||
Serve the app from Node and reverse-proxy to it — that keeps `/api`, uploads, the
|
||||
SPA fallback and the live sitemap working with no extra configuration.
|
||||
|
||||
nginx:
|
||||
|
||||
```nginx
|
||||
location / {
|
||||
proxy_pass http://127.0.0.1:8787;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
client_max_body_size 40M; # Studio uploads
|
||||
}
|
||||
```
|
||||
|
||||
IIS: install URL Rewrite + ARR and proxy the site to `http://127.0.0.1:8787`, or run
|
||||
it under iisnode. Raise `maxAllowedContentLength` to ~40MB for uploads.
|
||||
|
||||
Keep the process alive with a Windows service (`nssm`), `pm2`, or systemd:
|
||||
|
||||
```ini
|
||||
# /etc/systemd/system/blackdice-site.service
|
||||
[Service]
|
||||
WorkingDirectory=/srv/blackdice
|
||||
Environment=ADMIN_PASSWORD=…
|
||||
Environment=CONTENT_DIR=/srv/blackdice-content
|
||||
ExecStart=/usr/bin/node server/index.mjs
|
||||
Restart=always
|
||||
```
|
||||
|
||||
Docker:
|
||||
|
||||
```dockerfile
|
||||
FROM node:22-alpine
|
||||
WORKDIR /app
|
||||
COPY package*.json ./
|
||||
RUN npm ci
|
||||
COPY . .
|
||||
RUN npm run build
|
||||
ENV PORT=8787 CONTENT_DIR=/data
|
||||
VOLUME /data
|
||||
EXPOSE 8787
|
||||
CMD ["node", "server/index.mjs"]
|
||||
```
|
||||
|
||||
## Static hosting without the CMS
|
||||
|
||||
`dist/` can be served by any static host. Deep links need an SPA fallback, which is
|
||||
already configured for Vercel (`vercel.json`), Netlify (`public/_redirects`) and IIS
|
||||
(`public/web.config`). Apache:
|
||||
|
||||
```apache
|
||||
RewriteEngine On
|
||||
RewriteCond %{REQUEST_FILENAME} !-f
|
||||
RewriteCond %{REQUEST_FILENAME} !-d
|
||||
RewriteRule ^ index.html [L]
|
||||
```
|
||||
|
||||
In that setup the site shows the content compiled into the build and `/admin` cannot
|
||||
publish. To make a change, run Studio locally (`npm run dev`), publish, then commit
|
||||
the resulting `content/site-content.json` and any `content/uploads/` files and
|
||||
redeploy — the build copies neither automatically, so they must be placed alongside
|
||||
`dist/` (`dist/content/site-content.json`, `dist/content/uploads/…`).
|
||||
|
||||
## Release checklist
|
||||
|
||||
1. `npm ci && npm run build` — the build fails on type errors, so it gates itself.
|
||||
2. `node scripts/generate-sitemap.mjs https://www.blackdice.ai` if the static
|
||||
sitemap needs refreshing (the server's live one needs nothing).
|
||||
3. Deploy `dist/`, `server/`, `package.json`, and keep `content/` in place.
|
||||
4. Check: `/`, `/mobile-sdk`, `/news`, one `/blog/<slug>` deep link, `/sitemap.xml`,
|
||||
`/admin` login.
|
||||
5. In Search Console, submit `https://www.blackdice.ai/sitemap.xml` and request
|
||||
indexing for the product pages — they now have their own URLs to index.
|
||||
|
||||
## After the first deploy
|
||||
|
||||
- Set `ADMIN_PASSWORD` and share it only with the people who edit the site.
|
||||
- Publish once from Studio so `content/site-content.json` exists and snapshots begin.
|
||||
- Approve and publish the GSMA Open Gateway release (Studio → Articles).
|
||||
- Upload the Retina and Angel walkthrough clips (Studio → Demos) to finish the Halo
|
||||
CPE demos.
|
||||
@@ -0,0 +1,113 @@
|
||||
# Project structure
|
||||
|
||||
A directory-by-directory map of the repo. See [ARCHITECTURE.md](ARCHITECTURE.md)
|
||||
for how these pieces fit together at runtime.
|
||||
|
||||
```
|
||||
website-react/
|
||||
├── src/
|
||||
│ ├── main.tsx Router entry point — one route per page + /blog/:slug + /admin
|
||||
│ ├── vite-env.d.ts
|
||||
│ │
|
||||
│ ├── site/ ── The marketing website ──
|
||||
│ │ ├── SiteApp.tsx Renders siteMarkup.txt, applies CMS content, mounts React islands
|
||||
│ │ ├── siteMarkup.txt Page HTML (12 pages) with data-cms hooks — imported as a raw string
|
||||
│ │ ├── siteController.js Ported vanilla JS: page show/hide, nav, enquiry forms, live feed
|
||||
│ │ ├── styles.css The site's stylesheet (+ newsroom/article/demo additions)
|
||||
│ │ ├── blog/
|
||||
│ │ │ ├── NewsGrid.tsx Newsroom grid (/news) + home page "latest" strip, same data source
|
||||
│ │ │ └── ArticlePage.tsx Single article view at /blog/<slug>
|
||||
│ │ └── demos/
|
||||
│ │ ├── DemoSection.tsx Tabbed demo panel (Mobile SDK) — clip or interactive fallback
|
||||
│ │ └── DemoPlayer.tsx <video> player for a CMS-configured demo slot
|
||||
│ │
|
||||
│ ├── demo/ ── The BlackDice Angel product demo (pre-existing) ──
|
||||
│ │ ├── DemoScreen.tsx Full interactive demo player (Flows A–D)
|
||||
│ │ ├── DemoVideoPage.tsx Cinematic video-only page (/demo-video)
|
||||
│ │ ├── demo.css Scoped reset so the phone UI is pixel-faithful
|
||||
│ │ ├── components/ Icons, ScoreRing
|
||||
│ │ ├── context/ DemoContext (interactive flow state)
|
||||
│ │ ├── data/ mock.ts — sample data for the interactive flows
|
||||
│ │ └── threats/ Threat-detection scenario library
|
||||
│ │ ├── scenarios.ts 5 scenario definitions (scam call, SMS, SIM swap, DNS, permissions)
|
||||
│ │ ├── ThreatDemo.tsx The phone-mockup cinematic player (ThreatCinematic)
|
||||
│ │ ├── ThreatDemosSlider.tsx Slider through all scenarios (/threat-demos, or embedded)
|
||||
│ │ └── ThreatDemoPlayerPage.tsx Single scenario at /threat-demo/:id
|
||||
│ │
|
||||
│ └── cms/ ── Content model, API client, and the admin app ──
|
||||
│ ├── types.ts SiteContent, Post, DemoSlot, SiteSettings — the published document's shape
|
||||
│ ├── pages.ts Route table, default SEO copy, demo-slot ↔ page ↔ scenario mapping
|
||||
│ ├── store.tsx Merges factory + published content; ContentProvider/useContent; applyContent()
|
||||
│ ├── api.ts Fetch wrappers for every /api/* route; client-side image downscaling
|
||||
│ ├── seo.ts Per-route <title>/meta/canonical/OG/JSON-LD writer
|
||||
│ ├── sanitise.ts DOM-based HTML sanitiser for pasted/edited article bodies
|
||||
│ ├── generated/ Build artefacts — do not hand-edit
|
||||
│ │ ├── cmsFields.json Field manifest (652 fields), written by scripts/inject-cms-ids.mjs
|
||||
│ │ └── seedContent.json Factory content, written by scripts/seed-content.mjs
|
||||
│ └── admin/ ── BlackDice Studio (/admin) ──
|
||||
│ ├── AdminApp.tsx Shell: login gate, tabs, publish button, renders SiteApp as the live preview
|
||||
│ ├── admin.css Studio's chrome — fully namespaced .bdcms-*
|
||||
│ ├── useDraft.ts Editor's working copy: localStorage mirror, publish, discard, snapshots
|
||||
│ ├── useInlineEditor.ts Click-to-edit wiring over the previewed site
|
||||
│ ├── originals.ts Parses the shipped markup for "revert to original" / edited-field markers
|
||||
│ ├── RichText.tsx Article body editor (contentEditable + toolbar + paste sanitising)
|
||||
│ ├── PagesPanel.tsx Pages tab — field list, image/stat editing
|
||||
│ ├── PostsPanel.tsx Articles tab — full post CRUD
|
||||
│ ├── DemosPanel.tsx Demos tab — clip/poster upload per slot
|
||||
│ ├── SeoPanel.tsx SEO tab — per-page meta + site-wide settings
|
||||
│ ├── LeadsPanel.tsx Enquiries tab — submitted leads, CSV export
|
||||
│ └── HistoryPanel.tsx History tab — snapshots, import/export, discard
|
||||
│
|
||||
├── server/
|
||||
│ └── index.mjs The whole backend: auth, content, uploads, leads, sitemap. No dependencies.
|
||||
│
|
||||
├── scripts/
|
||||
│ ├── inject-cms-ids.mjs Adds data-cms/-img/-num hooks to siteMarkup.txt (idempotent)
|
||||
│ ├── seed-content.mjs Imports a blackdice-studio.json export into seedContent.json
|
||||
│ ├── resize-images.mjs Downscales oversized images (used by seed-content.mjs)
|
||||
│ ├── generate-sitemap.mjs Writes public/sitemap.xml + robots.txt from current content
|
||||
│ └── dev.mjs Runs the API server + Vite dev server together (npm run dev)
|
||||
│
|
||||
├── content-seed/
|
||||
│ └── additional-posts.json Posts authored in-repo (e.g. the GSMA release) — survive re-imports
|
||||
│
|
||||
├── content/ Runtime data — NOT in git (see .gitignore)
|
||||
│ ├── site-content.json The published document
|
||||
│ ├── versions/ One snapshot per publish
|
||||
│ ├── uploads/ Images/clips uploaded via Studio
|
||||
│ └── leads.jsonl Enquiry form submissions
|
||||
│
|
||||
├── public/ Static assets served as-is
|
||||
│ ├── logo.svg, *.png Brand assets and product screenshots
|
||||
│ ├── content/posts/ Article hero images imported from the studio export (in git)
|
||||
│ ├── sitemap.xml, robots.txt Static fallback (server generates a live version too)
|
||||
│ ├── _redirects Netlify SPA fallback
|
||||
│ └── web.config IIS SPA fallback
|
||||
│
|
||||
├── docs/
|
||||
│ ├── ARCHITECTURE.md How the system works (this is the deep-dive)
|
||||
│ ├── PROJECT-STRUCTURE.md This file
|
||||
│ ├── CMS-GUIDE.md For editors: how to use Studio
|
||||
│ └── DEPLOYMENT.md For ops: environment, hosting, backups, release checklist
|
||||
│
|
||||
├── index.html Vite entry HTML (default meta tags; overwritten per-route at runtime)
|
||||
├── vite.config.ts Dev server + API proxy config
|
||||
├── tsconfig.json
|
||||
├── vercel.json Vercel SPA fallback
|
||||
├── package.json
|
||||
└── README.md Start here
|
||||
```
|
||||
|
||||
## Where to make a given kind of change
|
||||
|
||||
| I want to… | Change this |
|
||||
|---|---|
|
||||
| Edit copy, images or an article | Don't touch code — use `/admin` |
|
||||
| Change page layout/structure | `src/site/siteMarkup.txt`, then `npm run cms:ids` |
|
||||
| Add a new page/route | `src/cms/pages.ts` (`PAGES` array) + a matching `id="pg-pN"` block in `siteMarkup.txt` + `Route` in `main.tsx` |
|
||||
| Change site-wide styling | `src/site/styles.css` |
|
||||
| Change Studio's own UI | `src/cms/admin/*` and `admin.css` |
|
||||
| Add an API endpoint | `server/index.mjs` (`handleApi`) |
|
||||
| Change what's in the published document | `src/cms/types.ts` (`SiteContent`) — update `mergeContent` in `store.tsx` too |
|
||||
| Add a demo slot | `src/cms/pages.ts` (`DEMO_SLOTS`) + a mount `<div>` in `siteMarkup.txt` + portal it in `SiteApp.tsx` |
|
||||
| Change article sanitisation rules | Both `src/cms/sanitise.ts` **and** `scripts/seed-content.mjs` — keep them in step |
|
||||
Reference in New Issue
Block a user