How dustland/agentok works
Project type and purpose
• Agentok Studio is a full-stack web application for visually composing agent workflows (AG2-based) with drag-and-drop.
• Frontend is built with Next.js + React, Backend is FastAPI, Database is Supabase, Code generation and execution via AG2.
Focus: the frontend/src/components/flow sub-system
• This folder implements the visual flow editor: nodes, edges, configuration panels, preview, and code-generation integration.
• It uses ReactFlow for diagramming, custom node/edge components, option controls, and communicates with state hooks, service libraries, and API routes.
• FlowEditor (flow-editor.tsx)
• FlowCanvas (flow-canvas.tsx)
• NodeList / NodeButton (node-list.tsx, node-button.tsx)
• Config Panel (flow-config.tsx)
• Preview / JSON view (flow-preview.tsx, flow-json.tsx)
b. Sub-components (lighter green)
• Node components (assistant.tsx, user.tsx, group.tsx, etc.)
• Edge components (converse-edge.tsx, tool-panel.tsx)
• Option controls (select, range, text under flow/option)
• React state & hooks (e.g., useDebounce, flow hooks if any)
• Global store (e.g., Zustand in frontend/src/store/*)
• flow.ts library (frontend/src/lib/flow.ts) – serialization & code-prep
• fetcher.ts hook for HTTP calls
• Next.js API routes (frontend/src/app/api/codegen/*, projects, templates)
• FastAPI service endpoints (/api/codegen/extract, /api/projects, etc.)
• Supabase (auth + DB)
• AG2 execution engine (Docker or local)
1) User drags/drops node or edge → FlowEditor UI
2) UI triggers ReactFlow events → updates React state / store
3) On configuration changes → OptionControls update Flow state → flow.ts serializes to JSON
4) “Preview” / “Generate Code” button → calls Next.js API → forwards to FastAPI /codegen/extract
5) FastAPI uses AG2 to generate Python code → returns code & execution logs → displayed in Preview
6) Saving workflow → UI calls /api/projects via fetcher → Supabase persists JSON
Architectural patterns & principles
• Component-based UI with single-source Flow state
• Separation of concerns:
• Presentation (React + ReactFlow components)
• State & business logic (Zustand store + flow.ts)
• Service layer (fetcher hooks + Next.js API)
• Persistence & compute (Supabase + FastAPI + AG2)
• One-way data flow: UI → State → API → DB/Compute → UI