A powerful AI-powered code generation and execution platform that combines **Strands-Agents** framework with **AWS Bedrock AgentCore** for intelligent Python code development.
## 🎯 Overview
Text to Python IDE is a full-stack application that enables users to:
- **Generate Python code** from natural language descriptions using advanced AI models
- **Execute code safely** in AWS-managed sandboxed environments
- **Upload CSV files** for data analysis and processing in generated code
- **Interact with results** through a modern web interface
- **Manage sessions** with persistent conversation history
- **Fallback**: Nova Premier (Inference Profile) - `us.amazon.nova-premier-v1:0`
- **Safety Net**: Claude 3.5 Sonnet - `anthropic.claude-3-5-sonnet-20241022-v2:0`
#### **Execution Environment (AgentCore)**
- **Sandboxed Python Environment**: Isolated execution in AWS
- **Real-time Results**: Streaming output and error handling
- **Session Persistence**: Maintains state across executions
## 🚀 Quick Start
### Prerequisites
- **Python 3.8+** with pip
- **Node.js 16+** with npm
- **AWS Account** with Bedrock access
- **AWS CLI** configured or credentials available
### 1. Setup and Start
The application includes automatic setup - just run the start script:
```bash
# Start the application (includes automatic setup)
./start.sh
# The script will automatically:
# - Create Python virtual environment if needed
# - Install all dependencies
# - Create .env configuration file
# - Start both backend and frontend servers
```
### 2. Configure Environment (Optional)
If you need to customize AWS credentials, edit the `.env` file:
```bash
# AWS Configuration (choose one method)
AWS_PROFILE=your_profile_name # Recommended
# Application Configuration
BACKEND_HOST=0.0.0.0
BACKEND_PORT=8000
REACT_APP_API_URL=http://localhost:8000
```
### 3. Access Application
After running `./start.sh`, access:
- **Frontend**: http://localhost:3000
- **Backend API**: http://localhost:8000
### 4. Verify Setup (Optional)
```bash
# Verify setup (optional - start.sh does this automatically)
python tests/verify_setup.py
# Run comprehensive tests
python tests/run_all_tests.py
```
## 📋 Usage
### Code Generation
1. Navigate to the **Code Generator** tab
2.**Optional**: Upload a CSV file using the "Upload CSV File" button for data analysis tasks
3. Enter a natural language description (e.g., "Create a function to calculate fibonacci numbers" or "Analyze the uploaded CSV data and create visualizations")
4. Click **Generate Code**
5. Review the generated code in the **Code Editor** tab
### CSV File Integration
1. In the **Code Generator** tab, click **Upload CSV File**
2. Select your CSV file (must have .csv extension)
3. The file will be available for use in code generation
4. When you mention data analysis, files, or CSV in your prompt, the AI will automatically incorporate your uploaded data
5. If you mention files in your prompt but haven't uploaded a CSV, you'll be prompted to upload one
### Code Execution
1. In the **Code Editor** tab, review or modify your code
2. Click **Execute Code** for immediate execution
3. Click **Interactive Execute** for code requiring user input
4. View results in the **Execution Results** tab
### File Upload
1. In the **Code Editor** tab, use the file upload component
2. Select a `.py` or `.txt` file
3. The file content will be loaded into the editor
4. Execute or modify as needed
## 🛠️ Development
### Project Structure
```
├── backend/ # FastAPI backend
│ ├── main.py # Main application
│ └── requirements.txt # Python dependencies
├── frontend/ # React frontend
│ ├── src/
│ │ ├── App.js # Main application
│ │ └── components/ # React components
│ └── package.json # Node dependencies
├── tests/ # Test scripts
│ ├── run_all_tests.py # Comprehensive test suite
│ └── verify_setup.py # Setup verification
├── docs/ # Documentation
├── .env # Environment configuration
├── setup.sh # Setup script
└── start.sh # Start script
```
### Running Tests
```bash
# Verify setup
python tests/verify_setup.py
# Run comprehensive tests
python tests/run_all_tests.py
# Run automated end-to-end tests (no user input required)