Viewport Marketing

Back End Deep Dive

The goal was to make an easily maintainable, and easy to understand project structure. Naturally, Next.js was the first choice.

Fully Serverless with Next.js

I built the entire backend using Next.js so this is 100% serverless. This means no managing, patching or scaling servers.

Serverlessness provides accurate cost tracking and massive scalability. You only pay for what you use. Resources scale up or down to match traffic.

I can focus on rapid feature development rather than backend ops and maintenance. This speed is a huge advantage.

Cached Static Pages

I built the site using Next.js, which allowed us to pre-render most pages as static HTML. This means pages load near instantly without needing a ton of client-side JavaScript.

Next.js also enables server side rendering. This allows us to dynamically generate certain pages while still appearing static to search engines. Overall, Next.js optimization helps the content rank higher on page speed scores.

For example, the "Matterport Tours in Temecula" article is indexed by Google. When users search that term, Google surfaces the relevant content.

PlanetScale Serverless Database

For the database, I selected PlanetScale, because back then it had a free tier, and was easy to integrate with.

According to Planetscale, I had limitless scalability, which is quite frankly not a feature we ever got close to using, but it made me feel warm and fuzzy.

AWS Step Function-Like Workflows with Inngest (without the heavy-ness)

For orchestrating (if/then routing, retries, and sequencing) the serverless functions, I used Inngest - an open source serverless orchestration service written in TypeScript (similar to AWS Step Functions).

Inngest brings AWS step function-like capabilities without the overhead of complicated AWS SDK's. I can create complex workflows using Typescript.

A key benefit is Inngest's typed events system. I define events and their payloads as TypeScript interfaces. This ensures correctness (and fewer headaches trying to remember events) as I build out workflows.

When adding new workflow steps, TypeScript alerts me if I try to send invalid events. Events always have the right shape.

Inngest also seamlessly integrates with the Next.js serverless functions. There's no worrying about function versions or permissions.

Overall, Inngest allows us to confidently build reliable, scalable workflows in a typed, testable way.

Built for Failure Resilience

In serverless, failures happen. Network requests time out. Services go down. Ingest mitigates this.

Each step in a workflow is isolated. If one fails, I just retry that step without breaking everything.

This makes this system reliable and robust. I can also easily respond to failures programmatically.

Overall, this serverless backend tech provides a lean, agile foundation to build on.