Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ The purpose of Chaos Coder is to accelerate the development process by providing
- Real-time code preview for each variation
- Interactive interface with theme toggling
- Voice input support for hands-free prompting
- Performance metrics for generation times
- Keyboard shortcuts for quick access to tools

## Tech Stack
Expand Down
109 changes: 0 additions & 109 deletions nextjs-web-app/PERFORMANCE_OPTIMIZATIONS.md

This file was deleted.

37 changes: 0 additions & 37 deletions nextjs-web-app/next.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,44 +12,7 @@ const nextConfig: NextConfig = {
// !! WARN !!
ignoreBuildErrors: true,
},
// Performance optimizations
experimental: {
optimizePackageImports: ['framer-motion', 'react-icons'],
},
// Bundle optimization
webpack: (config, { dev, isServer }) => {
// Optimize bundle size in production
if (!dev && !isServer) {
config.optimization.splitChunks = {
chunks: 'all',
cacheGroups: {
vendor: {
test: /[\\/]node_modules[\\/]/,
name: 'vendors',
chunks: 'all',
},
framerMotion: {
test: /[\\/]node_modules[\\/]framer-motion[\\/]/,
name: 'framer-motion',
chunks: 'all',
},
monaco: {
test: /[\\/]node_modules[\\/]@monaco-editor[\\/]/,
name: 'monaco-editor',
chunks: 'all',
},
},
};
}
return config;
},
// Compress responses
compress: true,
// Enable static optimization
trailingSlash: false,
// Optimize images
images: {
formats: ['image/webp', 'image/avif'],
domains: [
'lh3.googleusercontent.com', // Google user avatars
'avatars.githubusercontent.com', // GitHub avatars (in case you add GitHub auth)
Expand Down
19 changes: 1 addition & 18 deletions nextjs-web-app/src/app/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
}
}

/* Aurora animation - optimized for performance */
/* Aurora animation */
@keyframes aurora {
from {
background-position: 50% 50%, 50% 50%;
Expand All @@ -43,23 +43,6 @@

.animate-aurora {
animation: aurora 60s linear infinite;
/* Use will-change to optimize for animation */
will-change: background-position;
/* Use transform3d to enable hardware acceleration */
transform: translate3d(0, 0, 0);
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
.animate-aurora {
animation: none;
}

* {
animation-duration: 0.01ms !important;
animation-iteration-count: 1 !important;
transition-duration: 0.01ms !important;
}
}

/* Base styles */
Expand Down
31 changes: 2 additions & 29 deletions nextjs-web-app/src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -163,37 +163,10 @@ export default function Home() {
setIsLoading(true);

try {
// Make a test request to check rate limit before redirecting
const response = await fetch("/api/generate", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
prompt: prompt.substring(0, 50), // Just send a small part of the prompt for the check
variation: "rate-limit-check",
framework: "none",
}),
});

if (response.status === 429) {
// Rate limit exceeded
setShowSignupModal(true);
setIsLoading(false);
return;
}

const data = await response.json();
if (data.error === "rate_limit_exceeded") {
setShowSignupModal(true);
setIsLoading(false);
return;
}

// If no rate limit issues, proceed to results page
// Navigate directly to results page
router.push(`/results?prompt=${encodeURIComponent(prompt)}&numGenerations=${numGenerations}`);
} catch (error) {
console.error("Error checking rate limit:", error);
// Still try to navigate even if there was an error checking rate limit
router.push(`/results?prompt=${encodeURIComponent(prompt)}&numGenerations=${numGenerations}`);
console.error("Error navigating to results:", error);
} finally {
setIsLoading(false);
}
Expand Down
47 changes: 9 additions & 38 deletions nextjs-web-app/src/app/results/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { BrowserContainer } from "@/components/ui/browser-container";
import { useTheme } from "@/context/ThemeContext";
import ThemeToggle from "@/components/ThemeToggle";
import PromptInput from "@/components/DevTools/PromptInput";
import PerformanceMetrics from "@/components/DevTools/PerformanceMetrics";

import VoiceInput from "@/components/DevTools/VoiceInput";
import FullscreenPreview from "@/components/FullscreenPreview";
import MockDeployButton from "@/components/MockDeployButton";
Expand Down Expand Up @@ -95,10 +95,7 @@ function ResultsContent() {
new Array(numGenerations).fill("")
);
const [isPromptOpen, setIsPromptOpen] = useState(false);
const [isMetricsOpen, setIsMetricsOpen] = useState(false);
const [generationTimes, setGenerationTimes] = useState<{
[key: number]: number;
}>({});

const [isVoiceEnabled, setIsVoiceEnabled] = useState(true);
const [showSignupModal, setShowSignupModal] = useState(false);
const [isFullscreenOpen, setIsFullscreenOpen] = useState(false);
Expand All @@ -122,7 +119,6 @@ function ResultsContent() {
}, []);

const generateApp = useCallback(async (index: number, promptText: string) => {
const startTime = performance.now();
try {
const framework = getFramework(appTitles[index]);

Expand All @@ -136,21 +132,12 @@ function ResultsContent() {
}),
});

if (response.status === 429) {
// Show signup modal for rate limit
setShowSignupModal(true);
throw new Error("Rate limit exceeded. Please create an account to continue.");
}

if (!response.ok) {
throw new Error(`Failed to generate app ${index + 1}`);
}

const data = await response.json();
if (data.error === "rate_limit_exceeded") {
setShowSignupModal(true);
throw new Error("Rate limit exceeded. Please create an account to continue.");
} else if (data.error) {
if (data.error) {
throw new Error(data.error);
}

Expand All @@ -166,11 +153,7 @@ function ResultsContent() {
return newResults;
});

const endTime = performance.now();
setGenerationTimes((prev) => ({
...prev,
[index]: (endTime - startTime) / 1000, // Convert to seconds
}));

} catch (err) {
setError(
err instanceof Error ? err.message : "Failed to generate applications"
Expand Down Expand Up @@ -226,18 +209,10 @@ function ResultsContent() {
return;
}

// Generate apps with throttling to prevent overwhelming the system
const generateWithThrottle = async () => {
for (let i = 0; i < numGenerations; i++) {
generateApp(i, prompt);
// Add small delay between requests to reduce system load
if (i < numGenerations - 1) {
await new Promise(resolve => setTimeout(resolve, 100));
}
}
};

generateWithThrottle();
// Generate all apps
for (let i = 0; i < numGenerations; i++) {
generateApp(i, prompt);
}
}, [searchParams, generateApp, numGenerations]);

return (
Expand Down Expand Up @@ -460,11 +435,7 @@ function ResultsContent() {
isUpdateMode={true}
currentCode={editedResults[selectedAppIndex]}
/>
<PerformanceMetrics
isOpen={isMetricsOpen}
onClose={() => setIsMetricsOpen(false)}
generationTimes={generationTimes}
/>

{isVoiceEnabled && (
<VoiceInput onInput={(text) => handleVoiceInput(text)} theme={theme} />
)}
Expand Down
Loading