Go to file
StillHammer 3da40c0d73 Save current state before exploring first DRS commit
Preserving current work:
- Modified DRS modules and factories
- Updated content and progress tracking
- Deprecated PhraseModule moved to archive

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-12 08:47:23 +08:00
assets Implement comprehensive AI text report/export system 2025-09-26 21:24:13 +08:00
content Save current state before exploring first DRS commit 2025-10-12 08:47:23 +08:00
Legacy Complete architectural rewrite with ultra-modular system 2025-09-22 07:08:39 +08:00
saves Save current state before exploring first DRS commit 2025-10-12 08:47:23 +08:00
src Save current state before exploring first DRS commit 2025-10-12 08:47:23 +08:00
tests Unify vocabulary persistence system - remove dual systems 2025-09-30 13:39:00 +08:00
.envTMP Implement comprehensive AI text report/export system 2025-09-26 21:24:13 +08:00
.gitignore Initial commit: Interactive English Learning Platform 2025-09-15 14:25:13 +08:00
CLAUDE.md Implement strict DRS interface system for all 11 exercise modules 2025-10-08 13:43:25 +08:00
DRS_IMPLEMENTATION_PLAN.md Implement strict DRS interface system for all 11 exercise modules 2025-10-08 13:43:25 +08:00
DRS.md Implement intelligent DRS vocabulary system with Smart Guide integration 2025-09-30 08:26:30 +08:00
fix-server.bat Implement comprehensive AI text report/export system 2025-09-26 21:24:13 +08:00
index.html Save current state before exploring first DRS commit 2025-10-12 08:47:23 +08:00
package-lock.json Implement comprehensive AI text report/export system 2025-09-26 21:24:13 +08:00
package.json Implement comprehensive AI text report/export system 2025-09-26 21:24:13 +08:00
README.md Complete architectural rewrite with ultra-modular system 2025-09-22 07:08:39 +08:00
restart-clean.bat Implement comprehensive AI text report/export system 2025-09-26 21:24:13 +08:00
server.js Implement comprehensive AI text report/export system 2025-09-26 21:24:13 +08:00
SMART_PREVIEW_SPECS.md Implement comprehensive AI text report/export system 2025-09-26 21:24:13 +08:00
start-portable.bat Unify vocabulary persistence system - remove dual systems 2025-09-30 13:39:00 +08:00
start.bat Implement comprehensive AI text report/export system 2025-09-26 21:24:13 +08:00
test-api.bat Implement comprehensive AI text report/export system 2025-09-26 21:24:13 +08:00
test-factory.html Implement ExerciseFactory with strict DRS interface enforcement 2025-10-08 15:39:53 +08:00
TEST-GUIDE.md Add comprehensive testing suite with UI/UX and E2E integration tests 2025-09-28 23:04:38 +08:00

Class Generator 2.0

Educational Games Platform with Ultra-Modular Architecture

A complete rewrite of the Class Generator system using strict modular design patterns, vanilla JavaScript, and rigorous separation of concerns.

🚀 Quick Start

Method 1: Batch File (Windows)

# Double-click or run:
start.bat

Method 2: Command Line

# Install Node.js (if not already installed)
# Then run:
node server.js

# Or using npm:
npm start

Method 3: NPM Scripts

npm run dev     # Start development server
npm run serve   # Same as start

Server will start on: http://localhost:3000

🏗️ Architecture Overview

Core System (Ultra-Rigid)

  • Module.js - Abstract base class with sealed instances and WeakMap privates
  • EventBus.js - Strict event system with validation and type safety
  • ModuleLoader.js - Dependency injection with proper initialization order
  • Router.js - Navigation with guards, middleware, and state management
  • Application.js - Bootstrap system with auto-initialization

Key Architecture Principles

Inviolable Responsibility - Each module has exactly one purpose Zero Direct Dependencies - All communication via EventBus Sealed Instances - Modules cannot be modified after creation Private State - Internal data completely inaccessible Contract Enforcement - Abstract methods must be implemented Dependency Injection - No global access, everything injected

