joestein.dev

build story

Colophon · Grounded AI & Agentic CMS Architecture

How joestein.dev Was Built

How a prompt-first, grounded AI engineering portfolio was architected, modeled, tested, and styled—and the delivery workflow behind it.

1. Product Philosophy: Prompt-First, Dual-Mode & Beyond the Resume

A chronological resume is useful for scanning, but it often hides the implementation decisions behind an achievement. A conversational portfolio can expose that depth while introducing different risks: invented facts, first-person impersonation, and an interface that makes visitors work too hard to find evidence.

joestein.dev starts with a question and supports a traditional overview, while keeping its engineering evidence in a normalized Sanity content graph.

2. Phase 1 & 1.5: Semantic Core, Sanity CMS & Direct Context Grounding

The first functional prototype deliberately used browser-default semantic HTML before custom typography and visual layout. Small disposable wireframe styles were introduced during iteration; the principle was to settle content, interaction, and reading order before designing a theme. Semantic elements and explicit data-slot contracts became the stable foundation for the later visual layer.

Normalized Career & Project Graph

The portfolio uses four core document types: technology, role, project, and an about singleton. Achievements live inside roles, with stable _key identifiers, track tags, technology references, and includeInDefaultOverview flags. Projects reference the same technology catalog. About owns the introduction, story, contact details, resume assets, and editor-curated starter questions. A reusable page type now stores this colophon as Portable Text.

Flat Evidence Catalog, ID-Pointer Hydration & Bounded Completion

Gemini sees a flat catalog of selectable achievement keys and project IDs. Role summaries supply background without exposing role IDs as selectable evidence. Ambiguous identifiers are excluded from the catalog.

Published content, grounded generation, and server-hydrated receipts
Diagram source
flowchart TD
    subgraph CMS["Sanity Content Lake: published content"]
        ROLES["Roles and achievement keys"]
        PROJECTS["Projects and project IDs"]
        TECH["Canonical technology references"]
        ABOUT["About, downloads and editorial starters"]
        PAGE["Colophon prose and technical blocks"]
    end
    subgraph SERVER["Next.js App Router: /api/chat"]
        GROQ["Fresh GROQ projection: no CDN or TTL"]
        CATALOG["Flat selectable evidence catalog"]
        HISTORY["Validated question and text-only history"]
        LLM["Gemini: quota fallback only before output"]
        TOOLS["Zod arguments and server ID hydration"]
        TURN["At most two generation steps: shared 50-second deadline"]
    end
    subgraph UI["Semantic UI and presentation tokens"]
        SUMMARY["Leading summary paragraph"]
        CARDS["Zero to three ranked receipt cards"]
        TOPICS["Flat starter and contextual suggestions"]
    end
    ROLES --> GROQ
    PROJECTS --> GROQ
    TECH --> GROQ
    ABOUT --> GROQ
    PAGE --> GROQ
    GROQ --> CATALOG
    GROQ --> LLM
    UI -->|"Question and conversation"| HISTORY
    HISTORY --> LLM
    CATALOG --> LLM
    LLM -->|"IDs, vignettes and tool arguments"| TOOLS
    LLM -->|"Prose"| TURN
    TOOLS --> TURN
    TURN --> SUMMARY
    TURN --> CARDS
    TURN --> TOPICS

LLM Guardrails and Deterministic Validation of Model Outputs

Client-supplied tool outputs are not trusted as portfolio facts. The server validates incoming messages, forwards only text history, and loads fresh authoritative content before each answer. Conversation context helps with meaning; the interface does not promise citation-style references to earlier receipt numbers.

Invalid or incomplete core output is disclosed. Optional follow-up navigation can fail independently without spoiling a complete answer. A receipt remains useful without a match reason; in that case the UI keeps the score and vignette and omits the reasoning disclosure.

The implementation intentionally stops short of claim-by-claim verification, externally calibrated relevance scores, adversarial certification, or approval gates appropriate to a consequential workflow. For this portfolio, the goal is useful live exploration with clear evidence boundaries and recoverable failures. A mission-critical product would need stronger domain-specific evaluation, monitoring, and potentially human approval.

3. Phase 2.0: Prompt-First UX & White-Label Design Tokens

The visual layer was developed from a working HTML/CSS reference mock after the core interaction model had settled. Automated DOM, schema-boundary, geometry, and AI SDK stream tests protect behavior independently of the theme; builds, lint, TypeGen, and TypeScript checks complement those tests. Passing them is not a substitute for browser or accessibility review.

Helping Visitors Ask Useful Questions

Separate Conversation State from Request Status

The shell exposes data-conversation-state="idle|active" independently of data-request-state.

Independent conversation state and request status
Diagram source
stateDiagram-v2
    state Portfolio {
        state Conversation {
            [*] --> Idle
            Idle --> Active: User message added
            Active --> Active: Another question or retry
            Active --> Idle: Reset conversation
            Idle: Editorial invitation and starter prompts
            Active: Same composer in bottom command deck
        }
        --
        state Request {
            [*] --> Ready
            Ready --> Submitted: Submit question
            Submitted --> Streaming: Provider output starts
            Submitted --> Error: Request fails
            Streaming --> Streaming: Optional bounded core completion
            Streaming --> Ready: Turn finishes
            Streaming --> Error: Incomplete or failed turn
            Error --> Submitted: Explicit retry or new question
            Submitted: Ticker and visible progress status
            Streaming: Prose cursor and persistent progress status
        }
    }

Visual System & Accessibility Invariants

4. Agentic Engineering Workflow

The delivery process joined conversational product framing, a working reference mock, scoped implementation requests to OpenAI Codex, and iterative review of behavior and diffs. Sanity MCP and its best-practices skill supplied concrete content-modeling and ingestion capabilities; agents were implementation teammates rather than an excuse to accept generated code without architectural scrutiny.

Phase 2.6: Shared Behavior, Explicit Context, Editable Language

The header and footer evolved independently through user testing. Their presentation still serves different purposes, but both had begun owning the same mode names, destinations, and switching behavior. Joe used that duplication as the boundary for a small iteration: share mode behavior while keeping each placement independently themeable.

The shared ModeControl receives its current mode, optional transition callback, editorial labels, and header or footer placement through props. It does not inspect the DOM, infer context from the route, or fetch its own configuration. Semantic HTML and data-slot/data-placement hooks expose structure to themes; idle and active remain separate conversation facts. On the portfolio it switches local state; on editorial pages it renders ordinary destination links. The footer offers alternatives rather than assuming a binary next mode. Modes remain exclusive views of the portfolio; a page or an MCP interface is not automatically another mode.

A Sanity Site Settings singleton owns shared brand wording, mode labels, navigation copy, prompt invitation and composer copy, and editorial starter questions. Stable mode IDs, supported behavior, routes, provider secrets, and theme geometry remain application-owned. Renaming Prompt to Ask Joe changes language without changing capability. Starter questions were copied from About with their original array keys, strings, and order preserved. The old About field remains hidden and read-only for compatibility and rollback, while the new runtime reads only Site Settings. Missing UI copy has deterministic defaults, but missing starter questions never trigger fabricated prompts or cached AI answers.

This is an incremental white-label foundation rather than a generic site builder. Shared behavior does not require identical presentation, and editorial control does not grant configuration the power to invent application behavior. Regression checks cover renamed labels against stable IDs and routes, header/footer representations, callback-based switching, standalone page links, safe copy defaults, and starter-question order and identity.