Components / Prompt Builders

Prompt Chain Builder

A visual chain builder for creating multi-step AI prompt workflows with drag-and-drop step reordering.

Live Preview — prompt-chain-builder-01

Step Chaining

Sequential Logic Graph

Step 1
Llama-3

Extraction Phase

Parse unstructured PDF data into schema

Step 2
GPT-4o

Validation Phase

Check for hallucination and PII leaks

Step 3
Claude 3.5

Synthesis Phase

Generate final executive summary


Installation

Dependencies

Install the core libraries required for this component.

npm
npm install react lucide-react

Source Code

prompt-chain-builder-01.tsx
"use client";

import React from "react";
import { GitGraph, ArrowDown, Settings, Bot, Sparkles, Database, Search } from "lucide-react";
import { cn } from "@/lib/utils";

const chainSteps = [
    {
        id: "1",
        label: "Extraction",
        actor: "Llama-3",
        icon: <Database className="h-4 w-4" />,
        color: "border-blue-500",
        desc: "Parse unstructured PDF data into schema"
    },
    {
        id: "2",
        label: "Validation",
        actor: "GPT-4o",
        icon: <Search className="h-4 w-4" />,
        color: "border-violet-500",
        desc: "Check for hallucination and PII leaks"
    },
    {
        id: "3",
        label: "Synthesis",
        actor: "Claude 3.5",
        icon: <Sparkles className="h-4 w-4" />,
        color: "border-emerald-500",
        desc: "Generate final executive summary"
    },
];

export default function PromptChainBuilder() {
    return (
        <div className="rounded-[32px] border border-zinc-200 dark:border-zinc-800 bg-white dark:bg-zinc-950 p-8 shadow-2xl w-full max-w-md mx-auto relative overflow-hidden">
            {/* Background Decor */}
            <div className="absolute top-0 right-0 h-32 w-32 bg-indigo-500/5 rounded-full blur-3xl" />

            <div className="flex items-center justify-between mb-10 relative z-10">
                <div className="flex items-center gap-3">
                    <div className="p-2 rounded-xl bg-zinc-100 dark:bg-zinc-800">
                        <GitGraph className="h-5 w-5 text-zinc-600 dark:text-zinc-400" />
                    </div>
                    <div>
                        <h3 className="text-sm font-bold text-zinc-900 dark:text-zinc-100">Step Chaining</h3>
                        <p className="text-[10px] text-zinc-500 font-medium">Sequential Logic Graph</p>
                    </div>
                </div>
                <button className="p-2 rounded-xl border border-zinc-100 dark:border-zinc-800 hover:bg-zinc-50 transition-colors">
                    <Settings className="h-4 w-4 text-zinc-400" />
                </button>
            </div>

            <div className="flex flex-col items-center space-y-4 relative z-10">
                {chainSteps.map((s, i) => (
                    <React.Fragment key={s.id}>
                        <div className={cn(
                            "w-full p-5 rounded-2xl bg-zinc-50 dark:bg-zinc-900 border-l-[6px] transition-all hover:scale-[1.03] active:scale-95 cursor-pointer shadow-sm group",
                            s.color
                        )}>
                            <div className="flex items-center justify-between mb-3">
                                <div className="flex items-center gap-2">
                                    <div className="p-1.5 rounded-lg bg-white dark:bg-zinc-800 shadow-sm transition-colors group-hover:text-indigo-500">
                                        {s.icon}
                                    </div>
                                    <span className="text-[10px] font-black text-zinc-400 uppercase tracking-widest">Step {i + 1}</span>
                                </div>
                                <div className="flex items-center gap-1.5 px-2 py-0.5 rounded-full bg-zinc-200/50 dark:bg-zinc-800 text-[9px] font-bold text-zinc-500">
                                    <Bot className="h-2.5 w-2.5" />
                                    {s.actor}
                                </div>
                            </div>
                            <h4 className="text-sm font-bold text-zinc-900 dark:text-zinc-100 mb-1">{s.label} Phase</h4>
                            <p className="text-[11px] text-zinc-500 leading-relaxed">{s.desc}</p>
                        </div>
                        {i < chainSteps.length - 1 && (
                            <div className="h-10 flex items-center justify-center relative scale-110">
                                <div className="h-full w-[2px] bg-gradient-to-b from-zinc-200 to-zinc-100 dark:from-zinc-800 dark:to-zinc-900" />
                                <div className="absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 p-1 rounded-full bg-white dark:bg-zinc-950 border border-zinc-200 dark:border-zinc-800 shadow-sm animate-pulse">
                                    <ArrowDown className="h-3 w-3 text-zinc-400" />
                                </div>
                            </div>
                        )}
                    </React.Fragment>
                ))}
            </div>

            <div className="mt-8 pt-6 border-t border-zinc-100 dark:border-zinc-800">
                <button className="w-full flex items-center justify-center gap-2 py-3 rounded-2xl bg-indigo-600 text-white text-[11px] font-black uppercase tracking-widest hover:bg-indigo-700 transition-all shadow-xl shadow-indigo-500/20 active:scale-[0.98]">
                    Compile Chain
                    <Sparkles className="h-3.5 w-3.5" />
                </button>
            </div>
        </div>
    );
}

Functional Logic

Internal functions used to handle component logic.

Function Parameters
PromptChainBuilder() None

Variables

All variable declarations found in this component.

Name Kind Value
chainSteps const [

JSX Tags Usage

Every JSX/HTML tag used in this component, with usage count and source.

Tag Count Type Source
<ArrowDown> Library lucide-react
<Bot> Library lucide-react
<Database> Library lucide-react
<GitGraph> Library lucide-react
<React.Fragment> Library react
<Settings> Library lucide-react
<Sparkles> Library lucide-react
<button> Native Native HTML
<div> 16× Native Native HTML
<h3> Native Native HTML
<h4> Native Native HTML
<p> Native Native HTML
<Search> Native Native HTML
<span> Native Native HTML

Related Components

  • Prompt Template Editor — A rich text editor for creating and editing AI prompt templates with variable placeholders and syntax highlighting.
  • Prompt Variable Insert — An inline variable insertion widget that lets users define and insert dynamic placeholders into AI prompt templates.
  • Prompt Expert Mode — A power-user interface for fine-tuning prompt parameters and direct model interaction.
  • Prompt Test Bench — A split-panel interface for testing AI prompts with real-time input and simulated output comparison.
  • Prompt Version Diff — A version comparison tool showing prompt iterations with visual diff highlighting and restore functionality.
  • Prompt Optimizer — An AI-powered prompt refinement tool that suggests improvements for better model performance.