Featured

MoralesBuilds: Building My Own Portfolio

A portfolio and blog that runs on Cloudflare's free tier — Next.js on Workers, D1 and R2 — built to show work I couldn't show before.

Next.jsCloudflare WorkersD1R2TypeScript

Context

After more than nine years building software professionally, I had a gap I couldn't close: almost everything I'd built was private. Tools, systems and sites made for internal use or for clients I could describe in an interview but not show. Anyone evaluating me had to take my word for it.

This site is how I'm closing that gap. I could have started from a WordPress theme; I've used it before, and it would have been faster. But speed wasn't the point. I wanted a project that keeps my skills sharp, where I can rebuild ideas from past work in the open, experiment with tools I know and tools I don't, and publish what I learn along the way. Over time, I want it to become a place where colleagues and clients don't just read that work, but respond to it.

The Problem

The site has two audiences asking different questions: a client deciding whether to hire a freelancer, and a recruiter deciding whether to reach out. Both need the same thing in the first few seconds — understand who I am and what I do, see some evidence, and find an obvious way to get in touch.

Behind that first impression, the site has to keep growing without getting in my way. Publishing a new case study or fixing a typo in a post shouldn't require a redeploy, and adding Spanish later shouldn't break a single URL.

Constraints

  • $0 a month to run, domain registration aside. This isn't just thrift: many freelance clients have the same constraint, so designing within it is practice for real work.
  • Commercial use allowed. The site markets my services, so the hosting free tier has to permit that.
  • One person, part-time, alongside everything else in my day.
  • Two languages planned from day one, even though only English goes live first.

Decisions

Cloudflare instead of Vercel or AWS

Vercel is the natural home for Next.js, and AWS is where I have the most production experience. I passed on both. Vercel's free tier doesn't allow commercial use, and a site that sells my services is exactly that. AWS can be cheap, but not predictably free: egress, routing and edge invocations can each add a charge. Cloudflare's free tier covers compute, database, storage, DNS and the domain itself in one place, and allows commercial use. The cost is an extra build step: Next.js has to be compiled into a Worker with an adapter (@opennextjs/cloudflare), and I had to learn a platform I barely knew.

D1 instead of PostgreSQL

Most of my backend work has been on PostgreSQL, so it was the obvious choice — and the one I passed on. The free Postgres options either pause after a few days of inactivity or sit far from the edge workers that serve each request. Cloudflare D1 runs right next to those workers and fits comfortably in the free tier. The trade-off is real: no enums, no Postgres extensions, and it isn't built for heavy writes. For a site that is read far more often than it's written, that was a price worth paying.

Metadata in the database, content in object storage

Keeping posts as Markdown files in the repository is the simplest option, but every typo fix would mean a full deploy. Storing the whole text in D1 would eat into its 500 MB free limit. So each post and case study is split in two: the metadata the site needs to list, filter and sort lives in D1, and the Markdown body lives in R2. Publishing is a script that writes both. The price is two reads per page and no transaction spanning both stores, so the script always uploads the file before writing the database record.

The language in the URL from day one

Only English is live, so I could have used flat routes (/blog, /contact) and added the language later. But moving every route under a new folder after launch means broken links and lost search rankings. Every page lives under [locale] from the start, and English is served without a prefix, so today's URLs stay clean and Spanish can be added as /es/... without moving a file.

Implementation

The code is a pnpm monorepo with two main pieces: apps/web, the Next.js site, and packages/contents-db, a small package with typed queries and its own integration tests against a D1 database.

Visitor ──▶ Cloudflare Worker (Next.js via OpenNext)
                 ├──▶ D1   metadata: projects, posts, tags, leads
                 └──▶ R2   Markdown bodies

Markdown + frontmatter ──▶ upload script ──▶ R2 file, then D1 record

Pages render on the server, so titles, descriptions and content are in the HTML before any JavaScript runs. The contact form validates input, applies a rate limit stored in D1, saves the lead and sends me an email through Resend. Every pull request runs the test suite in GitHub Actions; a failing test blocks the merge, and merging to main deploys the site and applies pending database migrations.

Results

MetricValue
Monthly hosting cost$0
Publishing a post or case studyOne script, no redeploy

What I'd Do Differently

  • Default to the server. I first let each page send its title and banner up to the layout through client-side React state. It worked, but the title, the heading and the banner only appeared after JavaScript ran — invisible to search engines and link previews. I replaced it with a header that each page renders on the server. With React Server Components, I now start on the server and only move to the client when interactivity demands it.
  • Test against the real thing. The rate-limit store was only tested against an in-memory fake, so a wrong SQL parameter number made it to a pull request — one that would have broken the contact form on every submission. Code review caught it; a test against D1 would have caught it sooner. The queries now have integration tests against a real local database, and the store is next.