purav-2008's picture
Publishing to public space for live url
d0fdbcd
Raw History Blame Contribute Delete
12.3 kB
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Code Generation Platform</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
min-height: 100vh;
padding: 20px;
}
.container {
max-width: 1200px;
margin: 0 auto;
}
header {
text-align: center;
color: white;
margin-bottom: 40px;
}
header h1 {
font-size: 2.5em;
margin-bottom: 10px;
}
header p {
font-size: 1.1em;
opacity: 0.9;
}
.main-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 20px;
margin-bottom: 40px;
}
.panel {
background: white;
border-radius: 12px;
padding: 30px;
box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
}
.panel h2 {
color: #333;
margin-bottom: 20px;
font-size: 1.3em;
}
textarea {
width: 100%;
height: 200px;
padding: 15px;
border: 2px solid #e0e0e0;
border-radius: 8px;
font-family: 'Monaco', 'Menlo', monospace;
font-size: 0.9em;
resize: vertical;
}
textarea:focus {
outline: none;
border-color: #667eea;
box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}
.button-group {
display: flex;
gap: 10px;
margin-top: 15px;
}
button {
flex: 1;
padding: 12px 24px;
border: none;
border-radius: 8px;
font-size: 1em;
font-weight: 600;
cursor: pointer;
transition: all 0.3s ease;
}
.btn-primary {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
}
.btn-primary:hover {
transform: translateY(-2px);
box-shadow: 0 5px 20px rgba(102, 126, 234, 0.4);
}
.btn-secondary {
background: #f0f0f0;
color: #333;
}
.btn-secondary:hover {
background: #e0e0e0;
}
button:disabled {
opacity: 0.5;
cursor: not-allowed;
}
.output-section {
margin-top: 20px;
}
.json-output {
background: #f5f5f5;
border: 1px solid #e0e0e0;
border-radius: 8px;
padding: 15px;
max-height: 400px;
overflow-y: auto;
font-family: 'Monaco', 'Menlo', monospace;
font-size: 0.85em;
line-height: 1.6;
color: #333;
}
.json-output pre {
white-space: pre-wrap;
word-break: break-word;
}
.status-badge {
display: inline-block;
padding: 6px 12px;
border-radius: 20px;
font-size: 0.85em;
font-weight: 600;
margin-top: 10px;
}
.status-success {
background: #d4edda;
color: #155724;
}
.status-error {
background: #f8d7da;
color: #721c24;
}
.status-warning {
background: #fff3cd;
color: #856404;
}
.loading {
display: none;
text-align: center;
margin: 20px 0;
}
.spinner {
border: 4px solid #f3f3f3;
border-top: 4px solid #667eea;
border-radius: 50%;
width: 30px;
height: 30px;
animation: spin 1s linear infinite;
margin: 0 auto;
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
.info-card {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
padding: 20px;
border-radius: 12px;
margin-bottom: 20px;
}
.info-card h3 {
margin-bottom: 10px;
}
.info-card ul {
margin-left: 20px;
}
.info-card li {
margin-bottom: 8px;
}
.validation-report {
margin-top: 15px;
padding: 15px;
background: #f9f9f9;
border-left: 4px solid #667eea;
border-radius: 4px;
}
.validation-report h4 {
color: #667eea;
margin-bottom: 10px;
}
.validation-report ul {
margin-left: 20px;
}
.validation-report li {
margin-bottom: 5px;
font-size: 0.9em;
}
@media (max-width: 768px) {
.main-grid {
grid-template-columns: 1fr;
}
header h1 {
font-size: 1.8em;
}
}
</style>
</head>
<body>
<div class="container">
<header>
<h1>🤖 Code Generation Platform</h1>
<p>Transform natural language into executable system configurations</p>
</header>
<div class="info-card">
<h3>How it works:</h3>
<ul>
<li>Enter a natural language description of your application</li>
<li>The system processes it through 4 stages: Intent → Design → Schema → Validation</li>
<li>Get back a complete, executable configuration</li>
<li>Full validation ensures consistency across DB, API, UI, and Auth layers</li>
</ul>
</div>
<div class="main-grid">
<div class="panel">
<h2>📝 Input Prompt</h2>
<textarea id="prompt" placeholder="Describe your application...
Example: Build a CRM with login, contacts, dashboard, role-based access, and premium plan with payments. Admins can see analytics."></textarea>
<div class="button-group">
<button class="btn-primary" onclick="generateConfig()">Generate Configuration</button>
<button class="btn-secondary" onclick="loadExample()">Load Example</button>
</div>
</div>
<div class="panel">
<h2>📊 Generated Configuration</h2>
<div id="loading" class="loading">
<div class="spinner"></div>
<p>Generating configuration...</p>
</div>
<div id="output" class="output-section" style="display:none;">
<div id="status"></div>
<div class="json-output">
<pre id="jsonOutput">// Configuration will appear here</pre>
</div>
<div id="report"></div>
</div>
</div>
</div>
</div>
<script>
async function generateConfig() {
const prompt = document.getElementById('prompt').value.trim();
if (!prompt) {
alert('Please enter a prompt');
return;
}
showLoading(true);
try {
const response = await fetch('/api/generate', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ prompt: prompt })
});
const data = await response.json();
if (data.success) {
displayResult(data);
} else {
showError(data.error);
}
} catch (error) {
showError('Failed to generate configuration: ' + error.message);
} finally {
showLoading(false);
}
}
function displayResult(data) {
const output = document.getElementById('output');
const status = document.getElementById('status');
const jsonOutput = document.getElementById('jsonOutput');
const report = document.getElementById('report');
// Status badge
const executable = data.is_executable;
const statusClass = executable ? 'status-success' : 'status-warning';
const statusText = executable ? '✓ Executable' : '⚠ Generated with warnings';
status.innerHTML = `<span class="status-badge ${statusClass}">${statusText}</span>`;
// JSON output
jsonOutput.textContent = JSON.stringify(data.config, null, 2);
// Validation report
if (data.executable_report) {
let reportHtml = '<div class="validation-report">';
reportHtml += '<h4>Validation Report:</h4>';
if (data.executable_report.errors.length > 0) {
reportHtml += '<p style="color: #721c24;"><strong>Errors:</strong></p><ul>';
data.executable_report.errors.forEach(err => {
reportHtml += `<li>${err}</li>`;
});
reportHtml += '</ul>';
}
if (data.executable_report.warnings.length > 0) {
reportHtml += '<p style="color: #856404;"><strong>Warnings:</strong></p><ul>';
data.executable_report.warnings.forEach(warn => {
reportHtml += `<li>${warn}</li>`;
});
reportHtml += '</ul>';
}
reportHtml += `<p><strong>Database Tables:</strong> ${data.config.database_schema?.length || 0}</p>`;
reportHtml += `<p><strong>API Endpoints:</strong> ${data.config.api_schema?.length || 0}</p>`;
reportHtml += `<p><strong>UI Pages:</strong> ${data.config.ui_schema?.length || 0}</p>`;
reportHtml += '</div>';
report.innerHTML = reportHtml;
}
output.style.display = 'block';
}
function showError(message) {
const output = document.getElementById('output');
const status = document.getElementById('status');
const jsonOutput = document.getElementById('jsonOutput');
const report = document.getElementById('report');
status.innerHTML = `<span class="status-badge status-error">✗ Error</span>`;
jsonOutput.textContent = 'Error: ' + message;
report.innerHTML = '';
output.style.display = 'block';
}
function loadExample() {
document.getElementById('prompt').value =
'Build a CRM with login, contacts, dashboard, role-based access, and premium plan with payments. Admins can see analytics.';
generateConfig();
}
function showLoading(show) {
document.getElementById('loading').style.display = show ? 'block' : 'none';
document.getElementById('output').style.display = show ? 'none' : 'block';
}
</script>
</body>
</html>