brand: rename product to "Read the Markets" (read.markets)

The product is now "Read the Markets" served at https://read.markets,
with the app at https://app.read.markets. "Cassandra" survives only as
the in-product AI persona (system prompt + "Ask Cassandra" chat label).

Centralised the brand in app/branding.py: BRAND_NAME, BRAND_SHORT,
DOMAIN, SITE_URL, APP_URL, EMAIL_FROM_DEFAULT. Jinja templates pull
{{ BRAND_NAME }} via globals registered in templates_env.py; Python
code reads branding.BRAND_NAME directly. The future-rename surface
is now a one-liner.

Updated: FastAPI app title, every page title (dashboard, news, log,
settings, upload, login, verify), header brand div, auth-card brands,
OTP email subject + HTML + plain-text bodies (incl. uppercase header
tag), OpenRouter X-Title + HTTP-Referer attribution headers, README.
Email tests now assert against branding.BRAND_NAME rather than the
literal string.

Internal identifiers deliberately kept on the legacy "cassandra" name
to avoid invalidating live sessions / advisory locks / configs:
cookies (cassandra_session, cassandra_pending) + itsdangerous salts,
MariaDB GET_LOCK keys, CASSANDRA_TOKEN env var, cassandra.css filename,
pyproject package name, localStorage prefs, outbound User-Agent strings.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Giorgio Gilestro 2026-05-22 19:39:38 +01:00
parent 9759080134
commit 824d849c63
15 changed files with 82 additions and 39 deletions

View file

@ -1,6 +1,12 @@
# Cassandra # Read the Markets
Containerised macro-strategy dashboard — hourly market data, RSS news, Trading 212 portfolio, and an AI-generated strategic log. Read-only by design. Containerised macro-strategy dashboard — hourly market data, RSS news, Trading 212 portfolio, and an AI-generated strategic log written by **Cassandra**, the in-product seer. Read-only by design.
Production:
- Landing: <https://read.markets>
- App: <https://app.read.markets>
The Python package is still named `cassandra` and several internal identifiers (cookie names, advisory-lock keys, `CASSANDRA_TOKEN` env var, CSS filename) keep the legacy name on purpose — renaming them would invalidate live sessions / locks / configs for no user benefit. See `app/branding.py` for the brand single-source-of-truth.
## Quick start ## Quick start

View file

@ -1,11 +1,20 @@
"""Cassandra brand palette — single source of truth. """Brand single source of truth — name, domain, palette, fonts.
Both the website's CSS (`app/static/css/cassandra.css`) and the email The product is **Read the Markets** (read.markets). "Cassandra" remains
templates (`app/services/email_service.py`) draw from these dicts. CSS the in-product *AI persona* (system prompt + chat label) distinct from
hand-authors the values in its `:root` / `[data-theme="light"]` blocks; the brand, the way Slackbot is distinct from Slack. Anything that crosses
a drift-detection test (`tests/test_branding_consistency.py`) asserts into user-visible chrome (page titles, email headers, OpenRouter referer)
that what's in this module matches what's in the CSS, so updating the must read `BRAND_NAME` from here; do not hard-code the string.
brand in one place without the other fails CI.
Internal identifiers (`cassandra_session` cookie, pyproject package name,
SQLAlchemy GET_LOCK keys, file `cassandra.css`, env var `CASSANDRA_TOKEN`)
keep the legacy name on purpose renaming them would invalidate live
sessions / advisory locks / configs for zero brand benefit.
The colour palette below is hand-authored in CSS as well; a drift-
detection test (`tests/test_branding_consistency.py`) parses
`cassandra.css` and asserts every variable matches. Update both or
neither.
The light theme is the *default* in emails mail clients can't read The light theme is the *default* in emails mail clients can't read
`localStorage`, so we can't replicate the dashboard's user-toggled `localStorage`, so we can't replicate the dashboard's user-toggled
@ -15,6 +24,14 @@ via media query.
from __future__ import annotations from __future__ import annotations
BRAND_NAME = "Read the Markets"
BRAND_SHORT = "Read"
DOMAIN = "read.markets"
SITE_URL = "https://read.markets"
APP_URL = "https://app.read.markets"
EMAIL_FROM_DEFAULT = f"noreply@{DOMAIN}"
DARK: dict[str, str] = { DARK: dict[str, str] = {
"bg": "#0a0e14", "bg": "#0a0e14",
"surface": "#11151c", "surface": "#11151c",

View file

@ -13,6 +13,7 @@ from fastapi import FastAPI
from fastapi.middleware.gzip import GZipMiddleware from fastapi.middleware.gzip import GZipMiddleware
from fastapi.staticfiles import StaticFiles from fastapi.staticfiles import StaticFiles
from app import branding
from app.config import get_settings from app.config import get_settings
from app.db import get_session_factory from app.db import get_session_factory
from app.logging import configure_logging, get_logger from app.logging import configure_logging, get_logger
@ -56,7 +57,7 @@ async def lifespan(app: FastAPI):
app = FastAPI( app = FastAPI(
title="Cassandra", title=branding.BRAND_NAME,
description="Macro-strategy dashboard", description="Macro-strategy dashboard",
version="0.1.0", version="0.1.0",
lifespan=lifespan, lifespan=lifespan,

View file

@ -44,7 +44,7 @@ async def send_email(
"""Send a (potentially multipart) email. `text_body` is required — """Send a (potentially multipart) email. `text_body` is required —
it's the fallback for clients that can't or won't render HTML.""" it's the fallback for clients that can't or won't render HTML."""
s = get_settings() s = get_settings()
sender = s.SMTP_FROM or s.SMTP_USER or "noreply@cassandra.local" sender = s.SMTP_FROM or s.SMTP_USER or branding.EMAIL_FROM_DEFAULT
msg = EmailMessage() msg = EmailMessage()
msg["From"] = sender msg["From"] = sender
@ -91,7 +91,7 @@ _OTP_HTML_TEMPLATE = """\
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="color-scheme" content="light dark"> <meta name="color-scheme" content="light dark">
<meta name="supported-color-schemes" content="light dark"> <meta name="supported-color-schemes" content="light dark">
<title>Your Cassandra sign-in code</title> <title>Your {brand} sign-in code</title>
<style> <style>
@media (prefers-color-scheme: dark) {{ @media (prefers-color-scheme: dark) {{
body {{ background:{D_bg} !important; }} body {{ background:{D_bg} !important; }}
@ -111,12 +111,12 @@ _OTP_HTML_TEMPLATE = """\
</head> </head>
<body style="margin:0; padding:24px 12px; background:{L_bg}; font-family:{FONT_MONO}; color:{L_text}; -webkit-font-smoothing:antialiased;"> <body style="margin:0; padding:24px 12px; background:{L_bg}; font-family:{FONT_MONO}; color:{L_text}; -webkit-font-smoothing:antialiased;">
<div style="display:none; max-height:0; overflow:hidden; mso-hide:all; font-size:1px; line-height:1px; color:{L_bg};"> <div style="display:none; max-height:0; overflow:hidden; mso-hide:all; font-size:1px; line-height:1px; color:{L_bg};">
Your Cassandra sign-in code {code} expires in {ttl_minutes} minutes. Your {brand} sign-in code {code} expires in {ttl_minutes} minutes.
</div> </div>
<table role="presentation" cellpadding="0" cellspacing="0" border="0" align="center" width="100%" style="max-width:520px; margin:0 auto; border-collapse:separate;"> <table role="presentation" cellpadding="0" cellspacing="0" border="0" align="center" width="100%" style="max-width:520px; margin:0 auto; border-collapse:separate;">
<tr><td class="card" style="background:{L_surface}; border:1px solid {L_border}; padding:32px 28px;"> <tr><td class="card" style="background:{L_surface}; border:1px solid {L_border}; padding:32px 28px;">
<div class="muted" style="font-size:11px; letter-spacing:0.32em; color:{L_muted}; text-transform:uppercase;"> <div class="muted" style="font-size:11px; letter-spacing:0.32em; color:{L_muted}; text-transform:uppercase;">
&#9648;&nbsp;CASSANDRA &#9648;&nbsp;{brand_upper}
</div> </div>
<div style="height:22px; line-height:22px; font-size:0;">&nbsp;</div> <div style="height:22px; line-height:22px; font-size:0;">&nbsp;</div>
<div class="h1" style="font-size:17px; font-weight:normal; color:{L_text}; letter-spacing:0.02em;"> <div class="h1" style="font-size:17px; font-weight:normal; color:{L_text}; letter-spacing:0.02em;">
@ -136,7 +136,7 @@ _OTP_HTML_TEMPLATE = """\
<div class="divider" style="border-top:1px solid {L_border};"></div> <div class="divider" style="border-top:1px solid {L_border};"></div>
<div style="height:14px; line-height:14px; font-size:0;">&nbsp;</div> <div style="height:14px; line-height:14px; font-size:0;">&nbsp;</div>
<div class="muted" style="font-size:10.5px; color:{L_dim}; letter-spacing:0.06em;"> <div class="muted" style="font-size:10.5px; color:{L_dim}; letter-spacing:0.06em;">
Sent automatically by Cassandra &middot; do not reply Sent automatically by {brand} &middot; do not reply
</div> </div>
</td></tr> </td></tr>
</table> </table>
@ -150,6 +150,8 @@ def _html_template_filled(code: str, ttl_minutes: int) -> str:
return _OTP_HTML_TEMPLATE.format( return _OTP_HTML_TEMPLATE.format(
code=code, code=code,
ttl_minutes=ttl_minutes, ttl_minutes=ttl_minutes,
brand=branding.BRAND_NAME,
brand_upper=branding.BRAND_NAME.upper(),
FONT_MONO=branding.FONT_MONO, FONT_MONO=branding.FONT_MONO,
**{f"L_{k.replace('-', '_')}": v for k, v in branding.LIGHT.items()}, **{f"L_{k.replace('-', '_')}": v for k, v in branding.LIGHT.items()},
**{f"D_{k.replace('-', '_')}": v for k, v in branding.DARK.items()}, **{f"D_{k.replace('-', '_')}": v for k, v in branding.DARK.items()},
@ -157,7 +159,7 @@ def _html_template_filled(code: str, ttl_minutes: int) -> str:
_OTP_TEXT_TEMPLATE = """\ _OTP_TEXT_TEMPLATE = """\
CASSANDRA sign in {brand_upper} sign in
Your verification code: Your verification code:
@ -168,7 +170,7 @@ If you didn't request it, you can safely ignore this email — no changes
will be made to any account. will be made to any account.
Sent automatically by Cassandra · do not reply Sent automatically by {brand} · do not reply
""" """
@ -180,8 +182,13 @@ def render_otp_email(code: str, ttl_minutes: int) -> tuple[str, str, str]:
(Notion, Substack). The lock-screen exposure tradeoff is minimal: (Notion, Substack). The lock-screen exposure tradeoff is minimal:
anyone with phone access who could see the notification could also anyone with phone access who could see the notification could also
open the email.""" open the email."""
subject = f"Cassandra sign-in: {code}" subject = f"{branding.BRAND_NAME} sign-in: {code}"
text = _OTP_TEXT_TEMPLATE.format(code=code, ttl_minutes=ttl_minutes) text = _OTP_TEXT_TEMPLATE.format(
code=code,
ttl_minutes=ttl_minutes,
brand=branding.BRAND_NAME,
brand_upper=branding.BRAND_NAME.upper(),
)
html = _html_template_filled(code=code, ttl_minutes=ttl_minutes) html = _html_template_filled(code=code, ttl_minutes=ttl_minutes)
return subject, text, html return subject, text, html

View file

@ -13,6 +13,7 @@ from datetime import datetime, timedelta, timezone
import httpx import httpx
from tenacity import retry, retry_if_exception_type, stop_after_attempt, wait_exponential from tenacity import retry, retry_if_exception_type, stop_after_attempt, wait_exponential
from app import branding
from app.config import get_settings from app.config import get_settings
@ -521,9 +522,10 @@ def _endpoint_for(provider: str) -> tuple[str, str, str, dict[str, str]]:
s.OPENROUTER_API_KEY, s.OPENROUTER_API_KEY,
s.OPENROUTER_MODEL, s.OPENROUTER_MODEL,
{ {
# OpenRouter-specific attribution headers. # OpenRouter-specific attribution headers. Visible on the
"HTTP-Referer": "https://github.com/local/cassandra", # OpenRouter dashboard — keep aligned with the live brand.
"X-Title": "Cassandra", "HTTP-Referer": branding.SITE_URL,
"X-Title": branding.BRAND_NAME,
}, },
) )
raise RuntimeError(f"Unknown LLM provider: {provider!r}") raise RuntimeError(f"Unknown LLM provider: {provider!r}")

View file

@ -3,7 +3,7 @@
<head> <head>
<meta charset="UTF-8" /> <meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>{% block title %}Cassandra{% endblock %}</title> <title>{% block title %}{{ BRAND_NAME }}{% endblock %}</title>
{# Apply saved theme before stylesheet renders to avoid a flash. #} {# Apply saved theme before stylesheet renders to avoid a flash. #}
<script> <script>
(function() { (function() {
@ -137,7 +137,7 @@
<body> <body>
<div class="app"> <div class="app">
<header class="app-header"> <header class="app-header">
<div class="brand">Cassandra</div> <div class="brand">{{ BRAND_NAME }}</div>
<nav> <nav>
<a href="/" class="{% if request.url.path == '/' %}active{% endif %}">Dashboard</a> <a href="/" class="{% if request.url.path == '/' %}active{% endif %}">Dashboard</a>
<a href="/news" class="{% if request.url.path == '/news' %}active{% endif %}">News</a> <a href="/news" class="{% if request.url.path == '/news' %}active{% endif %}">News</a>

View file

@ -1,5 +1,5 @@
{% extends "base.html" %} {% extends "base.html" %}
{% block title %}Cassandra · Dashboard{% endblock %} {% block title %}{{ BRAND_NAME }} · Dashboard{% endblock %}
{% block main %} {% block main %}
<div id="dash-header-container" <div id="dash-header-container"

View file

@ -1,5 +1,5 @@
{% extends "base.html" %} {% extends "base.html" %}
{% block title %}Cassandra · Strategic Log{% endblock %} {% block title %}{{ BRAND_NAME }} · Strategic Log{% endblock %}
{% block main %} {% block main %}
<section class="panel log-page" style="grid-column: 1 / -1;"> <section class="panel log-page" style="grid-column: 1 / -1;">

View file

@ -3,7 +3,7 @@
<head> <head>
<meta charset="UTF-8" /> <meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Cassandra · Sign in</title> <title>{{ BRAND_NAME }} · Sign in</title>
<script> <script>
(function() { (function() {
try { document.documentElement.dataset.theme = localStorage.getItem('cassandra.theme') || 'dark'; } try { document.documentElement.dataset.theme = localStorage.getItem('cassandra.theme') || 'dark'; }
@ -15,7 +15,7 @@
<body> <body>
<div class="auth-shell"> <div class="auth-shell">
<div class="auth-card"> <div class="auth-card">
<div class="auth-card__brand">Cassandra</div> <div class="auth-card__brand">{{ BRAND_NAME }}</div>
<div class="auth-card__hint">sign in with email</div> <div class="auth-card__hint">sign in with email</div>
{% if referrer_present %} {% if referrer_present %}

View file

@ -1,5 +1,5 @@
{% extends "base.html" %} {% extends "base.html" %}
{% block title %}Cassandra · News{% endblock %} {% block title %}{{ BRAND_NAME }} · News{% endblock %}
{% block main %} {% block main %}
<section class="panel" style="grid-column: 1 / -1;"> <section class="panel" style="grid-column: 1 / -1;">

View file

@ -1,5 +1,5 @@
{% extends "base.html" %} {% extends "base.html" %}
{% block title %}Cassandra · Settings{% endblock %} {% block title %}{{ BRAND_NAME }} · Settings{% endblock %}
{% block main %} {% block main %}
<section class="panel" style="grid-column: 1 / -1; max-width: 760px; margin: 0 auto;"> <section class="panel" style="grid-column: 1 / -1; max-width: 760px; margin: 0 auto;">

View file

@ -1,5 +1,5 @@
{% extends "base.html" %} {% extends "base.html" %}
{% block title %}Cassandra · Import Portfolio{% endblock %} {% block title %}{{ BRAND_NAME }} · Import Portfolio{% endblock %}
{% block main %} {% block main %}
<section class="panel" style="grid-column: 1 / -1; max-width: 760px; margin: 0 auto;"> <section class="panel" style="grid-column: 1 / -1; max-width: 760px; margin: 0 auto;">
@ -12,10 +12,10 @@
<p style="color: var(--muted); font-size: 12.5px; margin: 0 0 14px; line-height: 1.6;"> <p style="color: var(--muted); font-size: 12.5px; margin: 0 0 14px; line-height: 1.6;">
Export your pie from the T212 web app Export your pie from the T212 web app
(<span class="neu">Trading 212 → Investing → Your Pie → ⋯ → Export</span>) (<span class="neu">Trading 212 → Investing → Your Pie → ⋯ → Export</span>)
and drop the CSV here. Cassandra resolves each Slice to its Yahoo and drop the CSV here. Each Slice is resolved to its Yahoo ticker;
ticker; the parsed pie is kept in <em>this browser's localStorage</em> the parsed pie is kept in <em>this browser's localStorage</em> only.
only. The server learns just which tickers exist (anonymously) so it The server learns just which tickers exist (anonymously) so it can
can fetch their prices. fetch their prices.
</p> </p>
<form id="upload-form" autocomplete="off"> <form id="upload-form" autocomplete="off">

View file

@ -3,7 +3,7 @@
<head> <head>
<meta charset="UTF-8" /> <meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Cassandra · Verify email</title> <title>{{ BRAND_NAME }} · Verify email</title>
<script> <script>
(function() { (function() {
try { document.documentElement.dataset.theme = localStorage.getItem('cassandra.theme') || 'dark'; } try { document.documentElement.dataset.theme = localStorage.getItem('cassandra.theme') || 'dark'; }
@ -15,7 +15,7 @@
<body> <body>
<div class="auth-shell"> <div class="auth-shell">
<div class="auth-card"> <div class="auth-card">
<div class="auth-card__brand">Cassandra</div> <div class="auth-card__brand">{{ BRAND_NAME }}</div>
<div class="auth-card__hint">verify your email</div> <div class="auth-card__hint">verify your email</div>
<p class="auth-card__lede"> <p class="auth-card__lede">

View file

@ -8,6 +8,7 @@ from pathlib import Path
from fastapi.templating import Jinja2Templates from fastapi.templating import Jinja2Templates
from markupsafe import Markup, escape from markupsafe import Markup, escape
from app import branding
from app.services.glossary import wrap_glossary from app.services.glossary import wrap_glossary
@ -63,3 +64,10 @@ templates.env.filters["price"] = _fmt_price
templates.env.filters["signed"] = _fmt_signed templates.env.filters["signed"] = _fmt_signed
templates.env.filters["money"] = _fmt_money templates.env.filters["money"] = _fmt_money
templates.env.filters["glossary"] = _glossary_filter templates.env.filters["glossary"] = _glossary_filter
# Brand globals — every template that prints a product name should pull
# from these so a future rename is a one-liner in `app/branding.py`.
templates.env.globals["BRAND_NAME"] = branding.BRAND_NAME
templates.env.globals["BRAND_SHORT"] = branding.BRAND_SHORT
templates.env.globals["SITE_URL"] = branding.SITE_URL
templates.env.globals["APP_URL"] = branding.APP_URL

View file

@ -15,8 +15,9 @@ def test_render_otp_email_returns_three_parts():
def test_render_otp_email_includes_code_and_ttl(): def test_render_otp_email_includes_code_and_ttl():
from app import branding
subject, text, html = email_service.render_otp_email("123456", 15) subject, text, html = email_service.render_otp_email("123456", 15)
assert "Cassandra" in subject assert branding.BRAND_NAME in subject
assert "123456" in subject # subject embeds the code for inbox visibility assert "123456" in subject # subject embeds the code for inbox visibility
assert "123456" in text assert "123456" in text
assert "123456" in html assert "123456" in html
@ -38,9 +39,10 @@ def test_render_otp_email_html_is_well_formed_doctype():
def test_render_otp_email_html_has_preheader_and_responsive_styles(): def test_render_otp_email_html_has_preheader_and_responsive_styles():
from app import branding
_, _, html = email_service.render_otp_email("000000", 15) _, _, html = email_service.render_otp_email("000000", 15)
# Inbox preview snippet — must be present and contain the code. # Inbox preview snippet — must be present and contain the code.
assert "Your Cassandra sign-in code" in html assert f"Your {branding.BRAND_NAME} sign-in code" in html
# Responsive + dark-mode media queries indicate cross-client robustness. # Responsive + dark-mode media queries indicate cross-client robustness.
assert "prefers-color-scheme" in html assert "prefers-color-scheme" in html
assert "@media (max-width" in html assert "@media (max-width" in html