A high-performance React application for the Medusa 2.0 cybersecurity competition platform.
This project has been optimized for production with the following improvements:
- Code Splitting: Automatic route-based code splitting reduces initial bundle size
- Vendor Chunking: React, UI components, and utilities are split into separate chunks
- Lazy Loading: Pages are loaded on-demand for faster initial page loads
- Tree Shaking: Unused code is automatically removed during build
- React Vendor: 44.92 kB
- Main App: 21.01 kB
- UI Components: 18.61 kB
- Home Page: 9.36 kB (lazy loaded)
- Registration Page: 3.68 kB (lazy loaded)
- Total Initial Load: ~85 kB (vs 112 kB before optimization)
- React.memo: Prevents unnecessary re-renders of components
- useCallback: Optimizes event handlers and functions
- Service Worker: Enables offline functionality and caching
- Image Optimization: Proper loading attributes and lazy loading
- Meta Tags: Comprehensive Open Graph and Twitter Card support
- Structured Data: JSON-LD schema markup for search engines
- Font Optimization: Optimized Google Fonts loading strategy
- Resource Hints: DNS prefetch and preconnect for external resources
- Frontend Framework: React 18 with TypeScript
- Build Tool: Vite with SWC compiler
- Styling: Tailwind CSS with custom cyber theme
- UI Components: shadcn/ui with Radix UI primitives
- Routing: React Router v6 with lazy loading
- State Management: React Query for server state
- Icons: Lucide React
- Package Manager: Bun
# Clone the repository
git clone <YOUR_GIT_URL>
# Navigate to the project directory
cd medusa-2.0
# Install dependencies
bun install
# Start development server
bun run dev
# Build for production
bun run build
# Preview production build
bun run preview
# Analyze bundle size
bun run build:analyze
bun run dev
- Start development serverbun run build
- Production build with optimizationsbun run build:analyze
- Build and analyze bundle compositionbun run lint
- Run ESLintbun run lint:fix
- Fix ESLint errors automaticallybun run type-check
- TypeScript type checkingbun run preview
- Preview production build locally
- Chunk Splitting: Automatic vendor and route-based splitting
- Minification: Terser with console/debugger removal
- CSS Code Splitting: Separate CSS chunks for better caching
- Source Maps: Disabled in production for smaller bundles
- Service Worker: Automatic registration for offline support
- Lazy Loading: Route-based code splitting
- Image Optimization: Loading and decoding optimizations
- Font Loading: Optimized Google Fonts strategy
- Initial Bundle: 364.40 kB (111.97 kB gzipped)
- Single large chunk with all dependencies
- Initial Load: ~85 kB gzipped
- 11 optimized chunks with intelligent splitting
- Lazy-loaded routes for better performance
- 23% reduction in initial bundle size
This project includes Docker support for easy deployment and development.
Dockerfile
- Production build with nginxDockerfile.dev
- Development build with hot reloaddocker-compose.yml
- Orchestration for easy deploymentnginx.conf
- Optimized nginx configuration for React SPA.dockerignore
- Optimized Docker build context
# Build and run with Docker Compose (recommended)
docker-compose up -d
# Or build and run manually
docker build -t medusa-2.0 .
docker run -d -p 3000:80 --name medusa-frontend medusa-2.0
# Start development environment with hot reload
docker-compose --profile dev up -d
# Access the application
# Production: http://localhost:3000
# Development: http://localhost:8080
The enhanced deploy.sh
script supports multiple deployment methods:
# Traditional deployment (build and upload manually)
./deploy.sh production traditional
# Docker deployment
./deploy.sh production docker
# Docker Compose deployment
./deploy.sh production docker-compose
# Development with Docker Compose
./deploy.sh development docker-compose
- Multi-stage builds for optimized image size
- nginx server for production with proper SPA routing
- Gzip compression and caching headers
- Security headers (CSP, XSS protection, etc.)
- Health check endpoint at
/health
- Hot reload in development mode
- Optimized build context with
.dockerignore
This project includes comprehensive GitHub Actions workflows for automated testing, building, and deployment:
- CI/CD - Build, test, and deploy to GitHub Pages
- Docker Build - Multi-platform Docker builds with security scanning
- Security Scan - Automated vulnerability scanning
- Manual Deploy - On-demand deployment to staging/production
- Push to
main
branch β Automatic production deployment - Push to
develop
branch β Automatic staging deployment - Create tags β Versioned Docker images
- Manual trigger β Deploy specific versions
# Automatic (via GitHub Actions)
git push origin main
# Manual Docker deployment
docker-compose up -d
# Development with hot reload
docker-compose --profile dev up -d
See .github/GITHUB_ACTIONS_SETUP.md
for detailed setup instructions.
- Fork the repository
- Create a feature branch
- Make your changes
- Run tests and linting
- Submit a pull request
This project is licensed under the MIT License.
Backend Repository: Medusa Backend