Source code for pphat.me, the personal portfolio and blog of LEAT Sophat, a senior front-end developer and UI/UX designer.
The site has an introduction, a tech stack, work experience, projects, and blog posts. Projects and posts come from a separate API at api.pphat.me. The site is built with Next.js and runs on Cloudflare Workers.
| Route | What's there |
|---|---|
/ |
Introduction, tech stack, featured projects, experience |
/about |
Background and work history |
/projects, /projects/[slug] |
Project list and project detail pages |
/posts, /posts/[slug] |
Blog list and articles (Markdown) |
/contact |
Contact form (email sent through Resend) |
- Next.js 16 (App Router), React 19, TypeScript (strict)
- Tailwind CSS v4, Radix UI, Framer Motion,
next-themes(light/dark) - react-markdown with
remark-gfm,rehype-highlight, andrehype-sanitizefor article content - Cloudflare Workers (with static assets), built and deployed with
@opennextjs/cloudflare - pnpm for package management
You need Node.js 22 or later and pnpm 10.
pnpm install
cp .env.example .env # then fill in the values
pnpm devThen open http://localhost:3000.
See .env.example. The main ones:
| Variable | Purpose |
|---|---|
NEXT_PUBLIC_APP_URL |
Public URL of the site, e.g. https://pphat.me |
NEXT_PUBLIC_APP_API |
Base URL of the content API, e.g. https://api.pphat.me (the default when unset) |
NEXT_PPHAT_API_KEY |
Server-side key for the content API. It is never sent to the browser. |
RESEND_API_KEY, RESEND_FROM_EMAIL |
Sending email from the contact form |
CONTACT_EMAIL |
Address that receives contact form messages |
NEXT_PUBLIC_* values are baked into the bundle at build time, so they have to be set where the build runs, not only at runtime.
| Command | What it does |
|---|---|
pnpm dev |
Start the dev server |
pnpm build |
Production Next.js build |
pnpm lint |
Run ESLint |
pnpm sitemap |
Regenerate the sitemaps in public/ from the API |
pnpm cf:build |
Full Cloudflare build: sitemaps, OpenNext worker into .open-next/, _headers |
pnpm preview |
Build and run the worker locally with Wrangler (uses .dev.vars, see .dev.vars.example) |
pnpm deploy |
Build and deploy the Worker from your machine (refuses if the bundle would contain secrets from .env*) |
pnpm upload |
Build and upload a new Worker version without making it live (same secret check) |
dev and build first run scripts/generate-brands.mjs. That script snapshots the icons in public/assets/brands/ into src/shared/data/brands.generated.json, because Cloudflare Workers can't read the filesystem at request time.
src/
app/ Routes (App Router) and API route handlers
api/ Read-only proxies to the content API, plus the contact form endpoint
shared/
components/ UI, layout, background, and icon components
data/ Static site content (profile, experience, FAQ, menus)
extension/ Markdown renderer, theme and progress-bar providers
libs/ API client, constants, email service, brand icons
seo/ styles/ hooks/ interfaces/
public/ Static assets, brand icons, generated sitemaps
scripts/ Build helpers (sitemap, brand snapshot, Cloudflare post-build, dev wrapper)
docs/ Postman collection for the content API
The site is a Cloudflare Worker (pphat-me in wrangler.jsonc), built by OpenNext. Workers Builds deploys it from this repository:
- Build command:
npm run cf:build - Deploy command:
node scripts/check-deploy-env.mjs && npx opennextjs-cloudflare deploy(production, frommaster) - Preview command for other branches:
node scripts/check-deploy-env.mjs && npx opennextjs-cloudflare upload
Never deploy with secrets in .env*. OpenNext copies every .env, .env.local, .env.<mode> and .env.<mode>.local value into the worker bundle. scripts/check-deploy-env.mjs runs before every deploy/upload and refuses when the bundle would contain anything other than NEXT_PUBLIC_*. Keep secrets in Worker secrets (npx wrangler secret put <NAME>).
cf:build regenerates the sitemaps, builds the worker into .open-next/, and writes _headers so static files get the same security headers as pages (scripts/cf-postbuild.mjs).
Caching and images (open-next.config.ts, wrangler.jsonc):
- R2 incremental cache: page and fetch results (
revalidate) are stored in the R2 bucketpphat-me-opennext-cache, with hot entries in Cloudflare's regional cache; a memory queue refreshes them in the background through theWORKER_SELF_REFERENCEbinding. Create the bucket once before the first deploy:npx wrangler r2 bucket create pphat-me-opennext-cache(R2 must be enabled on the account).deployuploads the build-time prerendered pages into it. - Images binding:
next/imageresizes and converts images with Cloudflare Images (IMAGESbinding).
NEXT_PUBLIC_* values are baked in at build time, so set them as build variables. Server-only values (NEXT_PPHAT_API_KEY, RESEND_API_KEY, RESEND_FROM_EMAIL, CONTACT_EMAIL) are Worker secrets.
- Every API proxy route is read-only and validates its URL path segments. The upstream API key is only used on the server.
- Article HTML is sanitized before it is rendered.
- The contact form validates and limits input, escapes it in the email, and is rate limited.
- Security headers are defined in
security-headers.mjsand applied to both pages and static files (via_headers).
© LEAT Sophat. All rights reserved.
