This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Project-GALAX is a Progressive Web App (PWA) social community platform built with vanilla JavaScript. It features real-time chat, interactive drawing, voice/video calling, file sharing, and pixel art avatars. The application uses a component-based architecture with dynamic library loading for graphics capabilities.
This project uses no build system - it runs directly in the browser using native ES6 modules:
- Development Server: Use any static web server (Python's
http.server, Node'shttp-server, VS Code Live Server) - Testing: No test framework configured - manually test features in browser
- Linting: No linting configuration found - maintain code quality manually
- Dependencies: All graphics libraries (Konva.js, PIXI.js, Three.js) loaded dynamically from CDN
js/
├── main.js # Application orchestrator and lifecycle management
├── config.js # Centralized configuration with feature flags
├── components/ # Feature-specific modules
│ ├── chat.js # Real-time messaging with WebSocket
│ ├── avatars.js # Pixel art avatar system
│ ├── drawing.js # Interactive canvas drawing
│ ├── voice.js # WebRTC voice/video calls
│ └── [others] # Navigation, files, profile, notifications
├── utils/ # Core utilities
│ ├── state.js # Reactive state management with proxies
│ ├── storage.js # Local storage and persistence
│ └── graphics.js # Graphics utilities and optimization
└── libs/
└── graphics-loader.js # Dynamic library loading system
- Component-Based Architecture: Each feature is a self-contained class exposed on
window - Reactive State Management: Proxy-based state system with path subscriptions (
state.js:1-200) - Dynamic Library Loading: Graphics libraries loaded on-demand based on feature usage
- Progressive Enhancement: Feature detection with graceful fallbacks
- Event-Driven Communication: Custom events for cross-component communication
The application uses a sophisticated reactive state system in js/utils/state.js:
- Proxy-based reactivity: Automatic change detection
- Path-based subscriptions: Subscribe to specific state paths like
user.preferences.theme - State persistence: Automatic localStorage sync with configurable expiry
- Middleware support: Transform state changes before applying
Example usage:
// Subscribe to state changes
window.StateManager.subscribe('user.preferences', (newValue, oldValue) => {
// Handle theme changes
});
// Update state
window.StateManager.setState('user.preferences.theme', 'dark');All configuration is centralized in js/config.js with feature flags:
- Graphics Libraries: Konva.js, PIXI.js, Three.js with CDN URLs
- WebSocket/API Endpoints: Environment-specific URLs
- Feature Flags: Enable/disable major features like voice, drawing, themes
- PWA Settings: Service worker, notifications, offline mode
- Performance Settings: Virtual scrolling, image optimization, lazy loading
The application supports multiple graphics libraries loaded dynamically:
- Konva.js (
CONFIG.graphics.konva): 2D canvas manipulation for drawing - PIXI.js (
CONFIG.graphics.pixi): High-performance 2D rendering - Three.js (
CONFIG.graphics.three): 3D graphics capabilities
Graphics are loaded on-demand through js/libs/graphics-loader.js when specific features are accessed.
- WebSocket Communication: Configured in
CONFIG.websocketfor chat and presence - WebRTC Support: Peer-to-peer voice/video calls via
js/components/voice.js - Typing Indicators: Real-time typing status in chat
- Presence System: User online/offline status tracking
- Components: Feature-specific classes in
js/components/ - Utilities: Shared functionality in
js/utils/ - Assets: Sprites and graphics in
assets/sprites/ - Styles: Modular CSS in
css/(components, animations, main styles)
-
Component Structure:
class FeatureManager { constructor() { this.initialize(); } async initialize() { // Component initialization } // Private methods documented with @private } window.FeatureName = new FeatureManager();
-
Error Handling: Comprehensive try-catch blocks with user-friendly error messages
-
Feature Detection: Check
CONFIG.supportbefore using browser APIs -
Accessibility: Screen reader support, keyboard navigation, high contrast options
- Service Worker: Disabled by default (
CONFIG.pwa.enableServiceWorker: false) - Web App Manifest: Configured in
manifest.jsonfor native app-like experience - Offline Support: IndexedDB storage for offline message viewing
- Push Notifications: Configurable notification system
- No Build Process: Application runs directly in browser - no compilation needed
- CDN Dependencies: All external libraries loaded from CDN, not bundled
- Manual Testing: No automated test suite - verify features manually in browser
- Security: Content Security Policy enabled, XSS prevention, input validation
- Performance: Virtual scrolling, image optimization, lazy loading enabled by default