From Formspree to Cloud Run: Building My Portfolio Contact Backend (and Living to Tell the Tale)
• 8-10 min read
When I first launched my portfolio website, I wanted a quick way for people to reach me. Like many developers, I turned to Formspree. It worked fine: type your message, hit submit, and boom — I’d get an email. But “fine” wasn’t enough for me anymore. I wanted to build something myself, something that would give me hands-on experience with Spring Boot and push me into the uncharted waters of deploying on Google Cloud Run. That’s how this project started — as a simple replacement for Formspree — and it quickly spiraled into a crash course in backend development, cloud deployment, and patience.
The backend itself was simple in concept. I built a REST endpoint called /api/contact to accept form submissions and created a ContactRequest object with validation annotations like @NotBlank and @Email. This way, I could be sure I wasn’t just receiving blank strings or nonsense in the email field. The service class, EmailService, was wired up to JavaMailSender and set to send me an HTML-formatted email with the user’s information. In theory, it was neat and tidy. In practice, nothing about getting it into production was neat or tidy.
My first hurdle was simply understanding why my form only seemed to work when I was running the backend on localhost. I wasn’t yet thinking like someone deploying to the cloud, so it took a while to realize the obvious: my code was running fine locally because it had direct access to everything it needed, but once deployed to Cloud Run, the environment had to be explicitly configured. That led me into my first real challenge: environment variables. At first, none of my values for spring.mail.username, spring.mail.password, contact.to, or contact.prefix were being picked up, which left my backend happily running but completely incapable of sending an email. It felt like the equivalent of having a car that starts perfectly but has no wheels attached. Learning how to inject those variables through Cloud Run — and how to pull sensitive values like the password from Google Secret Manager — was a turning point. Suddenly, the engine wasn’t just running, it had a road beneath it.
Just when I thought I was in the clear, deployment itself decided to throw me off track. My first attempts at redeploying the service with
gcloud builds submit --pack
image=us-central1-docker.pkg.dev/portfolio-contact-470712/apps/portfolio-contact
ended in failure because the Artifact Registry repository I was pushing to didn’t exist yet. The build would succeed, the image would compile, and then Google Cloud would shrug and tell me:
name unknown: Repository "apps" not found.
ERROR: failed to push because we ran out of retries.
It was like baking a cake only to discover the oven was imaginary. The solution was either to create the repository myself or switch to deploying with --source ., which let Cloud Run handle the heavy lifting. It sounds obvious now, but at the time it was another frustrating detour.
And then there were the Docker warnings. Every time I authenticated with gcloud auth configure-docker, I’d get a warning that Docker wasn’t in my PATH. Since I was using Cloud Buildpacks, I didn’t actually need Docker installed locally — Google was doing all the container work for me — but that didn’t stop the warnings from making me second-guess everything. The project was full of these little moments where I wondered if I was truly stuck or if the system was just messing with me. Spoiler: it was usually the latter.
Eventually, I got through those early roadblocks, and that’s when the most memorable bug of the whole project appeared. Everything was deploying, the environment variables were loading correctly, and the service looked like it was finally ready for the big leagues. Then came the 500 Internal Server Errors. I tried to submit a contact form, to test the outcome, and the logs filled with stack traces pointing deep into Tomcat and my ContactController.submit() method.
I was convinced I had broken something fundamental in my code. Hours of log-diving later, I realized the problem wasn’t my service at all — it was bad data. I was entering a bogus email address like struggles@wtf.com, which technically looked like an email but couldn’t pass AOL’s SMTP server without throwing a fit. My backend wasn’t catching the issue, so the whole request exploded into an error.
I ended up adding a stricter fail-fast regex check in the controller. Now if the email didn’t match, the backend would stop the request cold and return a friendly response instead of falling over. The relevant snippet looked like this:
if (req.getEmail() == null || !req.getEmail().matches(EMAIL_REGEX)) {
return ResponseEntity.badRequest().body(Map.of(
"code", "invalid_email",
"message", "Invalid email address. Please verify your email."
));
}
Instead of taking down the whole service, the endpoint now politely told the user their email wasn’t valid. It was one of those small changes that made a huge difference, and it taught me the value of defensive programming.
Looking back, this project started as a replacement for Formspree, but it ended up teaching me so much more. I learned how to build and validate APIs with Spring Boot, how to handle email with JavaMailSender, how to manage secrets securely with Google Secret Manager, and how to deploy real applications on Google Cloud Run. I learned how to debug production logs with the gcloud CLI, how to wrestle with GitHub branches without losing my mind, and how to keep moving forward even when the same command seemed to break in a new way every time I ran it. Most importantly, I learned that backend development isn’t just about writing code — it’s about adapting, troubleshooting, and laughing at your own mistakes along the way.
Now, my portfolio’s contact form doesn’t just look good on the frontend. Behind the scenes, it’s powered by a service I designed, built, and deployed myself. Every email that lands in my inbox will be a reminder of the work that went into it. And yes, I even made a logo in GIMP with the Spring Boot leaf, a Google Cloud badge, and an envelope, because if you survive a project like this, you deserve a little branding. What started with Formspree turned into a full-fledged learning journey, and while there were plenty of struggles along the way, I wouldn’t trade them. They’re what made the project not just functional, but meaningful.