Enhance PySide6-based Visual Editor

Job ID: 39020441

Budget: €30 – €50 EUR

### **Introduction: Current State of the System**
The system is a **graph-based visual editor** built using **PySide6 (Qt for Python)**. It already includes the following:

1. **Core Components**:
- **NgvScene**: Manages nodes, edges, and the undo/redo stack.
- **NgvView**: Handles rendering and user interactions (e.g., zooming).
- **NgvControls**: UI for adding rectangular and elliptical nodes.
- **Nodes**: Rectangular (`NgvRectNode`) and elliptical (`NgvEllipseNode`) nodes with input/output ports.
- **Edges**: Lines connecting nodes (`NgvEdge`).
- **Undo/Redo**: Implemented via commands (`NgvAddNodeCommand`, `NgvAddEdgeCommand`, `NgvMoveNodeCommand`).

2. **Basic Unit Tests**:
- Tests for node/edge creation, movement, and undo/redo are already implemented in `test_ngv_scene.py`.
- Coverage includes basic scenarios like adding nodes, moving them, and creating edges.

---

### **What Needs to Be Done**:
The goal is to **enhance the system** by:
1. **Ensuring encapsulation**: Prevent external access to `_` or `__` attributes.
2. **Expanding unit tests**: Cover edge cases and ensure high test coverage.
3. **Improving undo/redo consistency**: Handle complex scenarios and edge cases.
4. **Adding computation logic**: Implement metaclasses to allow nodes to execute custom logic.

---

### **Deliverable 1: Core System Testing and Encapsulation (Day 1-2)**
- **Goal**: Ensure core components are well-tested and encapsulated.
- **Tasks**:
1. **Review Existing Codebase**:
- Familiarize with `NgvScene`, `NgvView`, `NgvControls`, nodes, edges, and undo/redo commands.
- Leverage existing unittests (`test_ngv_scene.py`) as a starting point.
2. **Refactor for Encapsulation**:
- Ensure no external access to `_` or `__` attributes.
- Use existing methods (e.g., `add_node`, `add_edge`) instead of directly accessing private members.
3. **Expand Unit Tests**:
- Add tests for edge cases:
- Invalid node/edge creation.
- Undo/redo with mixed operations (e.g., add node → move → add edge → undo all).
- Ensure 90%+ test coverage for core components.
- **Outcome**: A fully tested and encapsulated core system.

---

### **Deliverable 2: Undo/Redo Consistency (Day 3)**
- **Goal**: Ensure undo/redo operations are consistent and handle edge cases.
- **Tasks**:
1. **Leverage Existing Unittests**:
- Use `test_ngv_scene.py` as a base for testing undo/redo.
2. **Add Complex Undo/Redo Tests**:
- Test multiple moves, mixed operations, and edge cases.
3. **Fix Inconsistencies**:
- Ensure commands are atomic and reversible.
- Use LLMs to quickly identify and fix issues in the undo/redo logic.
- **Outcome**: Robust undo/redo functionality with no edge case failures.

---

### **Deliverable 3: Metaclass and Computation Logic (Day 4)**
- **Goal**: Implement metaclasses and basic computation logic for nodes.
- **Tasks**:
1. **Define a Metaclass**:
- Use LLMs to generate a metaclass template for nodes.
- Ensure the metaclass allows dynamic computation logic.
2. **Add Basic Computation**:
- Implement a simple computation method (e.g., sum of inputs) to demonstrate extensibility.
3. **Test Computation Logic**:
- Add unit tests for the new computation logic.
- **Outcome**: Nodes can execute custom logic, and the system supports extensibility.

---

### **Key Notes for Freelancers**:
1. **Leverage Existing Codebase**:
- Use the existing unittests (`test_ngv_scene.py`) as a starting point.
- Familiarize with the core components (`NgvScene`, `NgvView`, `NgvControls`, nodes, edges, undo/redo commands).

2. **Use LLMs Effectively**:
- Use LLMs to generate code snippets, refactor code, and write tests.
- Example prompts:
- "Generate a metaclass for `NgvRectNode` to support dynamic computation logic."
- "Write a unittest for undo/redo with mixed operations."

3. **Focus on Testing and Encapsulation**:
- Ensure no direct access to `_` or `__` attributes.
- Expand unittests to cover edge cases and ensure high coverage.

---

### **Timeline Summary**:
- **Day 1-2**: Core system testing and encapsulation.
- **Day 3**: Undo/redo consistency.
- **Day 4**: Metaclass/computation logic.
Related categories: Python Testing / QA Software Testing Qt