跳到正文
DEV Community· Ryan Batchelder·· 1 小時前AI 評分39

BadgeTag:構建無伺服器會議聯絡工具

Building BadgeTag - The Serverless Conference Connection Helper

AI 導讀

BadgeTag 是一款無伺服器會議聯絡工具,讓用戶建立數碼名片,透過連結或 QR code 分享,也可 3D 列印到實體名牌上。系統以 Lambda、API Gateway、DynamoDB、S3、CloudFront 和 Cognito 組成,並用 AWS CDK 管理基礎設施。後端採用 Rust Lambda,原生編譯後冷啟動可達個位數毫秒。

正文

This is the story of BadgeTag, a lightweight digital business card you can pull up at a conference, share with a link or a QR code, and even 3D print onto a physical badge.

The idea came out of a recent AWS Summit that I attended. I was standing there trying to connect with someone, fumbling between social apps and taking photos of badges so I wouldn't forget who I'd just met. At one point I spent an embarrassing amount of time digging through a popular professional network's app trying to find where the QR code for my profile was hidden. Now instead of spending time being in the moment and making a human connection, I was fighting with an app. At that point I realized that my scannable code should live right there on my physical conference badge instead of buried four menus deep in my phone. This little app is my answer to that: make a profile with your name, contact details, and social links, and share it instantly, with nothing for the other person to install.

The feature list isn't really the interesting part (though I had a ton of fun thinking up new things to add). What I think is more interesting is the pile of technical decisions sitting underneath it, so that's what I want to spend this post on: how BadgeTag is built and why I made the decisions I did.

Serverless First

I reach for serverless whenever I can, because I don't want to pay for infrastructure that's sitting around doing nothing. BadgeTag is exactly the kind of workload that rewards that instinct, because its traffic is spiky and unpredictable and often zero. The whole app gets used for a few hours at a conference and then does almost nothing for weeks, and I really didn't want idle servers quietly draining my wallet in between. Scaling to zero after the show is over is the entire reason the economics work for a project like this. Conversely, if tons of people are connecting at a conference I don't want to have to worry about scaling sufficiently to meet that demand. Serverless covers both for me.

The architecture fell out of that mindset pretty naturally. Lambda handles the compute, with an API Gateway HTTP API in front. DynamoDB stores the data and S3 holds the static frontend and the profile images. CloudFront serves up all of it, and Cognito handles auth. Everything on that list scales to zero, or close enough that the bill rounds to nothing at low traffic.

The tradeoff I had to work around in return is that I needed to design around Lambda's stateless, time-boxed execution model, and you have to think about cold starts. That last point is really what drove my next decision.

Rust on the backend

I know, picking Rust for a digital business card seems like overkill. If I were writing everything myself I'd probably agree, but since Kiro is handling the code on this one, Rust started to make a lot more sense.

The long-standing knock on Lambda is cold starts, and while there are plenty of ways to mitigate them (provisioned concurrency, SnapStart, pinging functions on a schedule to keep them warm), most of those either cost money or add operational complexity, which runs against the whole reason I went serverless in the first place. The cleanest way to deal with a slow cold start is to not have one, and that's what Rust gives you. A Rust Lambda compiled to a native binary has no runtime to bootstrap and no garbage collector, so cold starts are in the single-digit milliseconds.

A few other things worked in my favor here.

  • I wanted invocations that were both fast and cheap, and it doesn't get faster and cheaper than ARM. Rust makes that painless because it can compile to ARM without any fuss. cargo-lambda handles the cross-compilation, so I don't have to think much about the build and deploy step.
  • I've always been a fan of strong type systems that prevent bugs at compile time, and Rust might have one of the best examples of that. We now live in a world where we have non-deterministic machines writing code for other machines to run deterministically, and a good type system sitting at the core of my quality posture helps me sleep better at night. There are practical benefits here as well where a coding agent can iterate faster when the compiler is catching issues than waiting to find them at runtime. Faster iteration not only means faster delivery, but also lower token costs for me.
  • … I just wanted to. I work with Python all the time and while that would have done a perfectly good job for this, side-projects are supposed to be fun so why not give something else a try?

