import gradio as gr from huggingface_hub import InferenceClient import os import json import zipfile import io from datetime import datetime # Initialize the client client = InferenceClient(model="cynnix69/qwen3-coder-30b", token=os.environ.get("HF_TOKEN")) # Store project history project_history = [] def parse_generated_code(response): """Parse the generated code into separate files""" files = {} current_file = None current_content = [] for line in response.split('\n'): if line.startswith('```') and ('/' in line or '.' in line): if current_file: files[current_file] = '\n'.join(current_content) current_file = line.strip('`').strip() current_content = [] elif line.startswith('```'): if current_file: files[current_file] = '\n'.join(current_content) current_file = None current_content = [] elif current_file: current_content.append(line) return files if files else {"main.py": response} def create_zip(files_dict): """Create a ZIP file from the generated files""" zip_buffer = io.BytesIO() with zipfile.ZipFile(zip_buffer, 'w', zipfile.ZIP_DEFLATED) as zip_file: for filename, content in files_dict.items(): zip_file.writestr(filename, content) zip_buffer.seek(0) return zip_buffer def build_software(requirements, project_type, framework, include_tests, include_docker, complexity, code_style, add_comments, security_level, optimization): """Generate complete software based on detailed requirements""" if not requirements.strip(): return None, "โ Please provide project requirements", "", None, "" # Enhanced prompt with all features prompt = f"""You are Cynetics Pro, an elite automated software architect and developer. PROJECT SPECIFICATIONS: - Type: {project_type} - Framework: {framework} - Complexity: {complexity} - Code Style: {code_style} - Security Level: {security_level} - Optimization: {optimization} REQUIREMENTS: {requirements} MANDATORY DELIVERABLES: 1. Complete project structure with all necessary files 2. Main application code with proper architecture 3. Configuration files (package.json, requirements.txt, etc.) 4. Comprehensive README.md with: - Setup instructions - Usage examples - API documentation (if applicable) - Environment variables needed 5. .gitignore file 6. Environment configuration (.env.example) {'7. Complete unit tests with >80% coverage' if include_tests else ''} {'8. Dockerfile and docker-compose.yml with optimization' if include_docker else ''} CODE REQUIREMENTS: - {'Add detailed inline comments explaining logic' if add_comments else 'Minimal comments, focus on clean code'} - Security: {security_level} (include input validation, sanitization, auth best practices) - Performance: {optimization} level optimization - Error handling: Comprehensive try-catch blocks - Logging: Structured logging throughout - Type hints/annotations where applicable OUTPUT FORMAT: For each file, use this exact format: ```filename.ext [file content here] ``` Generate production-ready, scalable code following industry best practices.""" try: # Generate code response = client.text_generation( prompt, max_new_tokens=4000, temperature=0.7, top_p=0.95, repetition_penalty=1.1 ) # Parse response into files files = parse_generated_code(response) # Create file tree view file_tree = "๐ Project Structure:\n" for filename in sorted(files.keys()): file_tree += f"โโโ {filename}\n" # Create download zip zip_file = create_zip(files) # Add to history project_history.append({ "timestamp": datetime.now().strftime("%Y-%m-%d %H:%M:%S"), "type": project_type, "framework": framework, "requirements": requirements[:100] + "...", "files_count": len(files) }) # Get first file for preview preview_file = list(files.keys())[0] preview_content = files[preview_file] status = f"โ Generated {len(files)} files successfully!" return response, status, file_tree, zip_file, preview_content except Exception as e: return None, f"โ Error: {str(e)}", "", None, "" def review_code(code, review_type): """AI code review with suggestions""" prompt = f"""You are a senior code reviewer. Perform a {review_type} review of this code: {code} Provide: 1. Security vulnerabilities (if any) 2. Performance issues 3. Code smells 4. Best practice violations 5. Suggestions for improvement Format as a detailed review with severity levels (Critical/High/Medium/Low).""" try: response = client.text_generation( prompt, max_new_tokens=1500, temperature=0.5 ) return response except Exception as e: return f"Error during review: {str(e)}" def refactor_code(code, refactor_goal): """Refactor code based on specific goal""" prompt = f"""Refactor this code to: {refactor_goal} Original code: {code} Provide: 1. Refactored code 2. Explanation of changes 3. Benefits of refactoring""" try: response = client.text_generation( prompt, max_new_tokens=2000, temperature=0.6 ) return response except Exception as e: return f"Error during refactoring: {str(e)}" def generate_tests(code, test_framework): """Generate comprehensive tests for the code""" prompt = f"""Generate comprehensive unit tests for this code using {test_framework}: {code} Include: 1. Unit tests for all functions/methods 2. Edge cases 3. Error cases 4. Mock external dependencies 5. Test fixtures/setup""" try: response = client.text_generation( prompt, max_new_tokens=2000, temperature=0.6 ) return response except Exception as e: return f"Error generating tests: {str(e)}" def explain_code(code, explanation_level): """Explain code in detail""" levels = { "Beginner": "Explain like I'm 5, with simple analogies", "Intermediate": "Technical explanation with some details", "Expert": "Deep technical analysis with design patterns and architecture" } prompt = f"""{levels[explanation_level]} Code to explain: {code} Provide a comprehensive explanation.""" try: response = client.text_generation( prompt, max_new_tokens=1500, temperature=0.5 ) return response except Exception as e: return f"Error explaining code: {str(e)}" def update_framework_options(project_type): """Update framework dropdown based on project type""" frameworks = { "Web App": ["React + Node.js", "Vue.js + Express", "Next.js", "Django", "Flask", "FastAPI", "Angular + NestJS", "Svelte + Express"], "Mobile App": ["React Native", "Flutter", "Swift (iOS)", "Kotlin (Android)", "Ionic", "NativeScript"], "API Service": ["FastAPI", "Express.js", "Django REST", "Flask-RESTful", "Spring Boot", "ASP.NET Core", "GraphQL"], "CLI Tool": ["Python Click", "Node.js Commander", "Go Cobra", "Rust Clap", "Python Typer"], "Desktop App": ["Electron", "PyQt", "Tauri", ".NET MAUI", "Flutter Desktop", "GTK"], "Data Pipeline": ["Apache Airflow", "Prefect", "Python + Pandas", "Apache Spark", "Luigi", "Dagster"], "Machine Learning": ["PyTorch", "TensorFlow", "Scikit-learn", "Hugging Face", "JAX", "FastAI"], "Game": ["Unity C#", "Godot", "Pygame", "Three.js", "Phaser", "LibGDX"], "Blockchain": ["Solidity + Hardhat", "Rust + Anchor", "Web3.js", "Ethers.js"], "DevOps Tool": ["Python + Boto3", "Terraform", "Ansible", "Kubernetes Operators"], "Chrome Extension": ["Manifest V3 + React", "Vanilla JS", "Vue.js"], "Discord Bot": ["Discord.py", "Discord.js", "JDA (Java)"] } return gr.Dropdown(choices=frameworks.get(project_type, ["Custom"]), value=frameworks.get(project_type, ["Custom"])[0]) # Custom CSS custom_css = """ @import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@300;400;500;600;700&display=swap'); * { font-family: 'Space Grotesk', sans-serif; } #main_container { max-width: 1600px; margin: auto; background: #0f1419; } .header { text-align: center; background: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%); color: white; padding: 3rem; border-radius: 15px; margin-bottom: 2rem; box-shadow: 0 10px 40px rgba(102, 126, 234, 0.4); } .header h1 { font-size: 3.5rem; font-weight: 700; margin: 0; text-shadow: 2px 2px 4px rgba(0,0,0,0.2); } .feature-card { background: linear-gradient(135deg, #1a1f2e 0%, #2d3748 100%); padding: 1.5rem; border-radius: 12px; border-left: 5px solid #667eea; margin: 1rem 0; box-shadow: 0 4px 15px rgba(0,0,0,0.3); transition: transform 0.3s ease; color: #e2e8f0 !important; } .feature-card:hover { transform: translateY(-5px); } .feature-card h3 { color: #ffffff !important; margin-bottom: 0.5rem; } .feature-card p { color: #cbd5e0 !important; } .feature-card small { color: #a0aec0 !important; } .stat-box { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); padding: 1rem; border-radius: 10px; text-align: center; box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3); color: white !important; } .stat-box h3 { color: white !important; margin: 0; font-size: 2rem; } .stat-box p { color: rgba(255,255,255,0.9) !important; margin: 0.5rem 0 0 0; } .pro-badge { background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%); color: white; padding: 0.3rem 0.8rem; border-radius: 20px; font-size: 0.8rem; font-weight: 600; display: inline-block; margin-left: 0.5rem; } .tabs { border-radius: 10px; overflow: hidden; } /* Fix for all text elements */ .gradio-container { background: #0f1419 !important; } label { color: #e2e8f0 !important; } .prose { color: #e2e8f0 !important; } /* Make sure all markdown text is visible */ .markdown-text, .markdown-text * { color: #e2e8f0 !important; } """ # Create the main interface with gr.Blocks(css=custom_css, title="Cynetics Pro - Ultimate AI Software Builder", theme=gr.themes.Soft(primary_hue="purple")) as demo: with gr.Column(elem_id="main_container"): # Header gr.HTML("""
From Idea to Production-Ready Code in Seconds
Powered by Qwen 3 Coder 30B | Built by cynnix69
Project Types
Frameworks
Code Review
Production Ready
Full-stack online store with payment integration, inventory management, and admin dashboard
Stack: Next.js + Node.js + PostgreSQLReal-time analytics with charts, user management, and subscription billing
Stack: React + FastAPI + RedisScalable chatbot service with NLP, webhooks, and multi-channel support
Stack: Python + FastAPI + ML๐ Privacy First: Your code is never stored | Generated in real-time
Powered by Qwen 3 Coder 30B | Built with โค๏ธ by cynnix69