📁 Project Structure

├── src/
│   ├── core/           # Core system modules (sealed)
│   │   ├── Module.js
│   │   ├── EventBus.js
│   │   ├── ModuleLoader.js
│   │   ├── Router.js
│   │   └── index.js
│   ├── components/     # Reusable UI components
│   ├── games/          # Game modules
│   ├── content/        # Content modules
│   ├── styles/         # Modular CSS
│   └── Application.js  # Main application bootstrap
├── Legacy/             # Old system (archived)
├── index.html         # Entry point
├── server.js          # Development server
├── start.bat          # Windows quick start
└── package.json       # Node.js configuration

🔥 Features

Development Server

  • ES6 Modules - Full import/export support
  • CORS Enabled - For online communication
  • Hot Reload Ready - Manual refresh (planned: auto-refresh)
  • Proper MIME Types - All file types supported
  • Security Headers - Basic security implemented

Application System

  • Auto-Start - No commands needed, just open in browser
  • Loading Screen - Elegant initialization feedback
  • Debug Panel - F12 to toggle, shows system status
  • Error Handling - Graceful error recovery
  • Network Status - Real-time connectivity indicator

Module System

  • Strict Validation - Errors if contracts violated
  • Lifecycle Management - Proper init/destroy patterns
  • Event-Driven - Loose coupling via events
  • Dependency Resolution - Automatic dependency loading

🎮 Creating Game Modules

import Module from '../core/Module.js';

class MyGame extends Module {
    constructor(name, dependencies, config) {
        super(name, ['eventBus', 'ui']);

        this._eventBus = dependencies.eventBus;
        this._ui = dependencies.ui;
        this._config = config;
    }

    async init() {
        // Initialize game
        this._eventBus.on('game:start', this._handleStart.bind(this), this.name);
        this._setInitialized();
    }

    async destroy() {
        // Cleanup
        this._setDestroyed();
    }

    _handleStart(event) {
        // Game logic here
    }
}

export default MyGame;

🧩 Adding to Application

// In Application.js modules config:
{
    name: 'myGame',
    path: './games/MyGame.js',
    dependencies: ['eventBus', 'ui'],
    config: { difficulty: 'easy' }
}

🐛 Debugging

Debug Panel (F12)

  • System status and uptime
  • Loaded modules list
  • Event history
  • Performance metrics

Console Access

// Global app instance available in console:
window.app.getStatus()           // Application status
window.app.getCore().eventBus    // Access EventBus
window.app.getCore().router      // Access Router

Common Issues

Module loading fails:

  • Check file paths in Application.js
  • Verify module extends Module base class
  • Ensure all dependencies are listed

Events not working:

  • Verify module is registered with EventBus
  • Check event type strings match exactly
  • Ensure module is initialized before emitting

🔒 Security & Rigidity

The architecture enforces several levels of protection:

  1. Sealed Classes - Object.seal() prevents property addition/deletion
  2. Frozen Prototypes - Object.freeze() prevents method modification
  3. WeakMap Privates - Internal state completely hidden
  4. Abstract Enforcement - Missing methods throw errors
  5. Validation Layers - Input validation at every boundary

Violation attempts will throw explicit errors with helpful messages.

🚀 Next Steps

  1. Create Game Modules - Implement actual games using new architecture
  2. Add Content System - Port content loading from Legacy system
  3. UI Components - Build reusable component library
  4. Performance - Add lazy loading and caching
  5. Testing - Add automated test suite

📝 Migration from Legacy

The Legacy/ folder contains the complete old system. Key differences:

  • Old: Global variables and direct coupling

  • New: Strict modules with dependency injection

  • Old: CSS modifications in global files

  • New: Component-scoped CSS injection

  • Old: Manual module registration

  • New: Automatic loading with dependency resolution


Built with strict architectural principles for maintainable, scalable educational software.