Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JACoB PR for Issue Begin making the Time Machine App #3

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jacob-ai-bot[bot]
Copy link

@jacob-ai-bot jacob-ai-bot bot commented Nov 19, 2024

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:

  1. Realistic probabilities
  2. Both positive and negative outcomes
  3. Interconnected consequences
  4. Time-appropriate developments
  5. Domain-specific factors

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

  1. Left Panel - Choice Input

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

  1. Right Panel - Timeline Visualization

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.

Copy link
Author

jacob-ai-bot bot commented Nov 19, 2024

Hello human! 👋

This PR was created by JACoB to address the issue Begin making the Time Machine App

Next Steps

  1. Please review the PR carefully. Auto-generated code can and will contain subtle bugs and mistakes.

  2. If you identify code that needs to be changed, please reject the PR with a specific reason.
    Be as detailed as possible in your comments. JACoB will take these comments, make changes to the code and push up changes.
    Please note that this process will take a few minutes.

  3. Once the code looks good, approve the PR and merge the code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

0 participants