@@ -9,8 +9,15 @@ App (src/app.tsx)
99├── Router → Dashboard | AutomationBuilder | Credentials
1010│
1111├── Dashboard (src/components/Dashboard.tsx)
12- │ └── Lists all automations
13- │ └── Edit/Delete/Export actions
12+ │ ├── Tabs: "Your Automations" | "Examples"
13+ │ │
14+ │ ├── YourAutomations (src/components/dashboard/YourAutomations.tsx)
15+ │ │ └── Lists user's automations
16+ │ │ └── Edit/Delete/Export actions
17+ │ │
18+ │ └── Examples (src/components/dashboard/Examples.tsx)
19+ │ └── Lists 7 example automations
20+ │ └── "Load Example" button for each
1421│
1522└── AutomationBuilder (src/components/AutomationBuilder.tsx)
1623 ├── BuilderHeader
@@ -63,23 +70,76 @@ const [currentAutomation, setCurrentAutomation] = useState<Automation>();
6370
6471#### Dashboard.tsx (src/components/Dashboard.tsx)
6572
66- List and manage automations .
73+ Container component managing automation list and examples with tab navigation .
6774
6875** Props:**
6976``` typescript
7077interface DashboardProps {
71- automations: Automation [];
72- onEdit : (automation : Automation ) => void ;
73- onDelete : (id : string ) => void ;
74- onNew : () => void ;
78+ automations: StoredAutomation [];
79+ onCreateAutomation : () => void ;
80+ onEditAutomation : (automation : StoredAutomation ) => void ;
81+ onUpdateAutomations : (automations : StoredAutomation [] ) => void ;
7582}
7683```
7784
7885** Features:**
79- - List all automations
86+ - Two-tab interface: "Your Automations" and "Examples"
87+ - Import automation from JSON file
88+ - Load example automations from ` docs/examples/ ` folder (via IPC)
89+ - Delete automation with file system cleanup (via IPC)
90+ - Switches to "Your Automations" tab after import/load
91+
92+ ** Key Methods:**
93+ - ` handleImportAutomation() ` - Import automation JSON file
94+ - ` handleLoadExample(example) ` - Load example via ` tree.loadExample() ` IPC
95+ - ` handleDeleteAutomation(automationId) ` - Delete via ` tree.delete() ` IPC, removes file from disk
96+
97+ #### YourAutomations.tsx (src/components/dashboard/YourAutomations.tsx)
98+
99+ Tab component displaying user's saved automations.
100+
101+ ** Props:**
102+ ``` typescript
103+ interface YourAutomationsProps {
104+ automations: StoredAutomation [];
105+ totalAutomations: number ;
106+ onEditAutomation: (automation : StoredAutomation ) => void ;
107+ onDeleteAutomation: (automationId : string ) => Promise <void >;
108+ }
109+ ```
110+
111+ ** Features:**
112+ - Card-based grid layout
113+ - Shows automation name, description, last update time
80114- Edit button → open in builder
81- - Delete button → confirm and remove
82- - New Automation button → create new
115+ - Delete button (Trash2 icon) → confirmation dialog → IPC delete
116+ - Empty state when no automations exist
117+
118+ ** Key Methods:**
119+ - ` handleDelete(automationId) ` - Shows confirmation dialog, calls async delete callback
120+
121+ #### Examples.tsx (src/components/dashboard/Examples.tsx)
122+
123+ Tab component displaying example automations for user learning.
124+
125+ ** Props:**
126+ ``` typescript
127+ interface ExamplesProps {
128+ automations: StoredAutomation [];
129+ onLoadExample: (example ) => Promise <void >;
130+ }
131+ ```
132+
133+ ** Features:**
134+ - Grid layout with 7 curated example automations
135+ - Examples: Google Search, Contact Form, E-commerce Price Monitor, GitHub API, Hacker News, Multi-Page Scraper, Pagination Loop
136+ - "Load Example" button for each example
137+ - Creates new automation from example data
138+ - Hover shadow effect for interactivity
139+
140+ ** Example Data Source:**
141+ - Loaded from ` docs/examples/*.json ` via IPC handler ` loopi:loadExample `
142+ - Files read by main process for security (no direct renderer file access)
83143
84144#### AutomationBuilder.tsx (src/components/AutomationBuilder.tsx)
85145
@@ -289,6 +349,98 @@ const executeGraph = async (nodeId) => {
289349};
290350```
291351
352+ ## Storage & Backend
353+
354+ ### TreeStore (src/main/treeStore.ts)
355+
356+ File system layer for automation persistence.
357+
358+ ** Key Functions:**
359+ ``` typescript
360+ // List all saved automations
361+ listAutomations (folder : string ): StoredAutomation []
362+
363+ // Load specific automation by ID
364+ loadAutomation (id : string , folder : string ): StoredAutomation | null
365+
366+ // Save/update automation to disk
367+ saveAutomation (automation : StoredAutomation , folder : string ): string
368+
369+ // Delete automation file permanently
370+ deleteAutomation (id : string , folder : string ): boolean
371+
372+ // Load example from docs/examples folder
373+ loadExample (fileName : string ): StoredAutomation
374+ ```
375+
376+ ** Storage Location:**
377+ - User automations: ` ~/.config/[AppName]/.trees/tree_[automationId].json `
378+ - Examples (read-only): ` docs/examples/*.json `
379+ - File format: JSON with StoredAutomation schema
380+
381+ ** Example:**
382+ ``` typescript
383+ {
384+ " id" : " 1734000000000" ,
385+ " name" : " Google Search Automation" ,
386+ " description" : " Search Google and take screenshot" ,
387+ " createdAt" : " 2024-12-12 10:00:00" ,
388+ " updatedAt" : " 2024-12-12 10:30:00" ,
389+ " flow" : { nodes: [... ], edges: [... ] }
390+ }
391+ ```
392+
393+ ### IPC Bridge (src/preload.ts)
394+
395+ Exposes secure API to renderer process.
396+
397+ ** Available Methods:**
398+ ``` typescript
399+ window .electronAPI .tree = {
400+ list(): Promise <StoredAutomation []>
401+ load(): Promise <StoredAutomation | null >
402+ save(automation : StoredAutomation ): Promise <string >
403+ loadExample(fileName : string ): Promise <StoredAutomation >
404+ delete(automationId : string ): Promise <boolean >
405+ }
406+ ```
407+
408+ ** Security Model:**
409+ - Renderer cannot access filesystem directly
410+ - All file I/O routed through main process
411+ - Context isolation prevents direct Node.js access
412+ - Preload script acts as secure gateway
413+
414+ ### IPC Handlers (src/main/ipcHandlers.ts)
415+
416+ Routes IPC messages to appropriate services.
417+
418+ ** Automation Handlers:**
419+ - ` loopi:listTrees ` → TreeStore.listAutomations()
420+ - ` loopi:loadTrees ` → TreeStore.loadAutomation()
421+ - ` loopi:saveTree ` → TreeStore.saveAutomation()
422+ - ` loopi:loadExample ` → TreeStore.loadExample()
423+ - ` loopi:deleteTree ` → TreeStore.deleteAutomation()
424+
425+ ** Type Definitions (src/types/globals.d.ts):**
426+ ``` typescript
427+ interface ElectronAPI {
428+ tree: {
429+ list: () => Promise <StoredAutomation []>;
430+ load: () => Promise <StoredAutomation | null >;
431+ save: (automation : StoredAutomation ) => Promise <string >;
432+ loadExample: (fileName : string ) => Promise <StoredAutomation >;
433+ delete: (automationId : string ) => Promise <boolean >;
434+ };
435+ }
436+
437+ declare global {
438+ interface Window {
439+ electronAPI: ElectronAPI ;
440+ }
441+ }
442+ ```
443+
292444### UI Component Patterns
293445
294446#### Form Fields
0 commit comments