Is Rust the obvious pick for a weekend-sized CRUD app? On my own, probably not. The learning curve is real, and if I were hand-writing every handler I'd likely have reached for something I could move through faster. But Kiro is doing the actual coding here, so I'm free to make tech choices without being hampered by my own language skills. This way I get the fast cold starts and the cheap Graviton bill without the long debugging evenings.

Infrastructure with CDK

All of the infrastructure is AWS CDK written in TypeScript, split into different stacks to keep components organized.

Let's start with a walkthrough: everything a visitor touches goes through a single CloudFront distribution. Any root-level requests fall through to the default behavior, which serves the React app out of an S3 bucket. Anything under /api/* is routed to an HTTP API Gateway sitting in front of the Rust Lambda. Anything under /images/* goes to the profile-image bucket. And /p/{id} requests get inspected by a small CloudFront Function that redirects known social-media crawlers off to a server-rendered OpenGraph route.

BadgeTag architecture: a visitor request flows through WAF and a single CloudFront distribution, which routes by path to a React app in S3, an HTTP API in front of a Rust Lambda, and a private profile-image bucket. The Rust Lambda reads and writes DynamoDB, uploads to the image bucket, and signs users in through Cognito, which delivers one-time codes via SES. A manual Step Functions job regenerates OpenGraph images, and CloudWatch alarms route to an SNS alerts topic.

Behind that, the app is split into multiples CDK stacks to keep concerns isolated:

  • DataStack holds state: a DynamoDB table for profiles and connections, and the S3 bucket for profile photos. I'm using a TableV2 global table with on-demand billing and point-in-time recovery turned on. I'm not deploying to multiple regions at this point so I certainly don't need to be using a global table, but if I ever want to go multi-region in the future I can deploy that with just a one-line change in my stack rather than re-building the table.

  • AuthStack is Cognito. Sign-in is passwordless, with an emailed code as the main path and passkeys as an optional second way in. The codes go out through SES which was a pain (more to come there) but on the flip side I appreciate not needing to worry about passwords whatsoever.

  • ApiStack is the Rust Lambda behind the HTTP API Gateway, plus throttling setup, alarms, and the Step Functions job for regenerating OpenGraph images. This is where most of the app actually lives.

  • FrontendStack owns the CloudFront distribution and the S3 bucket for the built React app. It's the piece that stitches all those paths together into one origin.

  • WafStack is a WAF Web ACL in front of CloudFront: AWS managed rule sets plus a per-IP rate limit to blunt the obvious scripted abuse.

  • RumStack is CloudWatch RUM for real-user monitoring in the browser, so I can see client-side errors and actual load times from real devices rather than guessing.

  • MonitoringStack is the single dashboard and the cost budget alarm. It pulls metrics from the other stacks and gives me one place to look, and one email if the monthly bill crosses a line I set.

All of these stacks are loosely coupled to avoid the headache that is CloudFormation exports. Each stack publishes the identifiers it owns (table name, bucket ARN, API URL, etc) to SSM Parameter Store on a predictable path, and the stacks that need them read them back by name. Anyone who has used CloudFormation exports enough has probably felt the pain of the hard dependency that creates, which makes a stack painful to tear down or replace while anything references it. Going through SSM means I can rip one down and redeploy it without a dependency chain fighting me the whole way. Yes, I know this is technically less safe because I could break the app but I'm the only person working on this and I mostly trust myself not to do that without realizing.

This project was also a good excuse to do something I'd been meaning to do for a while: set up a proper AWS Organization with separate dev and prod accounts. BadgeTag is public-facing, so I wanted its production workloads walled off in their own account, well away from anything I'm experimenting with. Accounts are one of the fault-isolation boundaries I've written about here before, so now any mess I make while hacking on something in dev isn't going to break the infrastructure that's actually serving up cards.

The SES production access slog

If you'd asked me beforehand to guess what would be the biggest time sink on this project, I would not have said "email." The code came together super quick, but getting AWS to let me actually send email from my production account was a different story.

