demo

package
v1.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 4, 2026 License: AGPL-3.0 Imports: 88 Imported by: 0

Documentation

Overview

Package demo loads the sample data from the design ("Acme Newsletter") so the app can be explored, screenshotted and compared with the prototype.

Seeding is split per domain: each domain fills its own seedX function in its own file (seed_<domain>.go). Seeders run in the order of the list in Seed and share IDs through *Seeder, so later seeders can reference users, lists and providers created earlier. Times are relative to now so "2 min ago" in the design reads the same in the demo.

Index

Constants

View Source
const (
	OctoberSubjectA = "October Product Update: three launches"
	OctoberSubjectB = "What shipped in October, and what we're retiring"
)

The October Product Update's subject test, as on the Report board: A is the campaign's subject (and the email's headline), B won.

View Source
const (
	EarnLiveKey = "rk_live_51QAcmeDemoOnlyNotARealStripeKey9fQ2" //nolint:gosec // demo key for the in-process Stripe, documented in the README
	EarnTestKey = "rk_test_51QAcmeDemoOnlyNotARealStripeKey3mZ8" //nolint:gosec // demo key for the in-process Stripe
)

The demo's restricted keys. They aren't Stripe keys: the demo's connections talk to an in-process Stripe (internal/app/wire_earn.go).

View Source
const (
	EntraGroupMarketing = "3f2a9d1e-5b7c-4e21-9a8f-2d4c6e8b0c91"
	EntraGroupEngLeads  = "8b7d44c0-1e2f-4a3b-8c9d-6e7f8a9b002e"
)

Entra ID group object IDs of the sample (A5 §4: "Marketing" 3f2a…c91, "Eng Leads" 8b7d…02e).

View Source
const (
	WhatsAppBusinessID = "102290129344410"
	WhatsAppPhoneID    = "106540352242922"
	WhatsAppToken      = "demo-system-user-token"
	WhatsAppAppSecret  = "demo-app-secret" //nolint:gosec // the demo account's, in the open on purpose
)

The demo's WhatsApp Business Account (…4410) and its credentials, which only the in-process Graph API (internal/whatsapp/meta/metatest) accepts.

View Source
const (
	StoreClientID     = "4f1c8e2b7d03a9e2"
	StoreClientSecret = "shpss_demo1c8e2b7d03a9e2b5f0c4d6e8a1b3c5" //nolint:gosec // the demo's sample app, answered by an in-process fake

)

Demo store credentials: the app's client ID (shown as 4f1c…a9e2) and the sealed secret and token the in-process Shopify accepts.

View Source
const AIDemoKey = "sk-ant-demo-recorded-0000" //nolint:gosec // a placeholder, documented as demo data

AIDemoKey is the sample connection's key: a placeholder, sealed like a real one, that no provider would accept.

View Source
const AIOctoberSummary = "" /* 652-byte string literal not displayed */

AIOctoberSummary is the summary Linh kept on October Product Update.

View Source
const BlogFeedETag = `"demo-blog-feed"`

BlogFeedETag is the version of the feed the demo seeded: a read that sends it back gets 304 Not Modified, so the seeded items stay as they are.

View Source
const BlogFeedURL = "https://blog.acme.io/feed/"

BlogFeedURL is the feed the WordPress plugin reports for blog.acme.io.

View Source
const ComposerFlashSaleBloat = 38

ComposerFlashSaleBloat is the number of pasted spans per plan card; it puts the flash sale at about 98 KB as the composer compiles it (mjml-browser), inside the "approaching Gmail's clipping limit" warning of the ComposerWarnings board. The server's compile (gomjml) is a few KB lighter.

View Source
const NorthwindOwner = "nadia@northwind.studio"

NorthwindOwner signs in to the agency sample as its instance admin.

View Source
const NorthwindStaff = "tomas@northwind.studio"

NorthwindStaff is the agency manager the boards show (QA signs in as him).

View Source
const Password = "reputecast-demo" //nolint:gosec // public demo password, documented in CONTRIBUTING.md

Password is shared by every demo account that signs in with a password.

View Source
const ReadinessDemoShortener = "https://acme.io/blog/november-2026-update?utm_source=newsletter"

ReadinessDemoShortener is where the November update's shortened link leads.

View Source
const SSOGoogleKey = "sso:google"

SSOGoogleKey is the s.Extra key of the Google Workspace SSO provider, so the instance seeder can extend it instead of creating a second one.

View Source
const SendersFooterAddress = "Acme Inc · 500 Market St, Suite 1200 · San Francisco, CA 94105"

SendersFooterAddress is Acme's postal address in email footers.

View Source
const SponsorReportToken = "Qm7vT2pXk9LbN4sW8cYd1A" //nolint:gosec // a public demo link, not a secret

SponsorReportToken is the demo's read-only link to #141's sponsor report (reputecast.acme.io/r/Qm7vT2pXk9LbN4sW8cYd1A).

View Source
const TOTPSecret = "JBSWY3DPEHPK3PXP" //nolint:gosec // public demo secret, documented in CONTRIBUTING.md

TOTPSecret is Linh Nguyen's authenticator secret in the demo, so the two-factor screens can be tried. Generate codes with any TOTP app.

View Source
const TwilioDemoWebhookSecret = "demo-twilio-shared-key-secret-acme-summit" //nolint:gosec // the demo account's, in the open on purpose

TwilioDemoWebhookSecret signs the demo Twilio account's webhooks (the shared key ReputeCast registered).

View Source
const WhatsAppConsentText = "Send me reminders about Acme Summit 2026 on WhatsApp. Up to 3 messages. Reply STOP to stop."

WhatsAppConsentText is the registration form's WhatsApp consent, v1.

Variables

View Source
var DemoRecoveryCodes = []string{
	"b4xk-9q2m-7hdn", "m2pq-x8c4-1zrt", "d9ws-3kfh-6yvb", "p7nj-5tgc-2qxe", "r3hd-8vmb-4wsk",
	"f6cz-2nqd-9jpa", "w8tk-7xsv-3ebr", "h5gm-1dyc-8kqw", "n9rb-6pfx-4tzs", "c3vj-5hwq-2mnd",
}

DemoRecoveryCodes are Linh Nguyen's recovery codes in the demo.

View Source
var MailboxShare = []struct {
	Key   string
	Share float64
}{{"gmail", 0.46}, {"outlook", 0.21}, {"yahoo", 0.09}, {"icloud", 0.08}, {"other", 0.16}}

MailboxShare is the sample split of recipients by mailbox provider.

View Source
var SendersNameservers = []string{"dana.ns.cloudflare.com", "rob.ns.cloudflare.com"}

SendersNameservers are the demo zone's nameservers (Cloudflare).

View Source
var SkipTransactional bool

SkipTransactional leaves the demo's transactional mail out: Acme Cloud's, and the paid tiers' Memberships emails (seed_earn.go). The transactional and SMTP relay tests set it in TestMain: they start from an empty Transactional tab.

Functions

func AccessibilityTitleOverlay

func AccessibilityTitleOverlay(next accessibility.TitleFetcher) accessibility.TitleFetcher

AccessibilityTitleOverlay answers title reads for the demo's links without going to the network: their hosts are real domains the demo has no business calling. Other pages go to next.

func DeliverabilityDNSOverlay

func DeliverabilityDNSOverlay(r dnscheck.Resolver) dnscheck.Resolver

DeliverabilityDNSOverlay answers the demo names from DeliverabilityDNSZone and everything else from r.

func DeliverabilityDNSZone

func DeliverabilityDNSZone() (*dnscheck.Zone, []string)

DeliverabilityDNSZone answers the demo's DNS: the acme.io names, the provider names they point to, and every built-in blocklist lookup of the demo assets (not listed).

func DigestFeedOverlay

func DigestFeedOverlay(next http.RoundTripper) http.RoundTripper

DigestFeedOverlay answers the sample blog's feed, pages and images offline; everything else goes to next. A conditional read of the feed the demo seeded gets 304, so the seeded items keep their dates.

func FormsDNSOverlay

func FormsDNSOverlay(r dnscheck.Resolver, urls publicurl.Builder) dnscheck.Resolver

FormsDNSOverlay answers the demo's custom domain for the public pages (news.acme.io) with a CNAME to this instance, so its DNS check passes in development like the board's "Published · news.acme.io/subscribe".

func ID

func ID() uuid.UUID

ID returns a fresh UUIDv7.

func PagesLinkStatus

func PagesLinkStatus(raw string) (int, bool)

PagesLinkStatus answers the page builder's link check for the demo's addresses without the network: Acme's own sites answer, except the beta terms the "Join the Beta Program" draft points at, which are gone (PageBuilderStates: "A link doesn't work"). ok is false for any other address.

func ReadinessLinkDNS

func ReadinessLinkDNS(r dnscheck.Resolver) dnscheck.Resolver

ReadinessLinkDNS answers the URI blocklist lookups of link domains in the demo and in tests (SR-1): go.acme-promo.link, the flash sale's "Claim your discount" link, is on Spamhaus DBL and SURBL, as the boards draw it, and every other domain is clean. No lookup reaches the real lists, whose operators refuse lookups through public resolvers anyway.

func ReadinessProberOverlay

func ReadinessProberOverlay(next contentcheck.Prober) contentcheck.Prober

ReadinessProberOverlay answers Send Readiness's link requests for the demo's links (acme.io and the sites the sample emails link to) without going to the network, so the demo reads like the boards offline; other links go to next.

func SMSDNSOverlay

func SMSDNSOverlay(r dnscheck.Resolver, urls publicurl.Builder) dnscheck.Resolver

SMSDNSOverlay answers the demo's short-link domain (go.acme.io) from the demo zone: a CNAME to the instance, as Marcus set it up.

func SampleWorkspace

func SampleWorkspace(ctx context.Context, tx pgx.Tx, box *secrets.Box, ws store.Workspace, owner store.User, now time.Time) error

SampleWorkspace fills a new workspace with a compact Acme sample for its owner: "Explore with demo data" on the first-run Overview (review PR-13). Three lists, a few hundred contacts across mailbox providers, demo connections of Amazon SES, Postmark and Postal (demo connections never send: nothing leaves the instance), the routing of the ProvidersRouting board and a draft campaign. Nothing else changes: no demo users, no shared password, no other workspace.

func SendersDNSOverlay

func SendersDNSOverlay(r dnscheck.Resolver, publicURL func() string) dnscheck.Resolver

SendersDNSOverlay answers what Settings › Senders shows differently from the deliverability demo zone (acme.io's own DMARC policy) and the tracking domain's CNAME, which points at the host of publicURL as it is now, on top of r, which is normally the deliverability demo zone (sendersDemoZone adds the senders' records there).

func SendersDomainService

func SendersDomainService(tx store.DBTX, publicURL string) *domains.Service

SendersDomainService is a domains service on the demo DNS zone, for the seeder's checks.

func SendersNS

func SendersNS(next func(context.Context, string) ([]string, error)) func(context.Context, string) ([]string, error)

SendersNS answers the demo zone's nameservers (acme.io and its subdomains) and asks next for everything else.

func SendersTTL

func SendersTTL(next domains.TTLFunc) domains.TTLFunc

SendersTTL answers the demo zone's TTL (an hour, as the sample records say) for acme.io names and asks next for everything else.

func Split

func Split(n int64, weights []float64) []int64

Split divides n by weights so the parts add up to exactly n (largest remainder method), keeping demo totals consistent across breakdowns.

func WebsiteCertOverlay

func WebsiteCertOverlay(next website.CertChecker) website.CertChecker

WebsiteCertOverlay answers the website's certificate checks for the demo's domains (acme.io and its subdomains, news.acme.io among them): a Let's Encrypt certificate that renews on time, without going to the network. Other domains go to next (nil: unknown).

func WhatsAppTemplates

func WhatsAppTemplates() []meta.Template

WhatsAppTemplates are the account's templates as Meta lists them (synced 15 Oct 08:00 in the demo).

Types

type NorthwindOptions

type NorthwindOptions struct {
	// ContactsDivisor loads every client with 1/n of its contacts (tests:
	// the same people, lists and rules on a database that clones fast).
	ContactsDivisor int
}

NorthwindOptions change how much of the sample is loaded.

type Result

type Result struct {
	OwnerEmail string
	Password   string
	TOTPSecret string
}

Result describes what was seeded.

func Seed

func Seed(ctx context.Context, pool *pgxpool.Pool, cfg *config.Config, box *secrets.Box, log *slog.Logger) (*Result, error)

Seed loads the demo data in one transaction. It is idempotent: when the demo owner already exists nothing happens.

func SeedAt

func SeedAt(ctx context.Context, pool *pgxpool.Pool, cfg *config.Config, box *secrets.Box, log *slog.Logger, at time.Time) (*Result, error)

SeedAt loads the demo data as seeded at a given moment: tests whose numbers depend on the calendar (this month's SMS spend) seed at a moment when the design's days fit in one month.

func SeedNorthwind

func SeedNorthwind(ctx context.Context, pool *pgxpool.Pool, cfg *config.Config, box *secrets.Box, log *slog.Logger) (*Result, error)

SeedNorthwind loads the agency sample into an empty database.

func SeedNorthwindWith

func SeedNorthwindWith(ctx context.Context, pool *pgxpool.Pool, cfg *config.Config, box *secrets.Box, log *slog.Logger, opts NorthwindOptions) (*Result, error)

SeedNorthwindWith loads the agency sample with options.

type Seeder

type Seeder struct {
	Tx  pgx.Tx
	Q   *store.Queries
	Box *secrets.Box
	Cfg *config.Config
	Now time.Time
	Log *slog.Logger

	// Instance and people
	Users map[string]store.User // by email
	// Workspaces by slug ("acme-newsletter", "acme-engineering-blog")
	Workspaces map[string]store.Workspace
	// Roles by workspace slug + key ("acme-newsletter/content-writer")
	Roles map[string]store.Role
	// Lists by name ("Weekly Digest")
	Lists map[string]uuid.UUID
	// Providers by short name ("ses", "postmark", "postal")
	Providers map[string]uuid.UUID
	// Campaigns by name
	Campaigns map[string]uuid.UUID
	// Senders by email
	Senders map[string]uuid.UUID
	// Domains by name
	Domains map[string]uuid.UUID
	// Extra is free-form storage for domain seeders.
	Extra map[string]any
	// contains filtered or unexported fields
}

Seeder carries shared state between domain seeders.

func (*Seeder) After

func (s *Seeder) After(fn func(context.Context, *Seeder) error)

After runs fn once every seeder has run, for rows that need IDs from a seeder that comes later in the order (for example per-provider domain verification, seeded with the senders but needing the providers).

func (*Seeder) Ago

func (s *Seeder) Ago(d time.Duration) time.Time

Ago returns now minus d.

func (*Seeder) WS

func (s *Seeder) WS() store.Workspace

WS returns the main demo workspace (Acme Newsletter).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL