Skip to content
Open
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
107 changes: 107 additions & 0 deletions nextjs-web-app/BACKGROUND_OPTIMIZATION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
# Background Animation Optimization

## Overview
Replaced the GPU-intensive Continuous Aurora Background Animation with a more efficient, lightweight background system to improve performance and reduce GPU usage.

## Changes Made

### 1. Aurora Background Component (`src/components/ui/aurora-background.tsx`)
**Before:**
- Heavy blur effects (blur-[100px], blur-[120px], blur-[90px])
- Continuous 60-second linear animations with `animate-aurora`
- Complex gradient animations with background-position changes
- Multiple layered animated elements with pseudo-elements
- GPU-intensive transform3d and will-change properties

**After:**
- Static gradient base with subtle color transitions
- Minimal animated overlay with gentle movement
- Optional subtle particle effects using CSS-only animations
- Significantly reduced GPU usage
- Maintained visual appeal with better performance

### 2. CSS Animations (`src/app/globals.css`)
**Removed:**
- `@keyframes aurora` - Complex background-position animation
- `.animate-aurora` - GPU-intensive animation class

**Added:**
- `@keyframes gentle-shift` - Subtle gradient movement (20s duration)
- `@keyframes float-slow` - Gentle particle floating (15s duration)
- `@keyframes float-delayed` - Delayed particle animation (18s duration)
- `@keyframes float-gentle` - Rotating particle animation (22s duration)

### 3. Tailwind Configuration (`tailwind.config.js`)
**Removed:**
- `aurora` keyframe definition
- `aurora` animation class

**Added:**
- `gentle-shift` keyframe and animation
- `float-slow` keyframe and animation
- `float-delayed` keyframe and animation
- `float-gentle` keyframe and animation

## Performance Benefits

### GPU Usage Reduction
- **Before:** Continuous GPU layer creation with transform3d and will-change
- **After:** Minimal GPU usage with simple transform and opacity changes

### Animation Efficiency
- **Before:** Complex background-position animations running every frame
- **After:** Simple transform and opacity animations with longer durations

### Visual Quality
- **Before:** Heavy blur effects causing rendering overhead
- **After:** Clean gradients with subtle movement maintaining visual appeal

### Battery Life
- **Before:** High GPU usage leading to increased power consumption
- **After:** Minimal resource usage improving battery life on mobile devices

## Technical Details

### New Animation Properties
- **Duration:** Longer animation cycles (15-22 seconds) vs. previous 60-second continuous loop
- **Easing:** `ease-in-out` for smoother, more natural movement
- **Delays:** Staggered animation starts to create organic movement patterns
- **Opacity:** Low opacity values (0.1-0.5) for subtle visual effects

### Browser Compatibility
- Uses standard CSS transforms and opacity changes
- Compatible with all modern browsers
- Respects `prefers-reduced-motion` settings for accessibility

### Reduced Motion Support
The existing reduced motion support in `globals.css` continues to work:
```css
@media (prefers-reduced-motion: reduce) {
.animate-aurora {
animation: none;
}
* {
animation-duration: 0.01ms !important;
animation-iteration-count: 1 !important;
transition-duration: 0.01ms !important;
}
}
```

## Testing Results
- βœ… Homepage loads with new efficient background
- βœ… Results page displays correctly with new background
- βœ… Visual appeal maintained while reducing GPU usage
- βœ… Animations are smooth and subtle
- βœ… No performance degradation observed

## Migration Notes
- No breaking changes to component API
- Existing `AuroraBackground` component usage remains the same
- All pages using the component automatically benefit from the optimization
- No additional configuration required

## Future Improvements
- Consider adding user preference for animation intensity
- Implement performance monitoring to track GPU usage improvements
- Add option to completely disable animations for maximum performance
109 changes: 0 additions & 109 deletions nextjs-web-app/PERFORMANCE_OPTIMIZATIONS.md

This file was deleted.

41 changes: 4 additions & 37 deletions nextjs-web-app/next.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,44 +12,11 @@ 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
63 changes: 26 additions & 37 deletions nextjs-web-app/src/app/api/generate/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,38 +19,8 @@ const frameworkPrompts = {
};

export async function POST(req: NextRequest) {
// Get client IP address
const ip = req.ip || req.headers.get("x-forwarded-for") || "127.0.0.1";

// Check rate limit (5 requests per IP)
const count = submissionCounts.get(ip) || 0;
// For debugging only
console.log(`Rate limit check: IP ${ip} has used ${count} requests`);

// if (count >= 25) {
// console.log("Rate limit exceeded for IP:", ip);
// return new Response(
// JSON.stringify({
// error: "rate_limit_exceeded",
// message: "Free limit exceeded. Please create an account to continue.",
// }),
// {
// status: 429,
// headers: {
// "Content-Type": "application/json",
// },
// }
// );
// }

// Parse the request body
const body = await req.json();

// Only increment count for real generations, not rate limit checks
if (body && body.variation !== "rate-limit-check") {
submissionCounts.set(ip, count + 1);
}
try {
const body = await req.json();
const { prompt, variation, framework } = body;

const portkeyApiKey = process.env.PORTKEY_API_KEY;
Expand Down Expand Up @@ -135,12 +105,31 @@ Additional Notes:

Format the code with proper indentation and spacing for readability.`;
} else {
fullPrompt = `Create a well-structured, modern web application:

Instructions:
1. Base functionality: ${prompt}
2. Variation: ${variation}
3. Framework: ${frameworkInstructions}
fullPrompt = `Create a well-structured, modern web application based on the specific requirements below:

CORE FUNCTIONALITY REQUEST:
${prompt}

IMPORTANT: Interpret the request literally and specifically. Do not default to generic patterns like to-do lists unless explicitly requested. Be creative and think about what the user actually wants.

VARIATION INSTRUCTIONS:
${variation}

FRAMEWORK REQUIREMENTS:
${frameworkInstructions}

CREATIVE INTERPRETATION GUIDELINES:
- If the request mentions "organize" or "productivity", consider alternatives to to-do lists such as:
* Calendar/scheduling apps
* Dashboard with widgets
* Time tracking applications
* Habit tracking systems
* Note-taking or journaling apps
* Project management boards
* Goal setting interfaces
- Focus on the specific domain or context mentioned in the request
- Add unique features that make the application interesting and functional
- Think about what would genuinely solve the user's stated problem

Technical Requirements:
- Create a single HTML file with clean, indented code structure
Expand Down
Loading