CodeForge Documentation
This directory contains comprehensive documentation for the CodeForge low-code application builder.
🚀 Quick Start
New Features
- Lazy Loading Charts - Lazy-load recharts, d3, three.js (NEW!)
- Hover-Based Preloading - Instant page navigation
- Preloading Quick Reference - Quick start guide
- Router Quick Start - Enable React Router in 2 minutes
- React Router Integration - Full router documentation
📚 Documentation Structure
Getting Started
- Router Quick Start - Enable route-based code splitting
- PRD - Product Requirements Document
Performance & Optimization
- Lazy Loading Charts - Lazy-load recharts, d3, three.js (NEW!)
- Bundle Optimization (Monaco Editor) - Lazy-load heavy components
- Hover-Based Preloading - Instant navigation with preloading
- Preloading Quick Reference - Quick start
- React Router Integration - Route-based code splitting
- Router vs Tabs Comparison - Performance benchmarks
- Router Quick Start - Enable router in 2 minutes
- Bundle Optimization - Bundle size and performance optimization
Error Fixes & Troubleshooting
- 502 Error Fix - Fix 502 Bad Gateway errors
- CI/CD Fixes - Continuous integration fixes
Architecture & Organization
- Documentation Reorganization - Docs structure
- Cleanup Complete - Code cleanup summary
- Changes Summary - Recent changes
- Organization Plan - Project organization
Detailed Sections
- API Documentation - API reference
- Architecture - System architecture
- Deployment - Deployment guides
- Guides - How-to guides
- Testing - Testing documentation
- Reference - Technical reference
🆕 Recent Additions
Chart Library Lazy Loading (Latest)
Optimized bundle size by lazy-loading heavy chart libraries:
Benefits:
- ~1.5MB+ reduction in initial bundle size
- Charts load only when needed
- Automatic preloading with hover support
- Retry logic for network failures
Libraries optimized:
- Recharts (~450KB)
- D3 (~500KB)
- Three.js (~600KB)
- ReactFlow (~300KB)
Learn more:
- Full Documentation - Complete guide
- Library Loader API - Technical reference
Monaco Editor Lazy Loading
Optimized bundle size by lazy-loading Monaco Editor (2.5MB+):
Benefits:
- ~2.5MB reduction in initial bundle size
- Faster initial page load for all users
- Monaco Editor loads only when needed
- Automatic preloading when editor pages are accessed
Components optimized:
- CodeEditor (main file editor)
- LambdaDesigner (lambda function editor)
- WorkflowDesigner (inline script editors)
Learn more:
- Full Documentation - Complete optimization guide
- Implementation Details - Technical details
Hover-Based Route Preloading
Instant page navigation with intelligent preloading:
Benefits:
- Instant navigation on hover-preloaded routes
- Adjacent route preloading for smooth sequential navigation
- Popular routes preloaded in background
- Visual feedback with preload indicator
Features:
- Hover detection with 100ms delay
- Smart concurrency control (max 3 concurrent)
- Automatic adjacent and popular route preloading
- Cache management and status tracking
Learn more:
- Full Documentation - Complete guide
- Quick Reference - Quick start
React Router Integration
We've added full React Router support with route-based code splitting:
Benefits:
- 52% smaller initial bundle (1.2MB vs 2.5MB)
- 50% faster time to interactive
- URL-based navigation
- Browser back/forward support
- Better code organization
Enable it:
// src/config/app.config.ts
export const APP_CONFIG = {
useRouter: true, // Change this!
}
Learn more:
- Quick Start Guide - Get started in 2 minutes
- Full Documentation - Complete guide
Available Guides
502 Bad Gateway Error Fix
Comprehensive guide for fixing 502 Bad Gateway errors in Codespaces/local development.
Quick Fix:
# Run the diagnostic script
bash scripts/diagnose-502.sh
# Then restart the dev server
npm run kill
npm run dev
Key Changes Made:
- ✅ Updated
vite.config.tsto use port 5000 (was 5173) - ✅ Server already configured to bind to
0.0.0.0 - ✅ Updated CI/CD workflows to use
npm installinstead ofnpm ci
Common Issues
1. Port Mismatch
Symptom: 502 errors when accessing Codespaces URL Cause: Vite running on different port than forwarded Fix: Ensure vite.config.ts uses port 5000
2. Workspace Dependencies
Symptom: CI/CD fails with EUNSUPPORTEDPROTOCOL
Cause: npm ci doesn't support workspace protocol
Fix: Use npm install or switch to pnpm
3. Server Not Accessible
Symptom: 502 errors even when server is running
Cause: Server bound to localhost only
Fix: Use host: '0.0.0.0' in vite.config.ts (already done)
4. MIME Type Errors
Symptom: Resources refused as wrong content type Cause: Usually secondary to 502 errors Fix: Fix 502 errors first, MIME issues resolve automatically
Quick Commands
# Check if server is running
lsof -i :5000
# Kill server on port 5000
npm run kill
# Start dev server
npm run dev
# Run diagnostics
bash scripts/diagnose-502.sh
# Check Codespaces ports
gh codespace ports
# Install dependencies (with workspace support)
npm install
File Changes Made
| File | Change | Status |
|---|---|---|
vite.config.ts |
Port 5173 → 5000 | ✅ Fixed |
.github/workflows/ci.yml |
npm ci → npm install (4 places) |
✅ Fixed |
.github/workflows/e2e-tests.yml |
npm ci → npm install |
✅ Fixed |
scripts/diagnose-502.sh |
Created diagnostic script | ✅ New |
docs/502_ERROR_FIX.md |
Created comprehensive guide | ✅ New |
Next Steps After Fixes
-
Restart Development Server
npm run kill # Kill existing processes npm run dev # Start fresh -
Verify in Browser
- Open Codespaces forwarded URL for port 5000
- Should see React app load without errors
- Check browser console - no 502s
-
Test CI/CD
- Push changes to trigger workflow
- Verify
npm installsucceeds - Build should complete successfully
-
Long-term Improvements
- Consider migrating to pnpm for better workspace support
- Add health check endpoint for monitoring
- Document port configuration for team
Troubleshooting
If issues persist after applying fixes:
-
Check the diagnostic output:
bash scripts/diagnose-502.sh -
Verify Codespaces port forwarding:
- Open Ports panel in VS Code
- Ensure port 5000 is forwarded
- Set visibility to Public or Private to Org
-
Check server logs:
- Look for errors in terminal where dev server runs
- Common issues: missing deps, syntax errors, port conflicts
-
Clear Vite cache:
rm -rf node_modules/.vite npm run dev -
Rebuild dependencies:
rm -rf node_modules package-lock.json npm install npm run dev
Additional Resources
Support
If you continue experiencing issues:
- Check existing documentation in
docs/directory - Review browser console for specific error messages
- Check server terminal logs for backend errors
- Verify all file changes were applied correctly