A Streamlit-based web application that generates, validates, and helps solve coding challenges using AI. The application supports multiple users and integrates with OpenAI's GPT models for intelligent question generation and solution validation.
- AI-Powered Question Generation: Creates unique coding challenges using GPT models
- Interactive Solution Interface: Write and test solutions in real-time
- Automated Testing: Validates solutions against test cases
- Code Formatting: Automatically formats submitted code
- Progress Tracking: Monitors user progress through challenges
- MongoDB Integration: Persistent storage of questions and user progress
- Multi-user Support: Handles concurrent users efficiently
CodeGen employs a structured workflow to generate high-quality coding problems:
- Generate Question: The process begins with specifying problem categories and a theme. AI is then utilized to create a unique coding problem based on these specifications.
- Solve: After generating a question, the next step involves developing a solution. Users can opt to generate an AI-powered solution or create their own implementation.
- Format: To ensure code quality and readability, the solution code is then formatted. This step helps in adhering to coding standards and improves the overall structure of the code.
- Debug: Rigorous testing is crucial. The solution is validated using unit tests, and debugging assistance is provided to resolve any identified issues.
- Review: The final stage is a comprehensive review of the generated problem and its solution. This step ensures the correctness and quality of the coding challenge before it is finalized and saved.
- Python 3.13
- Streamlit
- OpenAI LLMs
- MongoDB (optional)
- Docker & Docker Compose
- Nginx
- AWS EC2
- Python 3.13+
- Docker and Docker Compose
- OpenAI API key
- Tavily API key
- MongoDB URI (optional)
-
Clone the Repository
git clone https://github.com/yourusername/codegen.git cd codegen
-
Set Up Environment
# Create and activate virtual environment python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate # Install dependencies pip install -r requirements.txt
-
Configure Environment Variables Create a
.streamlit/secrets.toml
file:OPENAI_API_KEY = "your-openai-key" TAVILY_API_KEY = "your-tavily-key" MONGODB_URI = "your-mongodb-uri" # Optional
-
Run Locally
streamlit run CodeGen.py
For detailed deployment instructions, including EC2 setup, security configurations, and monitoring, see our Deployment Guide.
Quick deployment steps:
-
Launch EC2 Instance
- Recommended: t3.medium or larger
- Ubuntu 22.04 LTS or Amazon Linux 2023
- Configure security groups for ports 22, 80, and 443
-
Run Setup Script
# For Ubuntu ./scripts/setup_ec2.sh # For Amazon Linux ./scripts/setup_amazon_linux.sh
-
Configure Environment
cd ~/codegen/secrets # Edit .env with your API keys sudo nano .env
-
Start Application
cd ~/codegen docker-compose up -d
-
Build and Run with Docker Compose
docker-compose up --build -d
-
Access the Application
http://localhost:8501
See PROJECT_STRUCTURE for detailed information about the project organization.
- Install MongoDB Community Edition
- Create database and user:
mongosh use codegen db.createUser({ user: "codegen_user", pwd: "your_password", roles: ["readWrite"] })
To migrate existing JSON data to MongoDB:
python scripts/migrate_to_mongodb.py