One admin for the app's content and every blog conversation

Mobile App Dashboard & Blog Comments

Shopify blog comments have no threads. The team replies in threads anyway.

The problem

Shopify blog comments have no parent field, no metafields, and no way to mark a reply as staff.

The Country Life app shows different banners, popups, badges and home carousels to guests, retail shoppers, Rewards and Plus members, and wholesale buyers. Someone has to decide what each of them sees, on a schedule, without a developer — so the app needed an admin of its own, opened from inside Shopify admin rather than behind yet another password. Then the blog grew a conversation, with comments arriving from the website and, soon, from readers in the app. Shopify stores comments, but its comment model is flat: a reply from the team is just another top-level comment, there is nowhere to record what it answers, and the "staff" badge the theme shows is nothing more than an author name match that any visitor can type. The work was to make one place where the team moderates and answers every comment, wherever it was written, without moving the comments out of Shopify.

API routes
23API routes
unit tests
67unit tests
comment tests
31comment tests
dashboard screens
8dashboard screens
audience segments
5audience segments
data models
9data models

How it works

The dashboard is a Next.js app embedded in Shopify admin, with MongoDB behind Prisma for the content it owns. Comments are the deliberate exception: they are never copied into the dashboard's database. Shopify stays the only store of comment data, so the website theme, the app and the moderation screen can never disagree about what was said or whether it is published. The dashboard adds what Shopify lacks around that data — a moderation screen with paging and tabs, a secured submission route for the app, edits limited to verified team replies, and reply threading encoded in data Shopify already keeps. Content targeting works the same way in reverse: the app never decides its own segment. It forwards the shopper's token, and the server resolves membership from live Shopify tags and company contacts, so a customer cannot see wholesale content by editing anything on the device.

Engineering decisions

The non-obvious calls — where the straightforward approach fails, and what it cost to find that out.

01

Threads on a platform that has no threads

Why it breaks

A Shopify comment has an author, an email, a body and a status — and nothing else. There is no parent field and comments cannot carry metafields, so a team reply posted through the API is indistinguishable from an unrelated top-level comment, and the conversation reads out of order.

What I did

Each team reply records the comment it answers in its own email address, using plus-addressing on the team inbox. Mail to that address still reaches the team, and the email is never shown on the site or in the app. When the list is built, replies are nested under their parent — only on the same post, and never under another staff comment — and a parent that falls on the next page is fetched in so the thread is complete. If any of that fails, the list still renders flat.

export function teamEmailFor(parentId, env = process.env) {
  const base = staffEmail(env);
  const id = numericId(parentId);
  const at = base.lastIndexOf("@");
  return id && at > 0 ? `${base.slice(0, at)}+${id}${base.slice(at)}` : base;
}

export function parseReplyTarget(email) {
  const match = /^[^+@\s]+\+(\d{1,20})@/.exec(clean(email));
  return match ? match[1] : null;
}
src/lib/comments-admin.js
02

A staff badge that customers cannot fake

Why it breaks

The theme and the app badge any author whose name contains "Country Life". A plain substring check is trivially dodged — a hyphen, a Cyrillic letter that looks Latin, a zero-width character, or the digit 1 in place of an l — and then a stranger's comment carries the store's voice.

What I did

Names are normalised before comparison: Unicode decomposition, accents and non-letters stripped, look-alike characters mapped, and both readings of "1" tried. Customers are blocked from those names and from the team address, including its plus-tagged variants. The dashboard only treats a comment as staff when the name and the team email both match, and flags any staff-looking name from another address for review.

03

Never trust the caller with the blog or its policy

Why it breaks

Creating a comment needs the blog it belongs to, and whether that blog publishes immediately or holds comments for approval. Taking either from the request lets a client post into a closed blog or claim its comment was published. And a naive edit through the API resets the author, email or publish date, quietly moving or unpublishing the comment.

What I did

The blog and its comment policy always come from a server-side lookup of the article. Closed blogs return 403, and the app is told honestly whether the comment is live or will appear once approved. Edits are limited to verified team replies, re-read from Shopify first, and send the author, email and publish date back unchanged.

04

Rotating a secret must not lock staff out

Why it breaks

After the app's client secret is rotated, Shopify keeps signing session tokens with the oldest secret it has not revoked. A dashboard that only knows the new secret rejects every real staff member, with an error that points nowhere near the cause.

What I did

The server accepts a list of current and previous secrets, and when local verification still fails it asks Shopify to validate the token directly before refusing. The rejection message names exactly which setting to fix.

Correctness in production

What keeps it right once nobody is watching it run.

Moderation cannot be triggered from another site

The staff session cookie has to work inside the Shopify admin iframe, so it is SameSite=None. Every moderation request must therefore be JSON and same-site by the browser's own Sec-Fetch-Site header, ids must be safe integers, and an audit log records who did what — without storing comment text or echoing commenter emails into logs.

Least privilege for comments

Comment work runs under a separate Shopify app that holds only content scopes, with its own short-lived token, kept apart from the credentials that manage products and files.

Shoppers never see an error page

If Shopify cannot resolve a customer, the app gets the content meant for everyone instead of a failure. Audience values are normalised against a fixed list of five, customer tokens are cached only as hashes, and responses are marked private and uncacheable.

Honest about what the rate limiter is

App comments are limited per IP and per email, and the code says plainly that serverless instances do not share memory — so the limiter is a speed bump, and the sign-in requirement plus Shopify's own moderation and spam status are the real backstop.

Outcome

Every comment on the CLNF blog — written on the website or in the app — now lands in one queue inside the same dashboard the team already uses to run the app. Replies show up as real threads under the comment they answer, with a Team badge no customer can imitate, and app readers can join the conversation without leaving the app. Content for each kind of shopper is scheduled and targeted by the team directly, with a phone preview to check it before it goes live.

Ready to upgrade your store's infrastructure?

Whether you want this exact architecture deployed to your store, or a completely bespoke solution built from scratch.

I want this exact solution.

Skip the R&D. I can deploy the Mobile App Dashboard & Blog Comments architecture directly to your operations in days, not months.

I need something custom.

Have a unique workflow? Let's build a bespoke app tailored perfectly to your complex business needs.