ReactAgent is an open-source autonomous LLM agent project for React.js, positioned as an experimental application. Its core purpose is to use the GPT-4 language model to transform user stories into React components and to support composing existing components.
Main capabilities include: generating React components from user stories; composing new React components from existing components; generating React components using a local design system; the tech stack covers React, TailwindCSS, TypeScript, Radix UI, Shadcn UI; following Atomic Design Principles.
Usage: clone the repository and enter the project directory; obtain an OpenAI API Key; set OPENAI_SECRET_KEY in the .env file of backend/main (refer to .env.example), or run the script provided by the project; install dependencies; run the backend script to generate components; run the frontend application to view the component results; open frontend/main/src/GenReactApp.tsx for rendering configuration; read the project customization section.
Project customization: the generation process can be controlled via backend/main/react-agent/generateComponents.ts, supporting step-by-step execution or the full process; render the generated application via frontend/main/src/GenReactApp.tsx, using JsonSkeleton to render the page skeleton and the demo.tsx file to render the demo page; when generating React components, create a folder under LOCAL_COMPONENTS_DIR (default frontend/main/src/react-agent), write a user-story.md that is as detailed as possible, change CONTAINER_PATH in generateComponents.ts to that folder name, and then run the backend script; the directory structure such as UI_COMPONENTS_DIR, DEMO_COMPONENTS_DIR, LOCAL_COMPONENTS_DIR can be configured via .env.example.
Applicable scenarios: rapid generation of React component prototypes, exploratory conversion of user stories to code, and draft component generation based on a local design system.
Limitations and notes: the generated code is not production-ready and is recommended only for prototyping; currently only GPT-4 is supported, GPT-3.5 is not supported; the output may contain defects and errors, and it is recommended to review and test the code before use or execution; the first step of the generation process converts user stories into a JSON file, which may be inaccurate or omit information, and the JSON can be manually modified if necessary; it is recommended to run step by step and review the generated code after each step; the project is provided "as is" without any express or implied warranties, and the risk of use is borne by the user; GPT-4 token usage may incur costs, and you need to monitor and manage OpenAI API usage yourself and set limits or reminders; as an autonomous experiment, the generated content or behavior may not conform to actual business practices or legal requirements, and users must ensure compliance themselves.