graph TD
A[Start Process] --> B[Input: Amazon/Etsy URL]
%% Data Extraction Subagent
B --> C[Extract Listing Data]
C --> D[Parse Title]
C --> E[Parse Bullet Points]
C --> F[Parse Description]
C --> G[Get Main Image URL]
%% Analysis Subagent
D & E & F --> H[Keyword Analysis]
G --> I[Image Analysis]
H --> J[Trademark Check API]
I --> K[Vision API Analysis]
J --> L[Filter Safe Keywords]
K --> M[Generate Design Description]
%% Design Generation Subagent
L & M --> N[Create Image Prompt]
N --> O[Ideogram API Call]
O --> P[Background Removal API]
P --> Q[Image Upscaler API]
Q --> R[Format Check 4500x5400 300DPI]
%% Listing Creation Subagent
L --> S[Generate New Title]
L --> T[Generate New Bullets]
L --> U[Generate New Description]
S & T & U --> V[Format Text Files]
%% Final Output
R --> W[Package Design Files]
V --> X[Package Listing Text]
W & X --> Y[Create ZIP Package]
Y --> Z[End Process]
%% API Usage Tracking
B --> AA[Start API Counter]
J & K & O & P & Q --> AB[Log API Usage]
AB --> AC[Generate Monthly Report]
%% Error Handling
C -- Error --> AD[URL Error Handler]
O -- Error --> AE[Design Generation Error]
J -- Error --> AF[Trademark Check Error]
AD & AE & AF --> AG[Error Report]