BadgeTag handles sign-in with a one-time code emailed to you, so being able to send emails is kinda important. No email means nobody signs in, and signing in was pretty important (also I really didn't want to deal with passwords). AWS Simple Email Service (SES) starts every account in the sandbox, where you can only send to addresses you've verified yourself. That's perfectly fine for testing, but it's useless for real users. To send to anyone, you have to request production access.

Here's where the clean account structure I was so happy about came back to bite me a little. My prod account was brand new, created specifically for this project, which meant it had zero history. From their side I was an unknown account asking for the keys to send mail to arbitrary strangers. On the one hand I can appreciate how challenging it must be to prevent malicious users in this sense, but on the other I wish there was a bit more transparency in the process. Further adding to my frustration was the fact that my new account was sitting in an organization owned by a very old account (which has production SES access itself), and that fact didn't seem to matter.

So my first request got turned down. I wrote up what the app did, who it emailed and why, how I was handling bounces and complaints, and sent it back. Then I waited, and waited, and waited with no response until eventually… another denial.

Eventually I found this excellent guide written by fellow AWS Community Builder Warren Parad. I followed his advice exactly, resubmitted, and after another bit of waiting I was finally approved!

If I were doing it again, I would make sure I have everything in Warren's guide done thoroughly before my first request. It's an easy lesson to pass along: if your app depends on sending email from a fresh account then be prepared and start that conversation with AWS early. Being ready to launch and just waiting on AWS Support isn't a fun time.

The OG OG Image

A digital business card really has one job, which is to get shared. So with that in mind, imagine being me and going to show off my new app to the group chat only to paste in my BadgeTag link and have it just look like well… a link. Messaging apps these days all have some ceremony when you paste in a link with cool branding or previews, but since BadgeTag is essentially a single-page app (SPA) the iMessage crawler wasn't about to go run all my JavaScript to render anything. I wanted to have cool branding and previews, too!

An iMessage screenshot showing an example of an OG image

The fix was server-side OpenGraph rendering. There's a crawler-facing route that renders proper OG tags, including a link to a composite share image that stitches the logo, the QR code, and the profile photo together into a single PNG. That image is generated ahead of time whenever a user updates their slug or profile picture so it's ready to go whenever they share their link. You may have also noticed the "OG image regen" section in the diagram that's not associated with any user requests. If I ever change the OG image design, I wanted a way to regenerate all OG images at once, hence a step function state machine that can be manually invoked to pull all current users and fan out a re-generation of all of them.

What does 3D printing have to do with it?

Believe it or not, this whole idea actually started as a 3D printing project with a software component. They say that when you have a 3D printer, you just look for excuses to 3D print things, and I can confirm that's 100% true and the root cause of why you're sitting here reading this in the first place. So after I had this idea then came the hard part: generating QR codes is easy but what should it point to? Do I just scale-up my LinkedIn code and hope for the best? Do I want to generate a couple of codes to link to various different profiles depending on who I'm talking to? Is this all just silly?

That last question was probably the most important, because silliness often drives the best side projects. True to that initial idea, BadgeTag does have the ability to generate a 3 dimensional version of your QR code ready for multi-color printing. I just decided that in order to answer my question by building a whole app in front of it.

Screenshot of BadgeTag's 3D Print generation menu

Wrapping up

None of these decisions are revolutionary on their own, and they're all well-trodden paths. What I like about the way BadgeTag came together is how neatly they reinforce one another. The serverless rule pushed me toward Rust for fast cold starts, Rust let me stay cheap by running on Graviton, and keeping everything same-origin behind one distribution made the whole thing simpler to reason about while fixing a real bug in the process.

What surprised me most was how having coding agents like Kiro write the code reshuffled which trade-offs I even cared about. Rust is the clearest example: the thing that normally makes me hesitate is how long it takes me to write, and that cost mostly went away. Leveraging AI tooling also moved where my attention had to go. The decisions, the reviews, and the real-world testing became the work, because those are the parts that I don't want an agent doing for me.

The real test will come at this year's AWS re:Invent, when I'm standing in front of someone new and I can hold up my badge instead of digging through four menus on my phone. If the scan is quick and the card just loads, then all of this was worth it.

A Timely Footnote

If you made it this far, the date is still some time before the close of AWS re:Invent 2026, and you happen to be attending said event in Las Vegas: come find me! While I haven't solved portable 3d printing yet, I will be offering to print BadgeTag stickers on the spot that you can put somewhere to make it easy to connect with others at the conference! Just be sure to make your profile first at badgetag.me.

Not sure how to find me? Don't worry, there's an app for that :)

來源:DEV Community · dev.to