Product · Next.js · Security · Deployment
invitedFor: Digital Invitations Every Guest Sees the Same Way
A host designs an invitation and shares one link; hundreds of guests open it on their phones without an account. How we kept that page safe and identical for every guest: designs stored as data, frozen publications, the venue's own time zone, and five deployment defects that only shipping could expose.
In Kerala, a wedding invitation is still often a printed card, delivered by hand and followed by a phone call. More and more of it now happens on WhatsApp: a photo of the card, a location pin, a voice note with the times, a second message for the reception on another day. It works, but it is a pile of fragments, and every guest has to assemble the event from them.
invitedFor is a digital invitation product built for that reality. A host creates an event, picks a design, edits the invitation directly on the design and publishes a link. Guests open it on their phones and never need an account. Kerala and the south are the first market, so the designs, the date formats and the vocabulary follow from there.
I built the API, the web app and the deployment, starting in early September 2026. This post is the engineering story: the decisions that shaped it, the bugs that taught us the rules, and the deployment defects that only shipping could expose.
What the product does
A wedding here is rarely one event. It is several functions across two or three days: a ceremony in the morning, a reception in the evening, sometimes a function for each family. So an event in invitedFor holds a set of programs, each with its own time, venue and details, and each guest is invited to the programs that apply to them.
The host's side covers creating the event and its programs, choosing a design and a colourway, writing the story, a gallery, travel notes and answers to common questions, and adding guests. Each guest gets their own link. The guest's side is the invitation itself: the card, the programs they are invited to, a reply for each, dietary notes, any questions the host asked, and a button to add the times to their own calendar. The host sees who has opened their invitation and who has replied.
It is two services sharing one Postgres database on Neon: a NestJS API and a Next.js web app. Types and rules that both sides depend on live in a shared contracts package, built before either app. Migrations are forward-only. That shape sounds ordinary, and most of the product is ordinary: sign-up, an editor, a dashboard. One page is not.
Deciding the model before writing the code
We started with an architecture challenge rather than code: a master plan, reviewed by attacking it, with decisions recorded as numbered records and open questions recorded as open questions instead of being quietly answered by whatever got built first.
The most useful correction from that phase was about the word tenant. An early draft said "the event is the tenancy boundary". That conflated three different things, and we withdrew it in favour of an explicit separation:
- Authorisation scope is the event: you may act on an event if you are a member of it.
- Ownership is the customer account that pays for it.
- The host may be two families, or an event planner acting for a client, so a host is not the same thing as a customer, and neither is the same as one person.
What a tenant is stayed recorded as an open question until the product could answer it, because a data layer built on the wrong unit of isolation is not cheaply corrected.
The same review added a specific attack to defend against: the confused deputy. Someone who is legitimately a member of two events sends a change scoped to one event but carrying the ids of guests or invitations from the other. Membership passes, because they are a member. The defence is structural: every repository method that touches an event's children takes the event id as its first parameter and scopes by it, so a bare list of ids can never reach the database on its own.
We armed that rule as a tripwire before the code it guards existed. The tests that assert "every event-child repository is scoped by event" were written while there were no such repositories, so they passed by finding nothing, and would fire the moment someone added a method without the guard. They were verified by injecting violations, not by watching them go green: a method that took a plain list of ids fired; the same method with the event id first passed. The commit that adds the risky method can't forget the guardrail, because the build fails instead.
The page hundreds of people open
The guest's invitation is opened by everyone on the guest list, on every kind of phone, often within the same hour, and nobody signs in to see it. A mistake on that page is made hundreds of times. So it got its own rules, and we kept them short and in the repository. They are the few that actually caught bugs; everything else is ordinary good sense.
Rule one: a stored design is data, never markup
The easy way to support many designs is to store each one as SVG or HTML and render it. It is also the dangerous way. An SVG can carry a script, and an invitation is a page people trust because it came from family.
So a design is never markup. Administrators compose designs from a named kit, and the stored design is a small record that refers to that kit by name: a frame, a motif, a palette, a layout. Colours go through a validator that only accepts tokens from the palette. Artwork goes through a parser with a closed vocabulary. Nothing anyone types is ever rendered as markup, so there is nothing to inject.
The kit itself is drawn from scratch in vector: three kinds of arch, a corner spray, a garland, a mandala, a temple gateway, a peacock, a damask ground and a divider. Drawing rather than using photographs mattered for two reasons. Ornate invitation artwork found online is usually someone else's copyrighted illustration, which is not a risk a product can carry. And a drawing recolours where a photograph can't: every mark uses the current colour or a foil gradient resolved from the design's own palette, so one arch serves a maroon wedding and a sage-green garden one, and ornament and palette can never disagree.
That made colourways cheap. A host who loves a Kerala kasavu design but not its gold doesn't have to settle. A colourway is a whole design for storage and rendering, composed from its original so the drawing and shape are shared and only the paper and metal differ. The gallery shows a family of colourways as one tile with a dot for each, instead of near-duplicates side by side.
The trade-off is flexibility: a designer can't upload an arbitrary flourish. New ornaments are added to the kit in code and reviewed like any other change. For a page with this many readers, that is the right side of the trade.
Rule two: retire designs, never delete them
Once a host has chosen a design and shared the link, that invitation has to keep rendering, possibly for months, and long after the design has been replaced by a better one. Deleting a design would break every event that used it.
So designs are retired, never deleted: they disappear from the picker but keep working for events that already chose them. The renderer is also built to fall back rather than throw. If a design reference is ever missing or malformed, the guest still sees an invitation, not an error page.
Rule three: no randomness and no clock in the ornament kit
The invitation renders on the server first and then again in the browser, where React hydrates it. An ornament that used a little randomness to vary its petals would draw one flower on the server and a different one in the browser. That is a hydration mismatch, and depending on where it happens it is anything from a console warning to a broken page.
The rule is absolute: nothing in the ornament kit reads Math.random() or the current time.
Every render of an invitation draws the same card. Where we want variation, it comes from
the stored design, which is the same on both sides.
Rule four: the venue's time, not the host's
Dates are the single most important fact on an invitation, and they are where the server,
the browser and the people involved quietly disagree. Intl formats against the runtime's
locale and time zone: the server's on the first render, the guest's browser on hydration.
So every date on the guest page is formatted with an explicit locale and the venue's time
zone.
That rule was enforced in the display from the start. A real bug showed it had to hold in the editor too. The time pickers hand over a wall-clock time like "18:00", and every save turned it into an instant by reading it in the host's browser's time zone. A host in Kerala never sees the problem. A host in Dubai sending out a wedding in Thrissur typed 6 pm, and every guest's card said 7:30 pm. The design step's date sheet was worse: it read the time in the venue's zone and wrote it back in the browser's, so each save moved the ceremony another ninety minutes.
The fix put two functions in the contracts package that convert wall time to an instant and back in a named time zone, the program's or else the event's, and every form that touches a time uses them in both directions. The host's own lists now print the venue's hour too, because that is what the guest reads. The round-trip test runs with the laptop set to Dubai and the venue in India, the exact case the old conversion got wrong.
Rule five: every design meets AA contrast, in both schemes
An invitation is read outdoors, on inexpensive phones, by grandparents. Contrast is not a nicety. Every design and colourway has to meet WCAG AA contrast in both the light and dark schemes, and a test checks every combination in the kit. It has caught about a dozen designs that looked fine on a good monitor.
The host app got the same treatment from an automated accessibility sweep over the running product, and it found two lessons worth keeping:
- A token tested against the wrong background. The muted text colour cleared 4.5:1 against white and against nothing else in the palette. Muted text is almost never on plain white: it is the second line of a stat tile, the caption under a selected option. The one background it passed on was close to the only one it was never used on.
- A rule declared twice. One class was defined twice, hundreds of lines apart. The later rule set the colour, which is what anyone reading either would call the live definition; the earlier one also set an opacity the later never reset. The result shipped at 2.71:1 on every guest row in the product. Neither declaration was wrong on its own, which is why nothing caught it until we measured the rendered page.
Publishing freezes what a guest reads
For a while, publishing an event only stamped a "published" date, and the guest page rendered live from the event's rows. So a host editing the venue after sending invitations silently changed the invitation people already held.
Now publishing composes a snapshot and writes it as the next revision, so the history of what was actually sent survives instead of being overwritten, and the guest page reads from the current publication, never from the live rows.
The split that matters is between content and access. Content is frozen, but who may see which part is not. Entitlements, which programs each guest may see, stay live, so revoking an invitation takes effect immediately, even against a publication written before it. Otherwise a revoked invitation would keep working until the host happened to republish. A program added after a publication stays invisible until the host publishes again, which is the same rule read from the other side: an entitlement can't conjure content the host never published.
The open link, without a second model
Every invitation started out per-guest: type a name, issue a link, and that link is for that person. That is right when a host has a list and useless when they don't: an invitation posted in a family WhatsApp group, a QR code on a printed card, a link in a bio.
The tempting design is a public page anyone can open and reply on. That would fork the guest experience in two, one path with guests and entitlements and one without, and every feature after that would need building twice.
So the open link issues invitations rather than replacing them. A visitor opens it, gives their name, and the server creates a guest and an invitation carrying exactly the programs the host attached, then hands the visitor their own per-guest link. Everything downstream, entitlements, replies, revoking, the reply board and the dashboard counts, is unchanged, because what reaches it is an ordinary invitation. The host's guest list fills itself.
Before claiming, a visitor sees the event's name and how many functions lie behind the link, and nothing more. What an anonymous visitor may see is a real product question, and it stays the host's decision rather than something the open link quietly answers.
A calendar file that actually imports
A guest who has just said yes to three functions across two days needs a way to keep the times, and a wedding is exactly the event where times matter and get lost. So the invitation offers an "add to calendar" file.
It is served from a real route as text/calendar, not a data URL on the page: data-URL
downloads are unreliable on exactly the phones most guests open a WhatsApp link on, and a
button that does nothing on an iPhone is worse than no button. The route uses the same
capability model as the card beside it: the token in the link is the credential, so a
function this guest isn't invited to can't reach the file.
And it is written to the calendar standard rather than approximated, because a malformed calendar file doesn't degrade, it silently fails to import. Lines end in CRLF. Commas and semicolons are escaped, so a venue like "Grand Hall, Town Centre" doesn't split into two values and vanish. Long lines are folded by measuring bytes, not characters, so a name written in Malayalam or Devanagari isn't cut in the middle of a character.
The marketing site has to tell the truth
The homepage advertised a follow-up reminder that nothing implemented, for months, on the live site. Fixing that one claim fixes one claim, so we audited every claim on the marketing site against the product and found five more: a "maybe" reply the product didn't have, a household grouping that existed in no schema, a feature named in two different words.
The real fix for a class of defect is not five fixes. The reply statuses were declared in the API, spelled out again in the web app, and a third copy had reached the marketing site as the "maybe" that didn't exist. They now live once, in contracts, and a marketing-claims test keeps the site's promises tied to what the product actually does.
A host app that works like a phone app
Most hosts manage their event on a phone. The desktop sidebar used to become one sideways-scrolling strip that showed exactly one destination on a 375-pixel screen. The host app now behaves like a native app on phones: a tab bar under the thumb with the one primary action in the middle, a title bar that says where you are with a back arrow, safe areas for the notch and home indicator, and form fields at 16 px so iOS stops zooming into every input. It installs to the home screen like one too.
Small performance details mattered for the same reason. The logo had no image sizes set in a few places, so the browser fetched a 263 KB image to draw a 30-pixel icon, and the marketing pages pulled a 320 KB original for a footer watermark. Routing both through the image optimiser at the size actually drawn took them to a few kilobytes.
Five defects only deploying could expose
The part of this project I learned most from was getting it into production. The API runs on Render in Singapore, the web app on Vercel, and the database on Neon Postgres 18, also in Singapore, next to the API. Each of these defects was invisible locally.
1. Vercel built the web app without its workspace. Vercel builds with the web app's folder as its root and installs only that package. The TypeScript compiler, the Node types and the link to the shared contracts package all lived at the repository root, so the build failed. The fix was a project config that installs at the root and builds the contracts first.
2. The variable that makes the runtime correct broke the build. Render sets
NODE_ENV=production, and npm skips development dependencies when it is set. TypeScript
and the type packages disappeared, and the compile step failed. The fix was one line,
NPM_CONFIG_INCLUDE=dev, but it took a deploy to find it.
3. A commit the platform couldn't attribute stalled production. Vercel refuses to build a
commit whose author email doesn't match a GitHub account, and the refusal is per commit, so
one commit from an unknown address holds back everything merged after it. Worse, it is
silent from the repository: the push succeeds, main looks deployed, and only the
deployment list says blocked. It happened twice, from addresses a letter apart. The fix is
in the repository, not the platform: git hooks that refuse to write or push a commit from an
address the platform can't attribute, installed automatically by npm install, so every
fresh clone is guarded from its first install.
4. The blueprint is not the service. The API was created on Render from a render.yaml
blueprint once, and is not synced to it afterwards. A commit made a new environment variable
required and added it to the blueprint in the same change, which read as complete. The
service never received it, the new release refused to boot, and Render quietly kept the
previous version live, so a new rate limiter simply wasn't running while the health check
answered "ok". Now a required variable is set on the service before the commit that requires
it is merged. Startup still fails closed by design, so the cost of forgetting is a failed
deploy rather than a bad one.
5. A health check that pointed at a route that didn't exist. We separated readiness from liveness, and the controller looked like it served both paths:
@Get() // this one is overwritten...
@Get("ready") // ...by this one
async check() { /* ... */ }Stacked route decorators don't accumulate; they write the same metadata, and the last one
applied wins. /health/ready returned 404 to anyone who asked, including the deployment
config that named it, so pointing the platform's health check at it would have failed every
deploy of a perfectly healthy service, with a timeout and no reason given. The fix is a
single decorator with both paths, @Get(["", "ready"]), and a test that reads the health
path out of the deployment config and fails if the controller doesn't register it.
Every one of these is the same shape: two artifacts that are meant to agree, and nothing that checks they do. A package and its root, a runtime setting and a build step, a commit and an account, a blueprint and a service, a config and a route. The fixes that held were the ones that turned each agreement into something checked: a hook, a test, a startup check that fails closed and names the missing variable.
Two smaller lessons from the same weeks belong next to them. The first production sign-up returned a 500 because the web app's API address silently defaulted to localhost, which is nothing in a serverless runtime; it now refuses to start in production without the variable, because a silent default turns a missing setting into something that looks like an application bug. And a deploy was once checked by polling the sign-up endpoint with a password the old version rejected, until the new version shipped and the probe created a real account. The lesson is worth writing on the wall: poll with reads, never with writes, and never with a request whose safety depends on the server rejecting it.
Sign-in that keeps secrets where they belong
Google sign-in runs entirely in the web service. It exchanges the authorisation code, validates the identity token, and passes only the verified identity to the API. The API never receives a Google secret, code or token, so there is one fewer place for them to leak. Each environment has its own OAuth client, and none of the values are exposed to the browser. Session cookies are HTTP-only, secure and same-site.
Where it stands
The API, web app and database are deployed and verified end to end: sign-up, sign-in and the account flow run against production. Email delivery is set up on a verified domain and held back behind a logging transport until launch. Public event pages open once the remaining launch checks pass.
What I took from it
The guest page taught me to design for the reader I can't see: the relative on a slow phone, in another time zone, opening a link they trust. That reader is why designs are data, why publications are frozen, why times belong to the venue and why contrast is tested rather than eyeballed.
The deployment taught me to distrust anything that "looks complete". Most of the bugs worth writing about weren't in the code at all; they lived in the space between two things that were supposed to match. The habit I kept is to look for those pairs early, and to turn each one into a check before it turns into an incident.
