Architecture Note: AI-powered React component generator with live preview, virtual file system, and iterative refinement through conversational UI.
%%{init: {'theme': 'dark', 'themeVariables': { 'primaryColor': '#C17852', 'primaryTextColor': '#F0F6FC', 'primaryBorderColor': '#4A5E32', 'lineColor': '#E6C98F', 'secondaryColor': '#161B22', 'tertiaryColor': '#0D1117', 'background': '#0D1117', 'mainBkg': '#161B22', 'nodeBorder': '#4A5E32', 'clusterBkg': '#161B22', 'clusterBorder': '#4A5E32', 'titleColor': '#E6C98F', 'edgeLabelBackground': '#161B22'}}}%%
flowchart LR
subgraph Input["π₯ User Request"]
UR["π¬ Component Description"]
REF["πΈ Reference Image"]
end
subgraph Process["βοΈ AI Processing"]
SP["π System Prompt
React + Tailwind Expert"]
CL["π€ Claude AI
Anthropic API"]
ST["π‘ Streaming Response"]
end
subgraph Parse["π§ Code Extraction"]
PE["π¦ Parse TSX Blocks"]
VL["β
Validate Syntax"]
end
subgraph Output["π€ Generated Code"]
RC["βοΈ React Component"]
TW["π¨ Tailwind Styles"]
TS["π TypeScript Types"]
end
UR --> SP
REF --> SP
SP --> CL
CL --> ST
ST --> PE
PE --> VL
VL --> RC
VL --> TW
VL --> TS
%%{init: {'theme': 'dark', 'themeVariables': { 'primaryColor': '#C17852', 'primaryTextColor': '#F0F6FC', 'primaryBorderColor': '#4A5E32', 'lineColor': '#E6C98F', 'secondaryColor': '#161B22', 'tertiaryColor': '#0D1117', 'background': '#0D1117', 'mainBkg': '#161B22', 'nodeBorder': '#4A5E32', 'clusterBkg': '#161B22', 'clusterBorder': '#4A5E32', 'titleColor': '#E6C98F', 'edgeLabelBackground': '#161B22'}}}%%
flowchart TB
subgraph Generate["π€ AI Generation"]
AI["π€ Claude Response"]
CODE["π Generated TSX"]
end
subgraph VFS["π Virtual File System"]
MAP[("πΊοΈ File Map
In-Memory")]
IDX["π File Index"]
VER["π’ Version Control"]
end
subgraph Files["π Virtual Files"]
COMP["βοΈ components/*.tsx"]
UTIL["π§ utils/*.ts"]
STYLE["π¨ styles/*.css"]
end
subgraph Preview["β‘ Preview Engine"]
SAND["π¦ Sandpack"]
HOT["π₯ Hot Reload"]
end
AI --> CODE
CODE --> MAP
MAP --> IDX
MAP --> VER
IDX --> COMP
IDX --> UTIL
IDX --> STYLE
COMP --> SAND
UTIL --> SAND
STYLE --> SAND
SAND --> HOT
%%{init: {'theme': 'dark', 'themeVariables': { 'primaryColor': '#C17852', 'primaryTextColor': '#F0F6FC', 'primaryBorderColor': '#4A5E32', 'lineColor': '#E6C98F', 'secondaryColor': '#161B22', 'tertiaryColor': '#0D1117', 'background': '#0D1117', 'mainBkg': '#161B22', 'nodeBorder': '#4A5E32', 'clusterBkg': '#161B22', 'clusterBorder': '#4A5E32', 'titleColor': '#E6C98F', 'edgeLabelBackground': '#161B22'}}}%%
flowchart TB
subgraph User["π€ User Interface"]
MSG["π¬ Chat Message"]
IMG["πΈ Image Upload"]
end
subgraph Chat["π¬ Chat Engine"]
HIS[("πΎ Chat History")]
CTX["π Context Builder"]
end
subgraph AI["π€ Vercel AI SDK"]
STR["π‘ useChat Hook"]
CL["π§ Claude API"]
TOK["π Token Stream"]
end
subgraph Render["π₯οΈ UI Render"]
MD["π Markdown Parser"]
CB["π¦ Code Blocks"]
PRV["β‘ Live Preview"]
end
MSG --> HIS
IMG --> HIS
HIS --> CTX
CTX --> STR
STR --> CL
CL --> TOK
TOK --> MD
MD --> CB
CB --> PRV
%%{init: {'theme': 'dark', 'themeVariables': { 'primaryColor': '#C17852', 'primaryTextColor': '#F0F6FC', 'primaryBorderColor': '#4A5E32', 'lineColor': '#E6C98F', 'secondaryColor': '#161B22', 'tertiaryColor': '#0D1117', 'background': '#0D1117', 'mainBkg': '#161B22', 'nodeBorder': '#4A5E32', 'clusterBkg': '#161B22', 'clusterBorder': '#4A5E32', 'titleColor': '#E6C98F', 'edgeLabelBackground': '#161B22'}}}%%
flowchart LR
subgraph Code["π Generated Code"]
TSX["βοΈ Component TSX"]
CSS["π¨ Tailwind Classes"]
end
subgraph Bundle["π¦ Bundler"]
ESB["β‘ ESBuild/SWC"]
DEP["π Resolve Deps"]
end
subgraph Sandbox["ποΈ Sandpack Runtime"]
IF["π iframe Sandbox"]
RC["βοΈ React Runtime"]
TW["π¨ Tailwind CDN"]
end
subgraph Display["π₯οΈ Preview"]
RND["π― Rendered UI"]
ERR["β οΈ Error Boundary"]
ACT["π±οΈ Interactive"]
end
TSX --> ESB
CSS --> ESB
ESB --> DEP
DEP --> IF
IF --> RC
IF --> TW
RC --> RND
RC --> ERR
RND --> ACT
%%{init: {'theme': 'dark', 'themeVariables': { 'primaryColor': '#C17852', 'primaryTextColor': '#F0F6FC', 'primaryBorderColor': '#4A5E32', 'lineColor': '#E6C98F', 'secondaryColor': '#161B22', 'tertiaryColor': '#0D1117', 'background': '#0D1117', 'mainBkg': '#161B22', 'nodeBorder': '#4A5E32', 'clusterBkg': '#161B22', 'clusterBorder': '#4A5E32', 'titleColor': '#E6C98F', 'edgeLabelBackground': '#161B22'}}}%%
flowchart TB
subgraph Initial["π₯ Initial Request"]
REQ["π¬ Create component"]
end
subgraph Generate["π€ Generation"]
GEN["π§ Claude generates"]
V1["π¦ Version 1"]
end
subgraph Preview["β‘ Preview"]
PRV["π₯οΈ Live Preview"]
CHK{"β
Satisfied?"}
end
subgraph Refine["π Refinement"]
FB["π¬ User Feedback"]
CTX["π Context + History"]
UPD["π§ Update Code"]
end
subgraph Final["π€ Output"]
EXP["π¦ Export Code"]
DL["β¬οΈ Download"]
end
REQ --> GEN
GEN --> V1
V1 --> PRV
PRV --> CHK
CHK -->|"No"| FB
FB --> CTX
CTX --> UPD
UPD --> PRV
CHK -->|"Yes"| EXP
EXP --> DL
%%{init: {'theme': 'dark', 'themeVariables': { 'primaryColor': '#C17852', 'primaryTextColor': '#F0F6FC', 'primaryBorderColor': '#4A5E32', 'lineColor': '#E6C98F', 'secondaryColor': '#161B22', 'tertiaryColor': '#0D1117', 'background': '#0D1117', 'mainBkg': '#161B22', 'nodeBorder': '#4A5E32', 'clusterBkg': '#161B22', 'clusterBorder': '#4A5E32', 'titleColor': '#E6C98F', 'edgeLabelBackground': '#161B22'}}}%%
flowchart TB
subgraph Client["π₯οΈ Next.js Frontend"]
UI["π¬ Chat UI"]
PV["β‘ Preview Panel"]
ED["π Code Editor"]
end
subgraph API["π API Routes"]
CH["π¬ /api/chat"]
GN["π€ /api/generate"]
end
subgraph AI["π§ AI Layer"]
VER["π¦ Vercel AI SDK"]
CL["π€ Claude API
Anthropic"]
end
subgraph State["πΎ State Management"]
VFS[("π Virtual FS")]
HIST[("π¬ Chat History")]
end
subgraph Preview["ποΈ Sandpack"]
SB["π¦ Sandbox Runtime"]
HMR["π₯ Hot Module Reload"]
end
UI <--> CH
UI --> GN
CH --> VER
GN --> VER
VER <--> CL
VER --> VFS
CH --> HIST
VFS --> SB
SB --> HMR
HMR --> PV
VFS --> ED