Context and problem
A portfolio for a solo engineer is itself a technical artefact. If a site claims discipline in performance, accessibility, and system architecture while shipping a heavy client-side bundle or unverified numbers, the medium contradicts the message.
The previous version of this site was a client-rendered React single-page application using Three.js and React Three Fiber. While interactive, it forced every visitor—including search crawlers and AI answer engines—to wait for JavaScript hydration before seeing primary content, relied on external font CDNs, and mixed unverified marketing claims with real engineering work.
The goal of the redesign was straightforward: rebuild the site so that every page renders as clean, static HTML with strict semantic structure, enforces truth rules at compile time, and holds every route under explicit gzipped transfer budgets measured on every build.
Constraints and architectural decisions
Every major choice in this build came with a concrete trade-off. Rather than hiding those trade-offs, here are the four decisions that shaped the architecture.
Decision 1: Astro 7 static output over a React SPA
- Options considered: Keep React + Vite with prerendering, migrate to Next.js static export, or adopt Astro 7 with zero-JS islands.
- Choice: Astro 7 (
output: 'static',build.format: 'file',trailingSlash: 'never'). - Why: Content pages, case studies, and service guides need zero framework runtime in the browser. Astro renders plain HTML at build time and lets interactive pieces—such as the theme toggle, command palette, and filter controls—run as small vanilla TypeScript custom elements (
<x-name>). - Trade-off accepted: Cross-page shared-element transitions rely on native browser
@view-transitionrather than a client-side router. Browsers without cross-document View Transitions fall back to standard navigation without a JavaScript polyfill.
Decision 2: Self-hosted variable fonts with pinned ROND and opsz axes
- Options considered: Load Google Fonts from a CDN, self-host the full Google Sans Flex variable font, or subset and instance the font at build time.
- Choice: Self-host subset WOFF2 files generated with
fonttools, keepingwght(300–800) andwdth(75–100) while pinningRONDandopszat defaults, paired with JetBrains Mono for technical labels. - Why: Keeping all variable axes pushed the main font file to 242 KB, far above our 110 KB site-wide font budget. Pinning
opszandRONDbrought the total font payload (main Latin, rupee symbol face, and JetBrains Mono) down to 92.09 KB gzipped while preserving weight and width axes for typography. - Trade-off accepted: Display headings do not use automatic optical-size adjustments; metric-matched
ArialandConsolasfallbacks are used to minimize layout shift while fonts load.
Decision 3: Computed spring physics instead of hand-guessed easing curves
- Options considered: Hand-authored
cubic-bezier()approximations, a runtime JS spring library on every component, or build-time spring physics sampled into CSSlinear(). - Choice: A build-time TypeScript spring solver (
src/lib/spring-math.ts) that integrates underdamped, critical, and overdamped spring equations (mass = 1) and emits bothsrc/styles/motion.cssandsrc/lib/springs.ts. - Why: CSS
linear()gives real spring overshoot and settling without shipping a physics engine to the browser. Generating both CSS and TS from one source guarantees that CSS transitions and JavaScript animations stay identical, and a unit test fails if the generated files go stale. - Trade-off accepted: Using a single consistent 0.1% settle threshold produces slightly longer settle durations than rough spec estimates (for example,
snappysettles in 460 ms rather than ~300 ms).
Decision 4: Build-time truth rules and post-build HTML verification
- Options considered: Manual QA checklists before deploy, or automated build gates that inspect the generated
dist/output. - Choice: Zod content schemas plus four Node scripts (
check-content.mjs,check-links.mjs,validate-schema.mjs,size-budget.mjs) wired directly intonpm run build. - Why: Rules that are not automated eventually slip. The Zod schemas reject testimonials without
consent: true, reject metrics that lack a measurement method and ISO date, and reject unknown topic IDs. After Astro writesdist/, the post-build scripts parse every HTML file withparse5to verify heading counts, meta lengths, internal links, redirect chains, JSON-LD@idgraph resolution, and gzipped transfer sizes. - Trade-off accepted: Adding a new case study or service takes longer upfront because every page must clear word minimums, answer-summary limits, and schema checks before the build succeeds.
System architecture
The site is organized into three layers:
- Typed facts & content collections (
src/data/,src/content/):identity.tsserves as the single source of truth for entity facts, bios, and availability. Every JSON-LD graph, meta tag,llms.txtfile, and bio block reads from this registry so external search engines and AI systems see one consistent entity. - Design tokens & capability detection (
src/styles/,src/lib/capability.ts): Four color modes (light, dark, theatre, and blueprint) are expressed purely through CSS custom properties with computed WCAG contrast pairs. Before the stylesheet loads, a 352-byte inline head script setsdata-motion(full,lite, orstatic),data-theme, anddata-modeon<html>so there is no flash of wrong theme or motion tier. - Post-build audit pipeline (
scripts/): Everynpm run buildgeneratessrc/data/site-stats.jsondirectly from the gzipped assets indist/, ensuring the numbers shown on the site reflect the actual latest build rather than stale manual estimates.
Here is the core spring-sampling check that keeps generated CSS and TypeScript tokens synchronized:
export type MotionTier = 'static' | 'lite' | 'full';
export function detectTier(env: CapabilityEnv): MotionTier {
if (env.reducedMotion) return 'static';
if (env.saveData) return 'lite';
if (env.cores !== undefined && env.cores < 4) return 'lite';
if (env.memoryGB !== undefined && env.memoryGB < 4) return 'lite';
if (!env.webgl2) return 'lite';
return 'full';
}What the build measures today
Because site-stats.json is regenerated on every build, the site reports its own measured footprint directly:
- Home route gzipped transfer: 164.91 KB total (28.96 KB HTML, 24.35 KB CSS, 19.51 KB JS, 92.09 KB site-wide fonts).
- Content budget targets: ≤ 50 KB HTML, ≤ 30 KB CSS, ≤ 15 KB JS on standard content pages; ≤ 80 KB HTML, ≤ 35 KB CSS, ≤ 70 KB JS on heavy interactive pages.
- OG social cards: Rendered at build time via Satori and
@resvg/resvg-jsinto static PNGs capped at 120 KB each. - Automated unit tests: Verified with the native Node 22 test runner covering spring math, capability detection across all 128 hardware/preference combinations, pricing and the lead form’s data checks.
What comes next
The foundation and core pages are designed to grow incrementally. Next steps include adding interactive scroll-driven motion scenes gated to the full capability tier, completing owner-verified metrics for client case studies so they can move from draft to published, and running real-device Lighthouse and axe audits across light, dark, and blueprint modes.
Build-time OG cards, accessibility, and truth rules
Several smaller engineering details keep the site honest and maintainable over time:
- Build-time OG image generation: Rather than maintaining static PNGs by hand or running a headless browser in CI, social preview cards are rendered at build time using Satori and
@resvg/resvg-jswith a static OFL Google Sans Flex WOFF font. Each generated PNG is checked against a 120 KB ceiling so social cards never bloat the repository or CDN cache. - Computed WCAG contrast pairs: Every surface and text token across light, dark, theatre, and blueprint modes was checked against WCAG AA contrast formulas. Where the brand emerald accent (
#10B981) fell below 3:1 on white for non-text focus indicators, a dedicated--focustoken (accent-inkat 5.48:1 in light mode) was introduced so keyboard focus rings remain clearly visible in every mode. - Zero-placeholder enforcement: Content schemas reject testimonials without explicit
consent: trueand reject metrics that lack a repeatable measurement method and ISO date. Until real measurements and owner-reviewed facts are supplied for client case studies, those entries remain indraftstatus rather than shipping estimated numbers. - Progressive enhancement for interactive islands: Navigation menus, theme and blueprint toggles, the command palette, and work filters are built as small custom elements (
<x-name>) that enhance static semantic HTML. With JavaScript disabled, every page, link, FAQ accordion, and email fallback continues to work cleanly. - View Transitions without framework lock-in: Cross-document View Transitions provide subtle 300 ms crossfade and 12 px rise animations between pages in supporting browsers, while circular reveal wipes on the theme and blueprint toggles respect
prefers-reduced-motionand thestaticcapability tier unconditionally.
Lessons from treating a portfolio like production software
Applying strict budgets and automated truth checks to a personal site surfaced edge cases early—such as variable font axis weight (opsz alone adding nearly 100 KB), Satori absolute-positioning quirks, and focus-ring contrast limits on light surfaces. Catching those in build scripts rather than manual spot-checks means every future article, service, or case study inherits the same engineering floor automatically.








