Closed ChTiSh closed 3 months ago
This has been discussed with Chen, Kinski, Jordan, and Colin, and I feel we're in agreement to commit to the below strategy until further notice.
The short-term solution will be Bulk Update Approach (Single Endpoint).
In addition to allowing for a simpler API, this approach allows for simpler edit logic and state management in the client.
A good way to avoid session data loss will be to implement AutoSave, e.g.: If there have been no edits for five seconds, Save.
It is unclear just how many nodes and how much metadata will be transmitted, or at what point data volume becomes problematic. Let's start simple and adapt if necessary.
Objective: Develop the backend logic and algorithms necessary to store and update the tree in the testing MongoDB database. Assumption: Zustand store can hold info for all tree nodes and edges, which will be sent when user click "save" button to backend API Assumption: The data structure of Gemini generated JSON file (Initial tree) would be different from what backend received from the Zustand store (User edited tree)
Project Scope: Create Sample Data: - 2 hours Create Sample Node.ts and Edge.ts with min. 30 nodes and corresponding edges, assuming received from frontend then stored in database Reference: Sample node.ts and edge.ts on: https://reactflow.dev/learn/advanced-use/state-management
Develop one endpoint that receives node data from the frontend, Including necessary node and edge attributes - 3 hours Explore Feasibility: Investigate the limits and drawbacks for this approach, if this works at a reasonable speed, cost, space, time - then AC2 considered satisfied, CRUD would become stretch) - 4 hours
Acceptance Criteria: AC1: Implement API endpoints to receive updated tree data (nodes and edges). The endpoints should be capable of handling large payloads if the tree is complex. AC2: Implement Logic to handle the updated tree data and save it to the database
(Optional if replacing/adding whole tree doc approach is sufficiently functional for MVP): Explore CRUD Operations Endpoints and workflow: Implement separate logic to handle inserting, deleting, and updating each individual node to database. - 4 hours
Stretch Goal - Definitely should not be included, but it would be helpful: Explore if backup version can be stored if inserting a new tree as document makes sense Explore if can only send changed nodes instead of the whole tree