This project provides an API service that generates React TypeScript code based on natural language descriptions. It uses LangGraph for workflow management and GPT-4o for code generation.
- Generate complete React TypeScript applications from text descriptions
- Automatic styling with Tailwind CSS
- Streaming API responses
- Modern code generation with best practices
- Type-safe code generation
- Responsive design patterns
- Python 3.8 or higher
- Node.js 16 or higher
- OpenAI API key
- Clone the repository:
git clone https://github.com/yourusername/api-langraph.git
cd api-langraph
- Install Python dependencies:
pip install -r requirements.txt
- Set up environment variables:
cp .env.example .env
# Edit .env and add your OpenAI API key
- Start the FastAPI server:
uvicorn main:app --reload
- The API will be available at
http://localhost:8000
Generates React TypeScript code based on a description.
Request Body:
{
"description": "string"
}
Response: Server-sent events stream with the following format:
{
"description": "string",
"code": "string (JSON with file contents)",
"status": "string",
"review_feedback": "string"
}
Health check endpoint.
Response:
{
"status": "healthy"
}
Run the test script to verify the API functionality:
python test_api.py
main.py
- FastAPI application and API endpointsworkflow.py
- LangGraph workflow definition and code generation logictest_api.py
- API testing scriptrequirements.txt
- Python dependencies
The API generates a complete React TypeScript project with the following structure:
src/
├── App.tsx
├── index.tsx
├── App.css
├── index.css
└── react-app-env.d.ts
public/
└── index.html
package.json
tsconfig.json
tailwind.config.js
postcss.config.js
.gitignore
The API includes comprehensive error handling:
- Invalid JSON format detection
- Missing required files validation
- Code generation error handling
- API request/response validation
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- OpenAI for GPT-4o
- LangGraph for workflow management
- FastAPI for the web framework
- React and TypeScript communities