demo

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2026 License: AGPL-3.0 Imports: 48 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 (
	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 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 Password = "reputecast-demo" //nolint:gosec // public demo password, documented in the README

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 TOTPSecret = "JBSWY3DPEHPK3PXP" //nolint:gosec // public demo secret, documented in the README

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

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).

Functions

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 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 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 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.

Types

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.

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