Skip to content

Every analytics tool wants a subscription. And your data. I built Twiligent instead. YouTube stats. Instagram stats. One dashboard. Runs locally on your machine.

docs: document the design system, measured reference and cleanup

spacesdrive10d64a9516b2
diff --git a/.gitignore b/.gitignore
index 18e3e8d..a99818a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -51,3 +51,6 @@ yarn-debug.log*
skills-lock.json
.dev.vars
+
+# Third-party interface reference captures (kept local, not redistributed)
+docs/screenshots/reference/
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 2366ba0..9a2c4ce 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,6 +7,24 @@ Format follows [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
## [Unreleased]
+### Changed
+
+**Interface redesign in the Twiligent brand**
+- New app shell: 256px sidebar with the Twiligent lockup, search, grouped navigation, account and category lists, and a user menu with theme and sign-out; a 50px top bar with breadcrumb, refresh and theme toggle
+- Every page rebuilt on shared components and design tokens: Sora headings, Manrope text, JetBrains Mono numbers, brand red for primary actions and active states, warm dusk and paper surfaces, hairline borders
+- Light and dark themes from the same tokens, with a system option; the logo switches between the paper and dusk lockups with the theme
+- Overview opens with a greeting, quick actions and selectable metric tiles
+- Videos, Shorts, Instagram content, Reddit posts and Tracked content share one library layout: search, filter chips, quiet tables or card grids and a pager
+- Adding an account is a choice-card flow with a review step; Publish is a working surface with the editor on the left and settings on the right
+- Settings reorganised into labelled sections, with a theme picker
+- UI copy in sentence case, without exclamation marks; error messages say what to do next
+- Charts use the brand data-visualisation series in both themes
+
+### Removed
+
+- Legacy root `public/` dashboard, unmounted `trackedPosts.js` route, unused Redis OAuth helpers, unused shadcn block templates and the unused Geist font package
+- Duplicated helpers merged: platform badges and avatars, account paths, chart styling, filter tiers, pagination, Reddit post table, `safeAccount()`, Instagram publishing parameters
+
### Fixed
**Instagram Reels counted as Videos**
@@ -17,6 +35,14 @@ Format follows [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
### Added
+**Redesign additions**
+- Command palette (Ctrl+K or Cmd+K) for pages, accounts, categories, theme and actions
+- Hold-to-confirm for removing accounts, untracking content and deleting scheduled posts
+- `/accounts?add=1` opens the add-account flow directly
+- Location field in bulk publishing (the value was already sent with each post but had no input)
+- Frontend unit tests (`cd frontend && npm test`) and backend tests for credential stripping and Instagram publishing parameters
+- `docs/design-reference.md` and `docs/architecture/frontend/DESIGN_SYSTEM.md`
+
**Instagram views by content type**
- Views are fetched from the Instagram `views` insight alongside media, with no extra requests per item; items without insights show `-` instead of 0
- Instagram analytics page: Total Views plus Reels, Posts, and Videos cards; views columns in the top posts and content type tables
diff --git a/DECISIONS.md b/DECISIONS.md
index b4e2af9..3444cc3 100644
--- a/DECISIONS.md
+++ b/DECISIONS.md
@@ -506,3 +506,39 @@ Records every significant architectural decision, the alternatives considered, a
- When any item on a page cannot return insights (for example media posted before the account became professional), Instagram fails the entire page. That page is refetched without views, so its items show `-` rather than a number. Page size is 50 to limit the impact.
- Meta's reference labels `media_product_type` as Facebook Login only, but it is returned for Instagram Login in practice. The permalink fallback keeps classification correct if it is ever omitted.
- Views are organic Instagram views only and can lag by up to 48 hours, per Meta.
+
+---
+
+## ADR-023: Interface rebuilt on a token system: measured reference structure, Twiligent brand skin
+
+**Date:** 2026-10-13
+**Status:** Accepted
+
+**Decision:** The frontend is restyled onto design tokens in `frontend/src/index.css`. Layout, density, component shapes, states and motion follow measurements taken from a reference interface (recorded in `docs/design-reference.md`). Colour, typography, logo, accent and copy voice come from the Twiligent brand kit in `frontend/public/`. Shared components (`PageHeader`, `SurfaceBox`, `MetricBox`, `ConfirmDialog`, `CommandPalette` and others, listed in `docs/architecture/frontend/DESIGN_SYSTEM.md`) replace per-page markup. `MainCard` and `StatCard` are removed.
+
+**Context:** Pages used hard-coded Tailwind palette colours (blue primary, pink, orange, purple) unrelated to the brand, repeated the same helpers on every page (platform badges, avatar fallbacks, rank colours, chart styling, filter tiers, pagination), and loaded Inter from Google Fonts while the brand kit ships Sora, Manrope and JetBrains Mono.
+
+**Alternatives considered:**
+- Recolouring the existing shadcn theme only: fast, but leaves the duplicated page markup and the off-brand palette classes in place.
+- Adopting the brand's capsule buttons everywhere: the measured reference uses 10 to 12px rounded rectangles for controls. Structure follows the reference, so controls use the measured radii and badges keep the capsule as the brand echo.
+
+**Trade-offs:**
+- shadcn primitives in `components/ui/` now carry project styling. Regenerating one with the shadcn CLI overwrites it, so diff before accepting.
+- Destructive actions (removing an account, untracking content, deleting scheduled posts) now require press-and-hold. This is slower by design.
+- Fonts are served from `/fonts` on the same origin and preloaded, removing the third-party Google Fonts request.
+- `@fontsource-variable/geist` was installed but never imported, and is removed.
+
+---
+
+## ADR-024: Removed dead and duplicated code
+
+**Date:** 2026-10-13
+**Status:** Accepted
+
+**Decision:** Removed the original vanilla-JS dashboard in the repository root `public/` (from the initial commit, pointed at `localhost:3000`), the unmounted `backend/routes/trackedPosts.js` (superseded by `trackedContent.js`), the unused Redis OAuth state helpers in `backend/lib/cache.js`, and unused shadcn block templates in `frontend/src/components/`. `safeRedditAccount()` and the route-local `safeAccount()` are merged into `backend/lib/safeAccount.js`. Instagram container parameters are built by one function, `buildMediaParams()`, used by both the publish route and the cron scheduler.
+
+**Context:** The duplicated publishing parameter logic had to be changed in two Worker files for every new Instagram field, and two sanitisers for the same response shape made it easy to forget a credential.
+
+**Trade-offs:**
+- `scripts/publish-scheduled.js` still has its own copy of the publishing logic. It runs in GitHub Actions with zero npm dependencies and cannot import Worker modules.
+- The root `package.json` (an Express setup with no server file) is left in place because it also pins the shadcn CLI used from the repository root.
diff --git a/README.md b/README.md
index ab8e560..3e9f8f9 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,6 @@
<div align="center">
- <img src="frontend/public/logo.png" alt="Twiligent" width="96" />
+ <img src="frontend/public/Logos/twiligent-lockup-stacked.svg" alt="Twiligent" width="160" />
<h1>Twiligent</h1>
diff --git a/claude.md b/claude.md
index b1fe188..f96f648 100644
--- a/claude.md
+++ b/claude.md
@@ -32,6 +32,7 @@ For MCP usage, read `docs/mcp/OVERVIEW.md` before using any MCP server.
```
docs/
WRITING_STANDARDS.md Typography, icons, writing style, UI copy, commit messages
+ design-reference.md Measured interface reference, brand kit inventory, token sources
architecture/
OVERVIEW.md System topology, connections, request lifecycle
backend/
@@ -43,6 +44,7 @@ docs/
CRON.md Scheduled handlers, cron triggers
frontend/
REACT_ARCHITECTURE.md Provider tree, lazy loading, App.jsx
+ DESIGN_SYSTEM.md Tokens, shared components, page patterns
ROUTING.md All pages, paths, layout nesting
CONTEXTS.md AuthContext, AppContext, usage rules
API_LAYER.md api.js, request(), auth header injection
@@ -112,6 +114,8 @@ Read `docs/WRITING_STANDARDS.md` for the full specification. The non-negotiable
- Error messages explain what went wrong and what to do - no "Something went wrong"
- One comment per non-obvious logic block, maximum - never restate what the code does
- Every page must feel like it belongs to the same application: consistent padding, cards, skeletons, toasts, icons
+- All styling goes through the design tokens in `frontend/src/index.css` and the shared components listed in `docs/architecture/frontend/DESIGN_SYSTEM.md`; no hex or Tailwind palette colours in components
+- Brand assets (logos, fonts, tokens, guidelines) live in `frontend/public/`; sentence case in UI copy, no exclamation marks
---
diff --git a/docs/WRITING_STANDARDS.md b/docs/WRITING_STANDARDS.md
index 55c2368..7739c77 100644
--- a/docs/WRITING_STANDARDS.md
+++ b/docs/WRITING_STANDARDS.md
@@ -19,7 +19,7 @@ These rules apply to all generated code, documentation, UI copy, commit messages
- Never use emoji as icons in UI.
- Use SVG icons only.
-- Prefer Lucide React icons (`lucide-react`).
+- Prefer Lucide React icons (`lucide-react`) at a 1.75 stroke. Platform logos (YouTube, Instagram, Reddit) come from `components/brand/platform-icons.jsx`.
- If Lucide does not have an appropriate icon, use another open-source SVG icon library (e.g. Heroicons, Radix Icons).
- All icons in the same UI context must have consistent size, stroke width, spacing, and visual weight.
@@ -111,12 +111,15 @@ Every page must feel like it belongs to the same application.
Maintain:
-- Consistent page padding (`p-6` wrapper)
-- Consistent vertical rhythm (`space-y-6` between sections)
-- Consistent card structure (shadcn `Card` with `CardHeader`/`CardContent`)
-- Consistent loading states (shadcn `Skeleton`)
-- Consistent error display (toast notifications via `showToast`)
-- Consistent icon usage (Lucide, same stroke width)
-- Consistent button variants (primary for main action, outline for secondary)
+- One `PageHeader` per page; the app shell provides page padding
+- Consistent vertical rhythm (`flex flex-col gap-6` between sections)
+- Consistent containers (`SurfaceBox`, `MetricBox`) and design tokens only, no palette colours
+- Consistent loading states (`PageSkeleton`, `Skeleton`), empty states (`EmptyState`) and error display (toasts via `showToast`)
+- Consistent icon usage (Lucide, 1.75 stroke)
+- Consistent button variants (default for the main action, outline for secondary, ghost for tertiary)
+- Destructive actions confirmed with `ConfirmDialog` and `hold`
+- Sentence case in all UI copy, and no exclamation marks
+
+See `docs/architecture/frontend/DESIGN_SYSTEM.md` and `docs/design-reference.md`.
The entire project should feel like one polished application, not independently built pages.
diff --git a/docs/architecture/backend/CACHING.md b/docs/architecture/backend/CACHING.md
index ac82df5..15b5c8c 100644
--- a/docs/architecture/backend/CACHING.md
+++ b/docs/architecture/backend/CACHING.md
@@ -25,9 +25,8 @@ export async function getVideosCache(redis, userId, accountId) {
| `videos:{userId}:{accountId}` | Array of YouTube video objects with stats | `GET /api/accounts/:id/analytics` succeeds | `DELETE /api/accounts/:id` |
| `ig:{userId}:{accountId}` | `{ media, fetchedAt, version }` - normalized Instagram media (see `normalizeInstagramMedia()`) | `GET /api/accounts/:id/ig-analytics` or `ig-media` succeeds, or the Overview warms it | `DELETE /api/accounts/:id`, or a `version` mismatch |
| `reddit:{userId}:{accountId}` | Object `{ profile, analytics, posts }` for Reddit account | `GET /api/accounts/:id/reddit-analytics` succeeds | `DELETE /api/accounts/:id` |
-| `oauth_ig:{state}` | userId string (legacy, Redis-backed) | Instagram OAuth URL generation | Consumed on callback; 10-min TTL |
-**Note:** The `oauth_ig:` key is a legacy path. The current OAuth implementation uses HMAC-signed state tokens that don't require Redis. This key is set and consumed only when Redis is available, as a secondary verification layer.
+**Note:** Instagram OAuth state is an HMAC-signed token and does not use Redis. The unused Redis-backed `oauth_ig:` helpers were removed.
## Cache Versioning
diff --git a/docs/architecture/backend/SERVICES.md b/docs/architecture/backend/SERVICES.md
index fa2af9a..2cf60f3 100644
--- a/docs/architecture/backend/SERVICES.md
+++ b/docs/architecture/backend/SERVICES.md
@@ -132,12 +132,11 @@ All Reddit public JSON API calls go through `redditFetch(path, cookie)`. Request
| `fetchRedditProfile(username, cookie)` | Fetches profile data from `/user/{username}/about.json` |
| `fetchRedditPosts(username, cookie, limit)` | Paginates submitted posts up to `limit` (default 100) via `/user/{username}/submitted.json` |
| `computeRedditAnalytics(profile, posts)` | Computes score stats, subreddit breakdown, posting time patterns, monthly breakdown, virality/consistency scores |
-| `safeRedditAccount(account)` | Strips the `cookie` field before any API response |
| `fetchTrackedPostData(postUrl, cookie)` | Fetches score, comments, and metadata for any public Reddit post URL using the `.json` trick; optionally uses a session cookie |
-### `safeRedditAccount(account)`
+### Credentials in responses
-Strips the `cookie` field before the account object is returned in any API response, identical in purpose to `safeAccount()` for Instagram access tokens.
+Account responses for every platform pass through `safeAccount()` in `backend/lib/safeAccount.js`, which strips the Reddit `cookie` along with the Instagram `accessToken` and sets `hasCookie` so the frontend can show session status.
### No Worker secrets required
@@ -145,6 +144,12 @@ Reddit integration requires no Worker secrets. The session cookie is a per-user
---
+## Shared Instagram publishing parameters
+
+`buildMediaParams(post, accessToken)` in `services/instagram.js` builds the Graph API container parameters for photos, Reels, Stories and carousel items. The publish route (`routes/publishing.js`) and the cron scheduler (`utils/scheduler.js`) both call it. `scripts/publish-scheduled.js` keeps its own copy on purpose: it runs in GitHub Actions with zero npm dependencies and cannot import Worker code.
+
+---
+
## Adding a New Service
1. Create `backend/services/myPlatform.js`
diff --git a/docs/architecture/database/SECURITY.md b/docs/architecture/database/SECURITY.md
index ed7e60f..3ee7655 100644
--- a/docs/architecture/database/SECURITY.md
+++ b/docs/architecture/database/SECURITY.md
@@ -57,5 +57,5 @@ The GitHub Personal Access Token stored in `settings.value.githubPat` is stored
When reviewing security, check these files:
- `backend/middleware/auth.js` - JWT verification
- `backend/lib/db.js` - every function that accepts an optional `userId` should either: require it explicitly, or have a documented reason for omitting it (cron use case)
-- `backend/services/instagram.js` - `safeAccount()` definition and usage
+- `backend/lib/safeAccount.js` - `safeAccount()` definition; it strips every stored credential for all platforms
- All route files in `backend/routes/` - verify `safeAccount()` is called on every account response
diff --git a/docs/architecture/frontend/DESIGN_SYSTEM.md b/docs/architecture/frontend/DESIGN_SYSTEM.md
new file mode 100644
index 0000000..73f2f0e
--- /dev/null
+++ b/docs/architecture/frontend/DESIGN_SYSTEM.md
@@ -0,0 +1,67 @@
+# Frontend Design System
+
+The interface follows one rule: **structure** (layout, density, shapes, states, motion) comes from a measured reference interface, and **skin** (colour, type, logo, accent, copy voice) comes from the Twiligent brand kit in `frontend/public/`. Every value and its source is recorded in `docs/design-reference.md`.
+
+## Tokens
+
+All tokens live in `frontend/src/index.css`: raw values on `:root` and `.dark`, mapped into Tailwind through `@theme inline`. Components never use hex values or Tailwind palette colours (`bg-red-500`, `text-pink-600`).
+
+| Group | Utilities | Notes |
+|---|---|---|
+| Surfaces | `bg-surface`, `bg-surface-raised`, `bg-surface-sunken`, `bg-surface-hover`, `bg-surface-selected`, `bg-surface-wash` | Page, cards, wells, hover, selected rows, choice cards |
+| Lines | `border-line`, `border-line-control`, `border-line-strong`, `border-divider` | Hairlines, control borders, text input borders (3:1), dividers inside boxes |
+| Text | `text-ink`, `text-ink-muted`, `text-ink-faint`, `text-ink-inverse` | All pass WCAG AA on every surface in both themes |
+| Brand | `bg-brand`, `hover:bg-brand-hover`, `bg-brand-soft`, `text-brand-text`, `text-on-brand` | Red as text is always `text-brand-text` |
+| Status | `success`, `warning`, `danger`, `info`, each with `-soft` | Errors share the brand red, so they always carry an icon and the word "Error" |
+| Charts | `var(--chart-1)` to `var(--chart-5)` via `lib/chart.js` `SERIES` | Brand series order; platforms map to series in `lib/accounts.js` |
+| Type | `font-heading` (Sora), `font-sans` (Manrope), `font-mono` (JetBrains Mono); `text-display`, `text-page-title`, `text-section`, `text-body`, `text-small`, `text-caption` | Fonts are self-hosted from `frontend/public/fonts` and preloaded in `index.html` |
+| Radius | `rounded-row` 10, `rounded-control` 10, `rounded-field` 12, `rounded-card` 16, `rounded-panel` 24, `rounded-dialog` 24, `rounded-pill` | Buttons, inputs and chips are rounded rectangles; badges keep the brand capsule |
+| Sizes | `h-(--control-h-sm)` 32, `h-(--control-h)` 36, `h-(--control-h-lg)` 40, `--nav-row-h` 32, `--topbar-h` 50, `--sidebar-w` 256 | |
+| Motion | `duration-(--duration-fast)` 75ms, `--duration-base` 150ms, `--duration-overlay` 200ms, `animate-fold-in` 220ms | `prefers-reduced-motion` collapses all motion |
+
+Light is the `:root` default; `.dark` (set by `next-themes`, `attribute="class"`) redefines the same tokens. Users choose Light, Dark or System in Settings, the sidebar user menu, the top bar, or the command palette.
+
+## Components
+
+Shared components live in `frontend/src/components/`. Reach for these before writing markup.
+
+| Component | Use it for |
+|---|---|
+| `PageHeader` | The one title block per page: optional back link, eyebrow, avatar media, description and actions |
+| `SurfaceBox` | Any grouped content. Optional title row with `subheader` and `secondary` actions |
+| `MetricBox` | A single metric: icon, label, tabular value, one line of context. `highlight` marks the page's lead metric |
+| `SectionHeader` | A heading between groups of boxes |
+| `ListRow`, `RankNumber` | Dense clickable rows and mono rank numbers |
+| `SearchField`, `FilterChips` | Library search and single-select filters |
+| `Pager` | Previous and next with a count |
+| `MediaCard`, `MediaChip` | Thumbnail cards for videos, Shorts and Instagram media |
+| `ChartPanel` | A titled Recharts container with an empty state |
+| `MetricAreaChart` | A single-series area chart |
+| `ChoiceCard` | Large selectable cards in creation flows |
+| `DetailPanel`, `FieldRow` | The settings side panel of a working surface, and label plus hint plus control rows |
+| `ConfirmDialog` | Confirmation. Pass `hold` for destructive actions |
+| `HoldToConfirmButton` | Press and hold (pointer or Space or Enter) to confirm; a click never fires it |
+| `CommandPalette` | Ctrl+K or Cmd+K search over pages, accounts, categories and actions |
+| `EmptyState`, `ErrorState`, `LoadingState`, `PageSkeleton` | Every data view needs all of these |
+| `AccountAvatar`, `PlatformBadge`, `PlatformIcon` | Account and platform identity, never by colour alone |
+| `brand/Logo` | The theme-aware lockup, or the mark when the sidebar is collapsed |
+
+## Page patterns
+
+| Pattern | Pages | Shape |
+|---|---|---|
+| Home | Overview | Display greeting, quick-action tiles, selectable metric tiles, detail per metric |
+| Library | Videos, Shorts, Instagram content, Reddit posts, Tracked content | Search, filter chips, quiet table or card grid, pager |
+| Detail | YouTube channel, Instagram account, Reddit account, Category | Back link, avatar header, metric grids, underline tabs or sections |
+| Create | Accounts (add flow) | Choice cards, then a form step, then review before commit |
+| Working surface | Publish | Main editor on the left, sticky `DetailPanel` with settings and the primary action on the right |
+| Settings | Settings | Sections with a label column and content column |
+
+## Rules
+
+- One `PageHeader` per page. Gaps between page sections are `gap-6`, or `gap-8` on pages with large sections.
+- Destructive actions go through `ConfirmDialog` with `hold`.
+- Every async action disables its trigger, shows a spinner or progress, and ends in a toast that names what happened.
+- Sentence case in all UI copy. No exclamation marks. Errors say what happened and what to do.
+- Lucide icons at 1.75 stroke. 18px in navigation, 16px in controls.
+- New logic that can be pure goes in `src/lib/` with a `*.test.js` beside it (`npm test`).
diff --git a/docs/architecture/frontend/FEATURES.md b/docs/architecture/frontend/FEATURES.md
index a367d71..c17acea 100644
--- a/docs/architecture/frontend/FEATURES.md
+++ b/docs/architecture/frontend/FEATURES.md
@@ -5,8 +5,9 @@
```
frontend/src/
├── components/
-│ ├── MainCard.jsx <- Card wrapper with optional title/subheader/separator
+│ ├── SurfaceBox.jsx, MetricBox.jsx, PageHeader.jsx, ... <- Shared components, see DESIGN_SYSTEM.md
│ ├── MetricAreaChart.jsx <- Shared Recharts area chart for single-metric comparisons
+│ ├── ChartPanel.jsx <- Titled chart container with an empty state
│ └── ImageLightbox.jsx <- Thumbnail that opens the full image in a Dialog
├── features/
│ ├── analytics/
@@ -19,7 +20,9 @@ frontend/src/
│ │ ├── reddit/
│ │ │ ├── RedditAnalytics.jsx <- Reddit account analytics (karma, subreddits)
│ │ │ ├── RedditPosts.jsx <- Per-account post explorer
-│ │ │ └── RedditPostsAll.jsx <- Global post explorer (all Reddit accounts)
+│ │ │ ├── RedditPostsAll.jsx <- Global post explorer (all Reddit accounts)
+│ │ │ ├── redditPostTable.jsx <- Filters and table shared by both post explorers
+│ │ │ └── redditPostUtils.js <- Shared sort options, filtering and sorting
│ │ └── tracked/
│ │ ├── TrackedContent.jsx <- Tracked Reddit posts and YouTube videos
│ │ └── TrackedCategory.jsx <- Per-category analytics for tracked content
@@ -29,10 +32,11 @@ frontend/src/
│ │ └── UploadContent.jsx <- Instagram publish + scheduled post queue
│ ├── settings/
│ │ └── Settings.jsx <- GitHub PAT and other settings
-│ └── videos/
-│ ├── VideoExplorer.jsx <- YouTube video library with filtering
-│ ├── ShortsExplorer.jsx <- YouTube Shorts-filtered view
-│ └── ReelsExplorer.jsx <- Instagram Reels-filtered view
+│ ├── analytics/videos/
+│ │ ├── VideoExplorer.jsx <- YouTube video library with filtering
+│ │ └── useChannelVideos.js <- Loads every channel's videos; shared with Shorts
+│ ├── analytics/shorts/ShortsExplorer.jsx <- YouTube Shorts (60 seconds or less)
+│ └── analytics/reels/ReelsExplorer.jsx <- Instagram reels, posts and videos
```
## Metric Naming
@@ -55,7 +59,7 @@ grid, gradient, and tooltip styling. Use it instead of hand-rolling a Recharts `
data={[{ name: 'Item', karma: 42 }]}
dataKey="karma"
label="Karma"
- color="#f97316"
+ color={SERIES.warm} // from @/lib/chart
emptyMessage="Track content to compare karma"
/>
```
diff --git a/docs/architecture/frontend/REACT_ARCHITECTURE.md b/docs/architecture/frontend/REACT_ARCHITECTURE.md
index 9f4123a..70264bf 100644
--- a/docs/architecture/frontend/REACT_ARCHITECTURE.md
+++ b/docs/architecture/frontend/REACT_ARCHITECTURE.md
@@ -13,6 +13,10 @@
| Theming | next-themes | - |
| Toasts | Sonner | - |
| Icons | Lucide React | - |
+| Command palette | cmdk | - |
+| Fonts | Sora, Manrope, JetBrains Mono (self-hosted from `public/fonts`) | - |
+
+Visual tokens and shared components are described in `DESIGN_SYSTEM.md`.
## Entry: `frontend/src/main.jsx`
@@ -40,8 +44,11 @@ ThemeProvider (next-themes) <- OS/user theme preference
/* ->
ProtectedRoute <- redirects to /login if no session
AppProvider <- accounts[], loading, showToast
- MainLayout <- sidebar + header + <Outlet />
+ AppShell (layout/index.jsx)
+ AppSidebar <- navigation, accounts, categories, user menu
+ TopBar <- breadcrumb, refresh, theme
(lazy page)
+ CommandPalette <- Ctrl+K / Cmd+K
Toaster (Sonner, bottom-right) <- toast notifications
```
@@ -57,6 +64,12 @@ frontend/src/
lib/
supabase.js Supabase anon client (singleton)
utils.js cn() = clsx + tailwind-merge
+ accounts.js Platform helpers: paths, names, handles, platform summary
+ chart.js Recharts axis, grid, tooltip and series styling
+ library.js Filter tiers, paging, duration and engagement helpers
+ commandSearch.js Command palette ranking
+ holdProgress.js Hold-to-confirm timing
+ *.test.js Unit tests (npm test, Node test runner)
services/
api.js All backend HTTP calls
context/
@@ -66,14 +79,17 @@ frontend/src/
formatters.js fmtNum, fmtDate, fmtDuration, normalizeAccount, etc.
hooks/
use-mobile.js useIsMobile()
+ use-command-palette-shortcut.js Ctrl+K / Cmd+K toggle
layout/
- index.jsx MainLayout: SidebarProvider + AppSidebar + Header + Outlet
- Sidebar.jsx Collapsible sidebar with per-account nav links
- Header.jsx Breadcrumb, refresh, theme toggle, sign-out
+ index.jsx AppShell: SidebarProvider + AppSidebar + TopBar + Outlet + CommandPalette
+ navigation.js NAV_GROUPS and route titles (single source for sidebar, top bar, palette)
+ Sidebar.jsx Collapsible sidebar: logo, search, nav groups, accounts, categories, user menu
+ Header.jsx TopBar: breadcrumb, refresh all, theme toggle
components/
ProtectedRoute.jsx Auth guard component
- MainCard.jsx Standard page wrapper card
- ui/ shadcn generated components (40+)
+ PageHeader.jsx, SurfaceBox.jsx, MetricBox.jsx, ... Shared components (see DESIGN_SYSTEM.md)
+ brand/ Logo and platform icons
+ ui/ shadcn generated components, restyled onto the tokens
pages/
Login.jsx Auth page (not lazy-loaded, always small)
features/
@@ -84,6 +100,8 @@ frontend/src/
videos/ VideoExplorer.jsx - all videos table
shorts/ ShortsExplorer.jsx - shorts-filtered table
reels/ ReelsExplorer.jsx - Instagram media grid
+ reddit/ RedditAnalytics, RedditPosts, RedditPostsAll, shared post table
+ tracked/ TrackedContent.jsx, TrackedCategory.jsx
publishing/
UploadContent.jsx Instagram publishing + schedule queue
accounts/
diff --git a/docs/architecture/frontend/ROUTING.md b/docs/architecture/frontend/ROUTING.md
index 3a0597f..0640924 100644
--- a/docs/architecture/frontend/ROUTING.md
+++ b/docs/architecture/frontend/ROUTING.md
@@ -11,7 +11,7 @@ The app uses React Router v6 in `frontend/src/App.jsx`. The router uses `Browser
| `/login` | `Login.jsx` | Public - redirects to `/` if already authenticated |
| `/` (layout) | `AppLayout` (inline) | Protected - redirects to `/login` if unauthenticated |
| `/` (index) | `Overview.jsx` | Default page after login |
-| `/accounts` | `Accounts.jsx` | Connect/disconnect accounts |
+| `/accounts` | `AccountManager.jsx` | Connect and remove accounts. `?add=1` opens the add flow; `?ig_connected` and `?ig_error` report the Instagram OAuth result |
| `/channel/:id` | `ChannelAnalytics.jsx` | `:id` = account.id for YouTube accounts |
| `/instagram/:id` | `InstagramAnalytics.jsx` | `:id` = account.id for Instagram accounts |
| `/reddit/:id` | `RedditAnalytics.jsx` | `:id` = account.id for Reddit accounts |
@@ -20,9 +20,10 @@ The app uses React Router v6 in `frontend/src/App.jsx`. The router uses `Browser
| `/tracked-content` | `TrackedContent.jsx` | Tracked Reddit posts and YouTube videos - add, manage, categorize, refresh |
| `/tracked-content/category/:name` | `TrackedCategory.jsx` | Per-category analytics page; `:name` is URL-encoded category label; shows YouTube and Reddit sections separately |
| `/reddit-tracked` | redirect | Redirects to `/tracked-content` |
-| `/videos/:id` | `VideoExplorer.jsx` | `:id` = account.id for YouTube accounts |
-| `/publish/:id` | `Publish.jsx` | `:id` = account.id for Instagram accounts |
-| `/schedule/:id` | `Schedule.jsx` | `:id` = account.id for Instagram accounts |
+| `/videos` | `VideoExplorer.jsx` | Every video from every YouTube channel |
+| `/shorts` | `ShortsExplorer.jsx` | Videos of 60 seconds or less |
+| `/reels` | `ReelsExplorer.jsx` | Instagram reels, posts and videos |
+| `/upload` | `UploadContent.jsx` | Publish and schedule to Instagram, plus the scheduled post queue |
| `/settings` | `Settings.jsx` | User/platform settings |
## Auth Guard
@@ -53,7 +54,7 @@ All lazy components are wrapped in `<Suspense>` with a shared fallback.
{ path: 'my-page/:id', element: <MyPage /> }
```
-3. If the page appears in the sidebar, add it to `Sidebar.jsx`.
+3. If the page appears in the sidebar, add it to `NAV_GROUPS` in `layout/navigation.js`. The sidebar, top bar title and command palette all read from it. Detail routes get a title in `DETAIL_ROUTES` in the same file.
4. Update the Route Table in this file.
@@ -70,13 +71,12 @@ If `account` is undefined (invalid ID or account deleted), the page renders an e
## Navigation
-Navigation between routes uses React Router's `<Link>` component or the `useNavigate` hook. The `Sidebar.jsx` generates links dynamically from the accounts list in `AppContext`:
+Navigation between routes uses React Router's `<Link>` component or the `useNavigate` hook. Sidebar items render as real links. Per-account links come from `accountPath(account)` in `lib/accounts.js`:
```jsx
-// Per-account links generated at render time
-accounts
- .filter(a => a.platform === 'youtube')
- .map(a => ({ title: a.title, url: `/channel/${a.id}` }))
+accounts.map(account => ({ title: accountName(account), url: accountPath(account) }))
```
+The command palette (Ctrl+K or Cmd+K) searches pages, accounts, tracked categories and actions.
+
This means the sidebar updates automatically when accounts are added or removed.
diff --git a/docs/design-reference.md b/docs/design-reference.md
new file mode 100644
index 0000000..c3dcdc0
--- /dev/null
+++ b/docs/design-reference.md
@@ -0,0 +1,263 @@
+# Design Reference
+
+This file records where every visual decision in the Twiligent interface comes from. Structure (layout, proportions, density, component shapes, states, motion) follows a measured reference interface. Skin (colour, typography, logo, accents, copy voice) comes from the Twiligent brand kit in `frontend/public/`.
+
+Every token in `frontend/src/index.css` traces to a row in this file.
+
+---
+
+## 1. How the reference was measured
+
+- Source: the ElevenLabs web app, pages Home, Voice Library, Create Voice and Text to Speech, inspected on 2026-10-13 through Chrome DevTools (computed styles read with `getComputedStyle`, positions with `elementFromPoint`).
+- Viewport: 1442 x 788 CSS px at device pixel ratio 1.25, dark theme. Only the dark theme was available in the signed-in session; light values are derived from the brand kit (section 3).
+- Hairlines report as `0.8px` because a 1 CSS px border snaps to one device pixel at 1.25 DPR. They are implemented as `1px`.
+- Reference screenshots were captured to `docs/screenshots/reference/` for side-by-side checks. That folder is git-ignored: it contains third-party branding and is never shipped or redistributed.
+- No ElevenLabs logos, illustrations, names, copy or assets are used in the product.
+
+## 2. Measured reference values
+
+### Application shell
+
+| Element | Measured value | Twiligent token or class |
+|---|---|---|
+| Page ground (dark) | `#0F0F10` | Brand `dusk` `#140E10` used instead (skin) |
+| Sidebar width | 256px including a 1px right hairline | `--sidebar-w: 16rem` |
+| Sidebar ground | `#171717`, one step lighter than the page | `--surface-sidebar` dark `#1A1214` (brand-tinted lift) |
+| Sidebar edge | 1px, foreground at 7.5% | `--line` (ink at 8%) |
+| Top bar height | 50px, bottom hairline at 7.5% | `--topbar-h: 3.125rem` |
+| Top bar title | 14px / 20px, weight 500 | `text-small font-medium` breadcrumb |
+| Content gutter from sidebar | 20px | `sm:px-5` on the content column |
+| Content top padding | 23px below the top bar | `py-6` |
+
+### Navigation
+
+| Element | Measured value | Token or class |
+|---|---|---|
+| Row height | 32px | `--nav-row-h: 2rem` |
+| Row inset from sidebar edge | 12px | `SidebarContent px-1` plus group padding |
+| Row padding / gap | 0 8px / 8px | `px-2 gap-2` |
+| Row radius | 10px | `--radius-row: 10px` |
+| Label | 14px / 20px, weight 500 | `text-sm font-medium` |
+| Inactive label colour | foreground at 64% | `--ink-muted` |
+| Active label colour | foreground at 98% | `--ink` |
+| Active row fill | foreground at 4.3% | `--surface-selected` (ink at 6%, tuned for the warmer ground) |
+| Icon | 18px | `[&_svg]:size-[18px]`, Lucide at 1.75 stroke (brand) |
+| Group heading | 14px / 20px, weight 500, muted | `SidebarGroupLabel text-sm font-medium text-ink-muted` |
+| Hover transition | 150ms `cubic-bezier(0.4, 0, 0.2, 1)` | `--duration-base`, `--ease-standard` |
+
+### Typography scale
+
+| Role | Measured | Twiligent |
+|---|---|---|
+| Home headline | 28px / 36px, weight 400, -0.21px | `--text-display: 1.75rem / 2.25rem`, Sora 600 (brand display face) |
+| Page title | 24px / 30px, weight 400, -0.15px | `--text-page-title: 1.5rem / 1.875rem`, Sora 600 |
+| Section heading | 16px / 24px, weight 550, -0.2px | `--text-section: 1rem / 1.5rem`, Sora 600 |
+| Body and controls | 14px / 20px | `--text-body: 0.875rem / 1.25rem`, Manrope |
+| Row metadata | 13px / 19.5px, muted | `--text-small: 0.8125rem / 1.21875rem` |
+| Hints | 12px / 16px, muted | `--text-caption: 0.75rem / 1rem` |
+| Editor text | 16px / 24px | `text-base` in the publish caption editor |
+
+### Controls
+
+| Control | Measured value | Token or class |
+|---|---|---|
+| Primary button | 36px tall, 10px radius, 0 12px, 14px weight 500 | `Button` default: `h-(--control-h)` 36px, `rounded-control` 10px |
+| Small button (top bar) | 32px tall, 10px radius, 0 10px, 13px weight 500 | `size="sm"`: `--control-h-sm` 32px |
+| Large control (search, filters, full-width actions) | 40px tall, 12px radius, 0 16px | `size="lg"` and fields: `--control-h-lg` 40px, `--radius-field` 12px |
+| Secondary button border | 1px, foreground at 10% | `--line-control` (ink at 12%) |
+| Search field | 40px, 12px radius, 1px border, 14px text, focus border full foreground | `SearchField` |
+| Filter chip | 40px, 12px radius, 1px border at 10%, 0 12px, 14px weight 500 | `FilterChips` (36px for denser filter rows) |
+| Inline suggestion chip | 32px, 8px radius, 13px weight 500 | `size="sm"` outline buttons |
+| Control transition | 75ms `cubic-bezier(0.4, 0, 0.2, 1)`, colour only | `--duration-fast: 75ms` |
+
+### Tabs
+
+| Element | Measured value | Token or class |
+|---|---|---|
+| Style | Underline tabs on a row with a 1px hairline | `TabsList` default variant |
+| Tab height | 42px, padding 4px 0 10px | `h-[2.625rem]` |
+| Label | 14px weight 500, inactive at 64% | `text-sm font-medium text-ink-muted` |
+| Active indicator | 1px underline, foreground at 80% | 2px underline in `--brand` (brand accent marks the active state) |
+| Gap between tabs | 6px to 14px | `gap-4` |
+
+### Surfaces and cards
+
+| Element | Measured value | Token or class |
+|---|---|---|
+| Creation choice card | foreground wash at 4.3%, no border, 24px radius, 20px padding | `ChoiceCard`: `bg-surface-wash rounded-panel p-5` |
+| Choice card title / body | 16px weight 500 / 14px muted | `text-base font-medium` / `text-sm text-ink-muted` |
+| Choice grid gap | 20px rows, 12px columns | `gap-x-3 gap-y-5` |
+| Feature and media card | 16px radius | `--radius-card: 16px` |
+| Banner panel | 24px radius, 1px ring at 10% | `--radius-panel: 24px` |
+| List row title / meta | 14px weight 600 / 13px muted | `ListRow` |
+| Avatar in list rows | 32px circle | `AccountAvatar` default |
+
+### Working surface (text-to-speech pattern)
+
+| Element | Measured value | Twiligent |
+|---|---|---|
+| Settings panel | 460px wide, right side, separated by a hairline | `DetailPanel` in the Publish page, `lg:w-[28rem]` |
+| Panel tabs | underline tabs, 42px | `TabsList` default |
+| Field label | 14px weight 500 | `FieldRow` label |
+| Field control | 40px, 10px radius, 1px border at 10% | `--control-h-lg` |
+| Field hint | 12px / 16px muted | `FieldRow` hint |
+
+### Dialogs and overlays
+
+| Element | Measured value | Token or class |
+|---|---|---|
+| Dialog radius | 24px | `--radius-dialog: 24px` |
+| Dialog padding | 32px | `p-8` |
+| Dialog title | 24px / 30px weight 500 | `text-lg` Sora 600 (denser dialogs in this product) |
+| Full-width dialog action | 40px, 12px radius | `size="lg"` |
+| Scrim | neutral at 30%, no blur | `bg-[#0C0809]/40` (dusk-tinted) |
+| Open and close | 200ms | `--duration-overlay: 200ms` |
+
+## 3. Brand kit inventory
+
+Source folder: `frontend/public/`.
+
+### Logos (`Logos/`)
+
+| File | Use |
+|---|---|
+| `twiligent-lockup-horizontal.svg` | Primary lockup, colour mark plus dusk wordmark. Light theme sidebar. |
+| `twiligent-lockup-horizontal-reversed.svg` | Colour mark plus white wordmark. Dark theme sidebar. |
+| `twiligent-lockup-horizontal-dusk.svg`, `-white.svg` | Single-ink versions. Not used in the app. |
+| `twiligent-lockup-stacked.svg`, `-stacked-reversed.svg` | Square spaces. Used on the sign-in page. |
+| `twiligent-mark-color.svg` | The ribbon alone. Collapsed sidebar. |
+| `twiligent-mark-red.svg`, `-dusk.svg`, `-white.svg` | Single-colour marks for sizes under 24px. |
+| `twiligent-wordmark-*.svg` | Name alone. Not used. |
+| `twiligent-mark-original.png` | 1921 x 1663 master artwork. Not used at runtime. |
+
+All lockups are 4090 x 1000 (4.09:1). At the brand minimum of 24px tall the lockup is 98px wide.
+
+### App icons (`App icons/`)
+
+| File | Use |
+|---|---|
+| `twiligent-favicon.svg`, `twiligent-favicon-32.png` | Browser tab icon (red mark on dusk) |
+| `twiligent-app-icon-dusk-180.png` | Apple touch icon |
+| `twiligent-app-icon-dusk/paper/red` at 32, 180, 512 and SVG | Available for future install manifests |
+
+### Fonts (`fonts/`, SIL OFL 1.1, self-hosted)
+
+| Family | Weights included | Role |
+|---|---|---|
+| Sora | 600, 700 | Display: page titles, section headings, metric values |
+| Manrope | 400, 500, 600, 700 | Everything people read |
+| JetBrains Mono | 400, 500 | Ranks, IDs, keyboard hints |
+
+Manrope 400, 500, 600 and Sora 600 are preloaded in `index.html` and declared with `font-display: swap`.
+
+### Guidelines applied (`brand-guidelines.md`)
+
+- Sentence case for headings, buttons and menus. No exclamation marks in product UI.
+- Red as text is `brand-text`, never the raw brand red on dusk.
+- Errors share the brand red, so every error carries an icon and a word.
+- Lucide icons at 1.75px stroke, taking the colour of adjacent text.
+- `fold-gradient` only for brand bands, never behind paragraphs. Used once, on the sign-in panel.
+- Keyboard focus: 2px solid ring, 2px offset, in `focus-ring`.
+
+## 4. Structure versus skin decisions
+
+| Area | Reference says | Brand says | Decision |
+|---|---|---|---|
+| Button shape | 10 to 12px rounded rectangles | Capsules for buttons and badges | Buttons, inputs and chips follow the measured radii (structure). Badges and status tags keep the brand capsule as the ribbon echo. |
+| Primary action fill | Inverse (white on dark) | Twiligent red | Brand red (`--brand`), the signature accent. |
+| Active tab | Foreground underline | Accent marks selection | 2px brand underline. |
+| Page ground | `#0F0F10` neutral | Dusk `#140E10` warm | Dusk, with neutrals tinted toward brand ink. |
+| Display face | Proprietary display serif-sans | Sora SemiBold | Sora 600 at the measured sizes. |
+| Hover timing | 75ms controls, 150ms navigation | 150ms colour changes | Measured values (motion is structure). The 220ms fold entrance stays as the brand moment. |
+| Nav icon size | 18px | 20px | 18px to match the 32px row; 1.75 stroke from the brand. |
+
+## 5. Token table
+
+Each colour pair that carries text was checked for WCAG AA (4.5:1 for text, 3:1 for UI boundaries and chart marks). Ratios were computed with the WCAG relative luminance formula.
+
+### Colour
+
+| Token | Light | Dark | Source | Check |
+|---|---|---|---|---|
+| `--surface` | `#F7F3EF` | `#140E10` | Brand `surface` | |
+| `--surface-raised` | `#FFFFFF` | `#1F1719` | Brand `surface-raised` | |
+| `--surface-sunken` | `#EFE8E3` | `#0C0809` | Brand `surface-sunken` | |
+| `--surface-sidebar` | `#F3EEE9` | `#1A1214` | Derived: midpoint between sunken and surface (light), lifted toward raised (dark) as measured | ink 16.6:1 / 16.2:1, muted 6.4:1 / 8.3:1 |
+| `--surface-hover` | ink 4% | ink 4% | Measured wash | |
+| `--surface-selected` | ink 6% | ink 6% | Measured active row (4.3%), lifted for the warm ground | on sidebar: ink 14.7:1 / 14.1:1, muted 5.7:1 / 7.3:1 |
+| `--surface-wash` | ink 4.3% | ink 4.3% | Measured choice card fill | |
+| `--line` | ink 8% over surface | ink 8% over surface | Measured hairline (7.5%) | decorative |
+| `--line-control` | ink 12% over surface | ink 12% over surface | Measured control border (10%) | decorative, paired with fill |
+| `--line-strong` | `#8C7E83` | `#86777C` | Brand `line-strong`, text input borders | 3.5:1 / 4.5:1 on surface |
+| `--ink` | `#140E10` | `#F5EFEB` | Brand `ink` | 17.3:1 / 16.8:1 on surface |
+| `--ink-muted` | `#5F5357` | `#B8ABAF` | Brand `ink-muted` | 6.7:1 / 8.6:1 on surface |
+| `--ink-faint` | `#6A6565` | `#97918F` | Derived: ink mixed into surface at 62% / 58% | 5.2:1 / 6.2:1 on surface, 5.0:1 / 5.9:1 on sidebar |
+| `--ink-inverse` | `#FFFFFF` | `#140E10` | Brand `ink-inverse` | 19.1:1 / 16.8:1 on ink |
+| `--brand` | `#C11F2F` | `#C11F2F` | Brand `accent` | white on it 6.0:1 |
+| `--brand-hover` | `#9A1423` | `#D93444` | Brand `accent-hover` | white on it 8.4:1 / 4.6:1 |
+| `--brand-soft` | `#FBE7E8` | `#3A1419` | Brand `accent-soft` | |
+| `--brand-text` | `#B01C2B` | `#FF7A82` | Brand `accent-text` | 6.2:1 / 7.6:1 on surface, 5.8:1 / 6.5:1 on brand-soft |
+| `--success` / `-soft` | `#1E7349` / `#E2F3E9` | `#5FCB95` / `#12301F` | Brand | 5.1:1 / 7.1:1 text on soft |
+| `--warning` / `-soft` | `#7F4C00` / `#FCEFD9` | `#F2B65E` / `#3A2A12` | Brand `afterglow-text` / `afterglow-soft` | 6.3:1 / 7.7:1 |
+| `--danger` / `-soft` | `#B01C2B` / `#FBE7E8` | `#FF7A82` / `#3A1419` | Brand `danger` (shares accent-text) | 5.8:1 / 6.5:1 |
+| `--info` / `-soft` | `#2C5A99` / `#E5EDF8` | `#8DB3EC` / `#16243A` | Brand | 5.9:1 / 7.3:1 |
+| `--focus-ring` | `#C11F2F` | `#FF7A82` | Brand `focus-ring` | 5.4:1 / 7.6:1 on surface |
+
+### Data visualisation
+
+Series order follows the brand rule: red, ink-muted, afterglow, info, oxblood.
+
+| Token | Light | Dark | Source | Contrast on surface |
+|---|---|---|---|---|
+| `--chart-1` | `#C11F2F` | `#D93444` | Brand red; dark uses brand `accent-hover` | 5.4:1 / 4.1:1 |
+| `--chart-2` | `#5F5357` | `#B8ABAF` | Brand `ink-muted` | 6.7:1 / 8.6:1 |
+| `--chart-3` | `#B5761A` | `#E8A33D` | Brand `afterglow`; light derived darker because `#E8A33D` is 2.0:1 on paper | 3.4:1 / 8.9:1 |
+| `--chart-4` | `#2C5A99` | `#8DB3EC` | Brand `info` | 6.3:1 / 8.9:1 |
+| `--chart-5` | `#5E0B14` | `#B4626E` | Brand `oxblood`; dark derived lighter because oxblood is 1.4:1 on dusk | 12.4:1 / 4.5:1 |
+
+Platforms map to series: YouTube `chart-1`, Instagram `chart-3`, Reddit `chart-4`, categories `chart-2`. Platform is always also named in a label or legend, never shown by colour alone.
+
+### Type, space, shape, elevation, motion
+
+| Token | Value | Source |
+|---|---|---|
+| `--font-heading`, `--font-display` | Sora | Brand |
+| `--font-sans` | Manrope | Brand |
+| `--font-mono` | JetBrains Mono | Brand |
+| `--text-display` | 28px / 36px, -0.02em | Measured size, brand tracking |
+| `--text-page-title` | 24px / 30px, -0.015em | Measured |
+| `--text-section` | 16px / 24px, -0.01em | Measured |
+| `--text-body` | 14px / 20px | Measured |
+| `--text-small` | 13px / 19.5px | Measured |
+| `--text-caption` | 12px / 16px | Measured |
+| Spacing | 4px base (Tailwind scale) | Brand `space-*` |
+| `--radius-row` | 10px | Measured |
+| `--radius-control` | 10px | Measured |
+| `--radius-field` | 12px | Measured |
+| `--radius-card` | 16px | Measured, matches brand `radius-lg` |
+| `--radius-panel`, `--radius-dialog` | 24px | Measured, matches brand `radius-xl` |
+| `--radius-pill` | 999px | Brand capsule (badges) |
+| `--control-h-sm` / `--control-h` / `--control-h-lg` | 32 / 36 / 40px | Measured |
+| `--nav-row-h` | 32px | Measured |
+| `--topbar-h` | 50px | Measured |
+| `--sidebar-w` | 256px | Measured |
+| `--shadow-sm/md/lg` | Brand values | Brand (borders before shadows) |
+| `--duration-fast` | 75ms | Measured control transitions |
+| `--duration-base` | 150ms | Measured navigation transitions |
+| `--duration-overlay` | 200ms | Measured dialog transition |
+| `--duration-fold` | 220ms | Brand fold entrance |
+| `--ease-standard` | `cubic-bezier(0.4, 0, 0.2, 1)` | Measured |
+| `--ease-fold` | `cubic-bezier(0.2, 0.8, 0.2, 1)` | Brand |
+
+## 6. Differences from the October 2026 baseline
+
+| Baseline | Measured | Note |
+|---|---|---|
+| Ground around `#0F0F10` | `#0F0F10` | Confirmed |
+| Hairlines about 0.8px at 7.5 to 10% | 1px CSS (0.8px at 1.25 DPR), 7.5% structural, 10% on controls | Confirmed; the 0.8px is a DPR artefact |
+| Sidebar about 255px | 255.2px plus 0.8px edge | Confirmed |
+| 32px navigation rows, 8px radius | 32px rows; the active wash is 10px, the inner element 8px | Radius is 10px for the visible fill |
+| Controls 36 to 40px, 10 to 12px radius | 32, 36 and 40px; 10px buttons, 12px fields and chips | Adds a 32px tier for top-bar and inline actions |
+| Underline tabs | Underline tabs; the active tab also carries a faint bordered pill | The pill is not reproduced; underline only |
+| Large choice cards | 24px radius, borderless wash, 20px padding | Confirmed |
+| Sidebar ground | Not in baseline | Sidebar is lighter than the page (`#171717` vs `#0F0F10`) |
diff --git a/docs/features/NEW_INTEGRATION.md b/docs/features/NEW_INTEGRATION.md
index f1dd8af..feb5012 100644
--- a/docs/features/NEW_INTEGRATION.md
+++ b/docs/features/NEW_INTEGRATION.md
@@ -27,7 +27,7 @@ Document the answers in `DECISIONS.md` as a new ADR before writing any code.
| Frontend | `frontend/src/services/api.js` | Add methods |
| Frontend | `frontend/src/features/` | Create page(s) |
| Frontend | `frontend/src/App.jsx` | Add routes |
-| Frontend | `frontend/src/layout/Sidebar.jsx` | Add nav links |
+| Frontend | `frontend/src/lib/accounts.js`, `frontend/src/components/brand/platform-icons.jsx` | Add the platform to `PLATFORM_META`, `platformOf()`, `accountPath()` and an icon; the sidebar lists accounts automatically |
| Frontend | `frontend/src/context/AppContext.jsx` | Add normalization |
| Config | `.github/workflows/deploy-backend.yml` | Add new secret |
| Docs | `DECISIONS.md` | Add ADR |
diff --git a/docs/features/NEW_REACT_PAGE.md b/docs/features/NEW_REACT_PAGE.md
index c030504..3c41fcb 100644
--- a/docs/features/NEW_REACT_PAGE.md
+++ b/docs/features/NEW_REACT_PAGE.md
@@ -8,7 +8,7 @@ Read `frontend/src/features/analytics/channel/ChannelAnalytics.jsx` as a referen
|---|---|
| Create | `frontend/src/features/myFeature/MyPage.jsx` |
| Modify | `frontend/src/App.jsx` (add lazy import + route) |
-| Modify | `frontend/src/layout/Sidebar.jsx` (add nav link if needed) |
+| Modify | `frontend/src/layout/navigation.js` (add a nav item if the page belongs in the sidebar) |
| Modify | `frontend/src/services/api.js` (add API methods) |
| Update | `docs/architecture/frontend/REACT_ARCHITECTURE.md` |
@@ -47,30 +47,22 @@ export default function MyPage() {
loadData();
}, [loadData]);
- if (loading) {
- return (
- <div className="p-6 space-y-4">
- <Skeleton className="h-8 w-48" />
- <Skeleton className="h-48 w-full" />
- </div>
- );
- }
+ if (loading) return <PageSkeleton />;
if (!account) {
- return <div className="p-6 text-muted-foreground">Account not found.</div>;
+ return (
+ <SurfaceBox>
+ <EmptyState icon={<UserX />} title="Account not found" description="It may have been removed. Choose another account from the sidebar." />
+ </SurfaceBox>
+ );
}
return (
- <div className="p-6 space-y-6">
- <h1 className="text-2xl font-bold">{account.title}</h1>
- <Card>
- <CardHeader>
- <CardTitle>My Data</CardTitle>
- </CardHeader>
- <CardContent>
- {/* content */}
- </CardContent>
- </Card>
+ <div className="flex flex-col gap-6">
+ <PageHeader back={{ to: '/', label: 'Overview' }} title={account.title} />
+ <SurfaceBox title="My data">
+ {/* content */}
+ </SurfaceBox>
</div>
);
}
@@ -86,19 +78,16 @@ const MyPage = lazy(() => import('./features/myFeature/MyPage'));
{ path: 'my-page/:id', element: <MyPage /> },
```
-## Step 3: Add Navigation in Sidebar.jsx
+## Step 3: Add Navigation
-If the page appears in the sidebar (e.g., once per account):
+If the page belongs in the sidebar, add it to `NAV_GROUPS` in `frontend/src/layout/navigation.js`. The sidebar, top bar title and command palette pick it up automatically:
-```jsx
-// In Sidebar.jsx, inside the per-account link generation
-{
- title: 'My Feature',
- url: `/my-page/${account.id}`,
- icon: IconName,
-}
+```js
+{ path: '/my-page', label: 'My page', icon: IconName },
```
+Detail pages that are not in the sidebar get a top bar title in `DETAIL_ROUTES` in the same file.
+
## Step 4: Add API Methods
```js
@@ -110,10 +99,11 @@ getMyData: (id) => request(`/accounts/${id}/my-data`),
- Use `useAppContext()` - don't re-fetch the accounts list, use what's in context
- Always handle loading and error states
-- Use `Skeleton` components for loading state (not spinners - shadcn's Skeleton matches the page layout)
+- Use `PageSkeleton` or `Skeleton` for loading states, `EmptyState` for no data, and a toast for failures
- Use semantic HTML for the page structure
-- Wrap content in `className="p-6"` padding (matches existing pages)
-- Use `space-y-6` or `space-y-4` for vertical rhythm between sections
+- Start the page with `PageHeader`; the app shell already provides the page padding
+- Use `flex flex-col gap-6` for vertical rhythm between sections
+- Follow the page patterns in `docs/architecture/frontend/DESIGN_SYSTEM.md`
## Page That Doesn't Need an Account Parameter
@@ -129,8 +119,9 @@ export default function MyAggregatePage() {
}, [accounts]);
return (
- <div className="p-6">
- <p>Total views: {summary}</p>
+ <div className="flex flex-col gap-6">
+ <PageHeader title="My summary" />
+ <MetricBox label="Total views" value={fmtNum(summary)} />
</div>
);
}
diff --git a/docs/guidelines/SHADCN.md b/docs/guidelines/SHADCN.md
index 49ffefa..045816e 100644
--- a/docs/guidelines/SHADCN.md
+++ b/docs/guidelines/SHADCN.md
@@ -84,21 +84,26 @@ import { cn } from '@/lib/utils';
<div className={cn('base-class', isActive && 'active-class', className)}>
```
-## StatCard Component
+## Shared components
-A custom component at `frontend/src/components/ui/StatCard.jsx` is a KPI tile used across all analytics pages. Use it for metric display:
+Project components in `frontend/src/components/` sit on top of the shadcn primitives. Use them before composing primitives by hand. `MetricBox` is the KPI tile used across analytics pages:
```jsx
-import StatCard from '@/components/ui/StatCard';
+import MetricBox from '@/components/MetricBox';
-<StatCard
- title="Total Views"
+<MetricBox
+ icon={<Eye />}
+ label="Total views"
value={fmtNum(analytics.totalViews)}
- icon={Eye}
- description="Lifetime channel views"
+ subtitle="Lifetime channel views"
+ highlight
/>
```
+The full list (`PageHeader`, `SurfaceBox`, `ConfirmDialog`, `FilterChips`, and others) is in `docs/architecture/frontend/DESIGN_SYSTEM.md`.
+
+The shadcn primitives in `components/ui/` are restyled onto the design tokens. Keep that styling when regenerating a primitive with the shadcn CLI: diff the new file against the current one before overwriting.
+
## Theme
The project uses `next-themes` with `attribute="class"`. Dark mode is applied by adding the `dark` class to `<html>`. All shadcn components respond to this automatically via CSS variables defined in `frontend/src/index.css`.
diff --git a/docs/guidelines/TAILWIND.md b/docs/guidelines/TAILWIND.md
index 0cbfaef..4d78014 100644
--- a/docs/guidelines/TAILWIND.md
+++ b/docs/guidelines/TAILWIND.md
@@ -10,23 +10,28 @@ This project uses **Tailwind CSS v4**. The v4 API is substantially different fro
## Token References
-Design tokens are defined in the CSS file (check `frontend/src/index.css` or `frontend/src/app.css` for the `@theme` block). Use these tokens via their utility class names - never use hardcoded hex values in class names.
+Design tokens are defined in `frontend/src/index.css` and listed in `docs/architecture/frontend/DESIGN_SYSTEM.md`. Use them through their utility class names. Never use hex values or Tailwind palette colours (`bg-red-500`, `text-pink-600`) in components.
Common token utilities:
-- `bg-background` / `text-foreground` - page background and main text
-- `bg-card` / `text-card-foreground` - card surfaces
-- `bg-muted` / `text-muted-foreground` - subdued backgrounds and secondary text
-- `border-border` - default border color
-- `bg-primary` / `text-primary-foreground` - primary action color
-- `bg-destructive` / `text-destructive-foreground` - error/delete actions
+- `bg-surface` / `text-ink` - page background and main text
+- `bg-surface-raised` - cards and panels
+- `bg-surface-sunken` / `text-ink-muted` / `text-ink-faint` - wells and secondary text
+- `border-line` - hairline borders; `border-line-control` - control borders
+- `bg-brand` / `text-on-brand` - primary action; `text-brand-text` - red as text
+- `bg-danger-soft` / `text-danger`, plus `success`, `warning`, `info` - status
+
+The shadcn names (`bg-background`, `text-muted-foreground`, `bg-primary`) still work and map onto the same tokens.
## Layout
### Page wrapper
+The app shell already pads and centres the content column. Pages start with a flex column:
+
```jsx
-<div className="p-6 space-y-6">
- {/* page content */}
+<div className="flex flex-col gap-6">
+ <PageHeader title="Videos" description="..." actions={...} />
+ {/* sections */}
</div>
```
@@ -49,20 +54,22 @@ Common token utilities:
## Spacing System
Use the spacing scale consistently. Common patterns in this project:
-- `p-6` - standard page padding
-- `p-4` - card inner padding
-- `gap-4` - grid column gap
-- `gap-2` - inline icon+label gap
-- `space-y-6` - vertical rhythm between major sections
-- `space-y-4` - vertical rhythm within a card
-- `mb-4` / `mb-6` - heading bottom margin
+- `gap-6` - between page sections (`gap-8` on pages with large sections)
+- `gap-3` - between metric boxes in a grid
+- `gap-4` - between boxes in a grid
+- `px-5 py-4` - inside a `SurfaceBox` (built in)
+- `gap-2` - inline icon and label
+- Prefer `gap-*` on flex and grid over `space-y-*`
## Typography
+Use `PageHeader` for the page title and `SectionHeader` or a `SurfaceBox` title for sections. When writing type directly:
+
```jsx
-<h1 className="text-2xl font-bold">Page Title</h1>
-<h2 className="text-lg font-semibold">Section</h2>
-<p className="text-sm text-muted-foreground">Secondary info</p>
+<h1 className="font-heading text-page-title font-semibold">Page title</h1>
+<h2 className="font-heading text-section font-semibold">Section</h2>
+<p className="text-small text-ink-muted">Secondary info</p>
+<span className="font-mono text-caption tabular-nums">42</span>
```
Avoid using `text-xs` for anything the user needs to read comfortably. Use `text-sm` as the minimum for content.
@@ -76,7 +83,7 @@ Mobile-first. Most pages in this app are designed primarily for desktop (analyti
## Dark Mode
-This project uses shadcn's theme system, which manages light/dark via CSS custom properties - not Tailwind's `dark:` variant. Do not use `dark:` variants. Use token-based colors (`bg-card`, `text-muted-foreground`) which automatically respond to the theme.
+Light and dark values are both defined as tokens, so token utilities switch automatically. Do not use `dark:` variants for colour. The one sanctioned use of `dark:` is swapping the logo file in `components/brand/Logo.jsx`.
If you need to add a custom dark-mode variant for non-token colors, add a CSS custom property to the `@theme` block instead.
diff --git a/docs/workflows/TESTING.md b/docs/workflows/TESTING.md
index c2c0dcb..9391f7b 100644
--- a/docs/workflows/TESTING.md
+++ b/docs/workflows/TESTING.md
@@ -2,12 +2,15 @@
## Current State
-Most testing is manual. The backend has unit tests for pure service logic using Node's built-in test runner (no dependencies). Broader coverage is a known gap - see ROADMAP.md.
+Most testing is manual. Both the backend and the frontend have unit tests for pure logic using Node's built-in test runner (no dependencies). Broader coverage is a known gap - see ROADMAP.md.
```bash
cd backend && npm test
+cd frontend && npm test
```
+Frontend tests cover `src/lib/`: hold-to-confirm timing, command palette ranking, library filtering and paging, platform helpers, and a check that every Lucide icon imported in `src` exists. Keep testable logic in `src/lib/` free of JSX and `@/` imports so Node can load it directly.
+
Test files sit next to the module they cover as `*.test.js` (for example `services/instagram.test.js`). Wrangler only bundles files reachable from `server.js`, so test files never ship in the Worker.
The testing workflow documented here describes what should run before shipping any change.