File size: 12,305 Bytes
d0fdbcd | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 | <!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>
|