JACoB PR for Issue Begin making the Time Machine App #3
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary:
Goal of Time machine app:
it will be are an AI poweredtimeline generation assistant. -note that I have some ux code already to bootstrap the idea
added
How the app will work - Given an initial choice and context, and number of possbile choices (starting with 2 options) in text given by user
generate a realistic STEP by STEP (based on the time range selected) detailed sequence of events that could follow. Consider:
Format your response as a structured timeline with clear event descriptions,
timestamps, and consequence chains.
Technical Requirements
Stack
Frontend: React + TypeScript + Vite
Backend: Express.js + TypeScript
State Management: Zustand
API Integration: OpenAI API
Visualization: React Flow
Styling: TailwindCSS
HTTP Client: Axios
Project Structure
Copytimeline-app/
├── client/
│ ├── src/
│ │ ├── components/
│ │ │ ├── ChoicePanel/
│ │ │ ├── TimelineFlow/
│ │ │ └── shared/
│ │ ├── hooks/
│ │ ├── store/
│ │ ├── types/
│ │ └── services/
└── server/
├── src/
│ ├── routes/
│ ├── controllers/
│ ├── services/
│ └── types/
Core Features
Collapsible sidebar (30% width)
Input fields for initial conditions:
Choice title
Description
Key parameters
Timeline duration
Support for 1-3 parallel choices
Generate button to trigger timeline creation
React Flow canvas (70% width)
Node types:
Decision node (initial point)
Event node (timeline events)
Consequence node (outcomes)
Edge types:
Timeline connection
Cause-effect connection
Interactive navigation:
Zoom
Pan
Node selection
Timeline highlighting
@jacob-ai-bot --skip-build
Plan:
Step 1: Create
/client/src/store/timelineStore.ts
Task: Set up Zustand store for state management
Instructions:
In 'client/src/store/timelineStore.ts', create a Zustand store to manage the timeline state and choice data. Define state variables for choices, timeline events, and loading states. Implement actions to update choices based on user input, set timeline data received from the backend, and handle loading states during API calls.
Exit Criteria:
The Zustand store is set up with state variables and actions, and is ready to be used by React components for state management.
Step 2: Create
/client/src/services/openaiService.ts
Task: Implement OpenAI API integration service on the client
Instructions:
Create 'client/src/services/openaiService.ts' to handle API calls related to timeline generation. Use Axios to define functions that send choice data to the backend endpoint and receive the generated timeline data. Include error handling and export functions for use in components.
Exit Criteria:
The OpenAI API service functions are implemented, allowing the client to communicate with the backend for timeline generation.
Step 3: Create
/client/src/types/types.ts
Task: Define TypeScript types and interfaces
Instructions:
Create 'client/src/types/types.ts' and define interfaces for choice data, timeline events, nodes, edges, and API responses. Ensure that these types accurately represent the data structures used throughout the application.
Exit Criteria:
All necessary TypeScript interfaces and types are defined and can be imported wherever type definitions are required.
Step 4: Create
/server/src/index.ts
Task: Create the main entry point for the backend server
Instructions:
In 'server/src/index.ts', set up an Express.js application using TypeScript. Configure middleware for JSON parsing and CORS as needed. Initialize the server to listen on a specified port (e.g., 5000) and confirm that it starts without errors.
Exit Criteria:
The backend server starts successfully and is ready to handle incoming requests.
Step 5: Create
/server/src/routes/timelineRoutes.ts
Task: Set up backend routes for timeline generation
Instructions:
Create 'server/src/routes/timelineRoutes.ts' and define a POST route for '/generate-timeline'. This route should accept choice data from the client and forward it to the appropriate controller function.
Exit Criteria:
The route for '/generate-timeline' is defined and ready to handle incoming requests from the client.
Step 6: Create
/client/src/main.tsx
Task: Create the main entry point for the frontend application
Instructions:
Create a new file at 'client/src/main.tsx'. Initialize the React application using Vite's recommended setup for React with TypeScript. Ensure that ReactDOM renders the root component into the DOM. Import TailwindCSS styles by including the main CSS file. Confirm that the application renders without errors.
Exit Criteria:
The React application starts successfully with TailwindCSS styling applied, displaying a basic component without errors.
Step 7: Create
/client/src/components/ChoicePanel/ChoicePanel.tsx
Task: Implement the ChoicePanel component
Instructions:
In 'client/src/components/ChoicePanel/ChoicePanel.tsx', create the ChoicePanel component. This component should render a collapsible sidebar occupying 30% of the viewport width. Include input fields for 'Choice Title', 'Description', 'Key Parameters', and 'Timeline Duration'. Provide options to support 1-3 parallel choices. Add a 'Generate' button that will trigger the timeline generation process.
Exit Criteria:
The ChoicePanel component displays the required input fields and 'Generate' button, correctly styled and ready for user interaction.
Step 8: Create
/client/src/components/TimelineFlow/TimelineFlow.tsx
Task: Implement the TimelineFlow component
Instructions:
Create 'client/src/components/TimelineFlow/TimelineFlow.tsx' and implement the TimelineFlow component. Use React Flow to render a canvas occupying 70% of the viewport width. Define custom node types: 'DecisionNode' for initial points, 'EventNode' for timeline events, and 'ConsequenceNode' for outcomes. Define edge types for 'Timeline Connection' and 'Cause-Effect Connection'. Implement interactive features such as zoom, pan, node selection, and timeline highlighting.
Exit Criteria:
The TimelineFlow component renders a React Flow canvas with custom nodes and edges, supporting interactive navigation and ready for data integration.
Step 9: Create
/server/src/controllers/timelineController.ts
Task: Implement the timeline generation controller
Instructions:
In 'server/src/controllers/timelineController.ts', create a controller function 'generateTimeline' that handles incoming choice data. This function should call the OpenAI API service to generate the timeline based on the input and send the generated data back in the response.
Exit Criteria:
The 'generateTimeline' controller function processes input data, interacts with the OpenAI API service, and returns the generated timeline data.
Step 10: Create
/server/src/services/openaiService.ts
Task: Set up OpenAI API service on the server
Instructions:
Create 'server/src/services/openaiService.ts' and implement functions to communicate with the OpenAI API. Include functionality to construct prompts based on choice data, handle API keys securely, make API requests using Axios, and process the responses. Ensure that error handling is in place for API failures.
Exit Criteria:
The OpenAI API service functions correctly construct prompts, communicate with the OpenAI API, and return processed responses.