Skip to content

1T17/GGcode-node

Repository files navigation

GGcode Compiler

A modern web-based compiler for GGcode to G-code conversion with 3D visualization, real-time editing, and comprehensive tooling support.

πŸš€ Features test

  • Real-time GGcode Compilation: Convert GGcode to standard G-code with live feedback
  • Monaco Editor Integration: Advanced code editing with syntax highlighting and IntelliSense
  • 3D G-code Visualization: Interactive 3D preview of toolpaths with simulation controls
  • Configurator System: Dynamic form generation for parameterized GGcode files
  • Examples Library: Built-in collection of GGcode examples and templates
  • Help System: Comprehensive documentation with multi-language support
  • File Operations: Import/export GGcode and G-code files with drag-and-drop support
  • Annotation System: Real-time G-code analysis with modal state tracking

πŸ“ Project Structure

β”œβ”€β”€ .githooks/
β”‚   β”œβ”€β”€ commit-msg
β”‚   β”œβ”€β”€ post-commit
β”‚   └── pre-commit
β”œβ”€β”€ .github/ # GitHub workflows
β”‚   β”œβ”€β”€ workflows/
β”‚   β”‚   β”œβ”€β”€ ci.yml
β”‚   β”‚   β”œβ”€β”€ documentation.yml
β”‚   β”‚   └── release.yml
β”‚   └── markdown-link-check-config.json
β”œβ”€β”€ docs/ # Documentation
β”‚   β”œβ”€β”€ AI_AGENT_DOCUMENTATION.md
β”‚   β”œβ”€β”€ ARCHITECTURE.md
β”‚   β”œβ”€β”€ BUILD_DOCUMENTATION.md
β”‚   β”œβ”€β”€ COMMANDS.md
β”‚   β”œβ”€β”€ DEPLOYMENT.md
β”‚   β”œβ”€β”€ LOCALSTORAGE_LOGIC.md
β”‚   β”œβ”€β”€ PROJECT_STRUCTURE.md
β”‚   └── SVG_Path_Commands.md
β”œβ”€β”€ GGCODE/ # Example files
β”‚   β”œβ”€β”€ advanced patterns.ggcode
β”‚   β”œβ”€β”€ advanced_control.ggcode
β”‚   β”œβ”€β”€ Arc Spiral Pattern.ggcode
β”‚   β”œβ”€β”€ array_example.ggcode
β”‚   β”œβ”€β”€ array_literals.ggcode
β”‚   β”œβ”€β”€ Base10_Dice.ggcode
β”‚   β”œβ”€β”€ base10_Digits.ggcode
β”‚   β”œβ”€β”€ Basic Arc Commands.ggcode
β”‚   β”œβ”€β”€ Basic Square Pocket.ggcode
β”‚   β”œβ”€β”€ basic_circle.ggcode
β”‚   β”œβ”€β”€ complete_features.ggcode
β”‚   β”œβ”€β”€ complete_math.ggcode
β”‚   β”œβ”€β”€ configurator_demo.ggcode
β”‚   β”œβ”€β”€ Crop Circle Pattern.ggcode
β”‚   β”œβ”€β”€ Flower of Life.ggcode
β”‚   β”œβ”€β”€ Flower Pattern with Arcs.ggcode
β”‚   β”œβ”€β”€ function_example.ggcode
β”‚   β”œβ”€β”€ Gear Teeth.ggcode
β”‚   β”œβ”€β”€ Inverted Spiral - Downward.ggcode
β”‚   β”œβ”€β”€ math_functions.ggcode
β”‚   β”œβ”€β”€ Mind-Blowing Gear Generator.ggcode
β”‚   β”œβ”€β”€ operators_and_logic.ggcode
β”‚   β”œβ”€β”€ Rose Pattern.ggcode
β”‚   β”œβ”€β”€ simple_spiral.ggcode
β”‚   β”œβ”€β”€ Spiral Function Circle Grid.ggcode
β”‚   β”œβ”€β”€ Spiral Function Grid.ggcode
β”‚   β”œβ”€β”€ Spiral Function Multi-Ring Circular Grid.ggcode
β”‚   β”œβ”€β”€ Spiral.ggcode
β”‚   β”œβ”€β”€ square.ggcode
β”‚   β”œβ”€β”€ Stair Stringer.ggcode
β”‚   β”œβ”€β”€ star.ggcode
β”‚   β”œβ”€β”€ start spiral.ggcode
β”‚   β”œβ”€β”€ SVG.ggcode
β”‚   β”œβ”€β”€ test-arc.ggcode
β”‚   β”œβ”€β”€ test-svg-arcs.ggcode
β”‚   └── True Spiral with Arcs.ggcode
β”œβ”€β”€ public/ # Static assets (legacy)
β”‚   β”œβ”€β”€ css/
β”‚   β”‚   β”œβ”€β”€ components/
β”‚   β”‚   β”‚   β”œβ”€β”€ buttons.css
β”‚   β”‚   β”‚   β”œβ”€β”€ controls.css
β”‚   β”‚   β”‚   β”œβ”€β”€ headers.css
β”‚   β”‚   β”‚   β”œβ”€β”€ navigation.css
β”‚   β”‚   β”‚   └── tooltips.css
β”‚   β”‚   β”œβ”€β”€ editor/
β”‚   β”‚   β”‚   β”œβ”€β”€ annotation-content.css
β”‚   β”‚   β”‚   β”œβ”€β”€ annotation-toolbar.css
β”‚   β”‚   β”‚   └── annotations.css
β”‚   β”‚   β”œβ”€β”€ layout/
β”‚   β”‚   β”‚   β”œβ”€β”€ global.css
β”‚   β”‚   β”‚   β”œβ”€β”€ grid.css
β”‚   β”‚   β”‚   └── panels.css
β”‚   β”‚   β”œβ”€β”€ modals/
β”‚   β”‚   β”‚   β”œβ”€β”€ app-usage.css
β”‚   β”‚   β”‚   β”œβ”€β”€ base.css
β”‚   β”‚   β”‚   β”œβ”€β”€ code-blocks.css
β”‚   β”‚   β”‚   β”œβ”€β”€ collapsible.css
β”‚   β”‚   β”‚   β”œβ”€β”€ dropdowns.css
β”‚   β”‚   β”‚   β”œβ”€β”€ examples.css
β”‚   β”‚   β”‚   β”œβ”€β”€ help-system.css
β”‚   β”‚   β”‚   β”œβ”€β”€ language-selector.css
β”‚   β”‚   β”‚   β”œβ”€β”€ rtl-support.css
β”‚   β”‚   β”‚   β”œβ”€β”€ search.css
β”‚   β”‚   β”‚   β”œβ”€β”€ settings.css
β”‚   β”‚   β”‚   └── states.css
β”‚   β”‚   β”œβ”€β”€ base.css
β”‚   β”‚   β”œβ”€β”€ components.css
β”‚   β”‚   β”œβ”€β”€ editor.css
β”‚   β”‚   β”œβ”€β”€ main.css
β”‚   β”‚   β”œβ”€β”€ modals.css
β”‚   β”‚   └── README.md
β”‚   β”œβ”€β”€ data/
β”‚   β”‚   β”œβ”€β”€ completions/
β”‚   β”‚   β”‚   β”œβ”€β”€ ggcode-axes.json
β”‚   β”‚   β”‚   β”œβ”€β”€ ggcode-brackets.json
β”‚   β”‚   β”‚   β”œβ”€β”€ ggcode-constants.json
β”‚   β”‚   β”‚   β”œβ”€β”€ ggcode-functions.json
β”‚   β”‚   β”‚   β”œβ”€β”€ ggcode-hover-constants.json
β”‚   β”‚   β”‚   β”œβ”€β”€ ggcode-hover-functions.json
β”‚   β”‚   β”‚   β”œβ”€β”€ ggcode-hover-gcodes.json
β”‚   β”‚   β”‚   β”œβ”€β”€ ggcode-hover-keywords.json
β”‚   β”‚   β”‚   β”œβ”€β”€ ggcode-hover-mcodes.json
β”‚   β”‚   β”‚   β”œβ”€β”€ ggcode-keywords.json
β”‚   β”‚   β”‚   β”œβ”€β”€ ggcode-language-config.json
β”‚   β”‚   β”‚   β”œβ”€β”€ ggcode-operators.json
β”‚   β”‚   β”‚   β”œβ”€β”€ ggcode-param-mappings.json
β”‚   β”‚   β”‚   β”œβ”€β”€ ggcode-signatures.json
β”‚   β”‚   β”‚   └── ggcode-tokenizer.json
β”‚   β”‚   β”œβ”€β”€ help-content/
β”‚   β”‚   β”‚   β”œβ”€β”€ ar.json
β”‚   β”‚   β”‚   β”œβ”€β”€ de.json
β”‚   β”‚   β”‚   β”œβ”€β”€ en.json
β”‚   β”‚   β”‚   β”œβ”€β”€ es.json
β”‚   β”‚   β”‚   β”œβ”€β”€ fr.json
β”‚   β”‚   β”‚   β”œβ”€β”€ he.json
β”‚   β”‚   β”‚   β”œβ”€β”€ it.json
β”‚   β”‚   β”‚   β”œβ”€β”€ ja.json
β”‚   β”‚   β”‚   β”œβ”€β”€ ko.json
β”‚   β”‚   β”‚   β”œβ”€β”€ metadata.json
β”‚   β”‚   β”‚   β”œβ”€β”€ MULTILANGUAGE_GUIDE.md
β”‚   β”‚   β”‚   β”œβ”€β”€ nl.json
β”‚   β”‚   β”‚   β”œβ”€β”€ pl.json
β”‚   β”‚   β”‚   β”œβ”€β”€ pt.json
β”‚   β”‚   β”‚   β”œβ”€β”€ README.md
β”‚   β”‚   β”‚   β”œβ”€β”€ ru.json
β”‚   β”‚   β”‚   β”œβ”€β”€ tr.json
β”‚   β”‚   β”‚   └── zh.json
β”‚   β”‚   β”œβ”€β”€ themes/
β”‚   β”‚   β”‚   β”œβ”€β”€ ggcode-dark-colors.json
β”‚   β”‚   β”‚   └── ggcode-light-colors.json
β”‚   β”‚   └── team-themes.json
β”‚   β”œβ”€β”€ js/
β”‚   β”‚   β”œβ”€β”€ main.js
β”‚   β”‚   β”œβ”€β”€ main.js.LICENSE.txt
β”‚   β”‚   β”œβ”€β”€ main.js.map
β”‚   β”‚   β”œβ”€β”€ navigation.js
β”‚   β”‚   β”œβ”€β”€ navigation.js.map
β”‚   β”‚   β”œβ”€β”€ src_client_js_core_applicationManager_js.js
β”‚   β”‚   β”œβ”€β”€ src_client_js_core_applicationManager_js.js.map
β”‚   β”‚   β”œβ”€β”€ src_client_js_editor_settings_js.js
β”‚   β”‚   β”œβ”€β”€ src_client_js_editor_settings_js.js.map
β”‚   β”‚   β”œβ”€β”€ src_client_js_editor_theme-loader_js.js
β”‚   β”‚   β”œβ”€β”€ src_client_js_editor_theme-loader_js.js.map
β”‚   β”‚   β”œβ”€β”€ src_client_js_editor_themes_js.js
β”‚   β”‚   β”œβ”€β”€ src_client_js_editor_themes_js.js.map
β”‚   β”‚   β”œβ”€β”€ src_client_js_ui_aiCommands_js.js
β”‚   β”‚   └── src_client_js_ui_aiCommands_js.js.map
β”‚   β”œβ”€β”€ flags.css
β”‚   β”œβ”€β”€ GGcode.ico
β”‚   β”œβ”€β”€ logo.png
β”‚   β”œβ”€β”€ mill-annotations.json
β”‚   β”œβ”€β”€ mill-dictionary.json
β”‚   β”œβ”€β”€ OrbitControls.js
β”‚   └── style.css
β”œβ”€β”€ scripts/ # Build and utility scripts
β”‚   β”œβ”€β”€ check-project-health.sh
β”‚   β”œβ”€β”€ generate-docs.sh
β”‚   β”œβ”€β”€ setup-hooks.sh
β”‚   β”œβ”€β”€ smart-commit.sh
β”‚   β”œβ”€β”€ update-changelog.js
β”‚   β”œβ”€β”€ update-dependencies.sh
β”‚   β”œβ”€β”€ update-readme-structure.js
β”‚   └── verify-setup.sh
β”œβ”€β”€ src/ # Source code
β”‚   β”œβ”€β”€ client/ # Client-side code (ES6 modules)
β”‚   β”‚   └── js/
β”‚   β”‚       β”œβ”€β”€ api/
β”‚   β”‚       β”œβ”€β”€ config/
β”‚   β”‚       β”œβ”€β”€ configurator/
β”‚   β”‚       β”œβ”€β”€ core/
β”‚   β”‚       β”œβ”€β”€ editor/
β”‚   β”‚       β”œβ”€β”€ ui/
β”‚   β”‚       β”œβ”€β”€ utils/
β”‚   β”‚       β”œβ”€β”€ visualizer/
β”‚   β”‚       └── main.js
β”‚   └── server/ # Server-side code (CommonJS)
β”‚       β”œβ”€β”€ config/
β”‚       β”‚   β”œβ”€β”€ environment.js
β”‚       β”‚   └── index.js
β”‚       β”œβ”€β”€ middleware/
β”‚       β”‚   β”œβ”€β”€ errorHandler.js
β”‚       β”‚   β”œβ”€β”€ index.js
β”‚       β”‚   └── security.js
β”‚       β”œβ”€β”€ routes/
β”‚       β”‚   β”œβ”€β”€ ai.js
β”‚       β”‚   β”œβ”€β”€ compiler.js
β”‚       β”‚   β”œβ”€β”€ examples.js
β”‚       β”‚   β”œβ”€β”€ help.js
β”‚       β”‚   └── index.js
β”‚       β”œβ”€β”€ services/
β”‚       β”‚   β”œβ”€β”€ compiler.js
β”‚       β”‚   β”œβ”€β”€ fileManager.js
β”‚       β”‚   └── helpContent.js
β”‚       β”œβ”€β”€ app.js
β”‚       └── index.js
β”œβ”€β”€ tests/ # Test suite
β”‚   β”œβ”€β”€ client/
β”‚   β”‚   β”œβ”€β”€ api/
β”‚   β”‚   β”‚   β”œβ”€β”€ client.test.js
β”‚   β”‚   β”‚   └── compiler.test.js
β”‚   β”‚   └── visualizer/
β”‚   β”‚       β”œβ”€β”€ adaptive-rendering.test.js
β”‚   β”‚       β”œβ”€β”€ chunk-loader.test.js
β”‚   β”‚       β”œβ”€β”€ debug.test.js
β”‚   β”‚       β”œβ”€β”€ frustum-culling-performance.test.js
β”‚   β”‚       β”œβ”€β”€ frustum-culling.test.js
β”‚   β”‚       β”œβ”€β”€ geometry-manager.test.js
β”‚   β”‚       β”œβ”€β”€ geometry-optimization.test.js
β”‚   β”‚       β”œβ”€β”€ lod-system.test.js
β”‚   β”‚       β”œβ”€β”€ matrix-calculations.test.js
β”‚   β”‚       β”œβ”€β”€ parser-simple.test.js
β”‚   β”‚       β”œβ”€β”€ PERFORMANCE_VALIDATION_SUMMARY.md
β”‚   β”‚       β”œβ”€β”€ performance-test-report.md
β”‚   β”‚       β”œβ”€β”€ progress-bar-benchmark.js
β”‚   β”‚       β”œβ”€β”€ progress-bar-integration.test.js
β”‚   β”‚       β”œβ”€β”€ progress-bar-validation.js
β”‚   β”‚       β”œβ”€β”€ render-queue.test.js
β”‚   β”‚       β”œβ”€β”€ renderer-optimization.test.js
β”‚   β”‚       β”œβ”€β”€ renderer.test.js
β”‚   β”‚       └── tooltipIntegration.test.js
β”‚   β”œβ”€β”€ config/
β”‚   β”‚   └── testConfig.js
β”‚   β”œβ”€β”€ fixtures/
β”‚   β”‚   β”œβ”€β”€ examples/
β”‚   β”‚   β”‚   β”œβ”€β”€ simple_square.ggcode
β”‚   β”‚   β”‚   └── with_variables.ggcode
β”‚   β”‚   └── help/
β”‚   β”‚       └── test_help.json
β”‚   β”œβ”€β”€ server/
β”‚   β”‚   β”œβ”€β”€ config/
β”‚   β”‚   β”‚   └── config.test.js
β”‚   β”‚   └── services/
β”‚   β”‚       β”œβ”€β”€ compiler.test.js
β”‚   β”‚       └── fileManager.test.js
β”‚   β”œβ”€β”€ utils/
β”‚   β”‚   β”œβ”€β”€ mocks.js
β”‚   β”‚   β”œβ”€β”€ testHelpers.js
β”‚   β”‚   └── testRunner.js
β”‚   β”œβ”€β”€ AI_TESTING_README.md
β”‚   β”œβ”€β”€ ai-commands-test.js
β”‚   β”œβ”€β”€ ai-integration-results.json
β”‚   β”œβ”€β”€ ai-integration-test.js
β”‚   β”œβ”€β”€ ai-test-cases.json
β”‚   β”œβ”€β”€ run-ai-tests.js
β”‚   β”œβ”€β”€ setup.js
β”‚   └── smoke-tests.json
β”œβ”€β”€ views/ # EJS templates
β”‚   β”œβ”€β”€ layouts/
β”‚   β”‚   └── main.ejs
β”‚   β”œβ”€β”€ pages/
β”‚   β”‚   └── index.ejs
β”‚   β”œβ”€β”€ partials/
β”‚   β”‚   β”œβ”€β”€ head.ejs
β”‚   β”‚   β”œβ”€β”€ modals.ejs
β”‚   β”‚   β”œβ”€β”€ scripts.ejs
β”‚   β”‚   └── viewer.ejs
β”‚   β”œβ”€β”€ help-template.ejs
β”‚   β”œβ”€β”€ helpExamples.ejs
β”‚   └── index.ejs
β”œβ”€β”€  pm2.json
β”œβ”€β”€ .eslintrc.js
β”œβ”€β”€ .gitignore
β”œβ”€β”€ .jsdoc.json
β”œβ”€β”€ .prettierrc
β”œβ”€β”€ CHANGELOG.md
β”œβ”€β”€ CONTRIBUTING.md
β”œβ”€β”€ libggcode.so
β”œβ”€β”€ MAINTENANCE.md
β”œβ”€β”€ nodemon.json
β”œβ”€β”€ nohup.out
β”œβ”€β”€ package-lock.json
β”œβ”€β”€ package.json
β”œβ”€β”€ README.md
β”œβ”€β”€ server.log
β”œβ”€β”€ setup.sh
β”œβ”€β”€ USAGE.md
└── webpack.config.js

πŸ› οΈ Installation

Prerequisites

  • Node.js >= 16.0.0
  • npm >= 8.0.0
  • GGcode native library (libggcode.so)

Setup

  1. Clone the repository

    git clone <repository-url>
    cd ggcode-compiler
  2. Install dependencies

    npm install
  3. Configure environment

    cp .env.example .env
    # Edit .env with your configuration
  4. Build and test

    npm run build

πŸš€ Usage

Development

# Start development server with hot reload
npm run dev

# Start with debugging
npm run dev:watch

Production

# Start production server
npm start

# Or with PM2
pm2 start ecosystem.config.js

Testing

# Run all tests
npm test

# Run tests with coverage
npm run test:coverage

# Run tests in watch mode
npm run test:watch

Code Quality

# Lint code
npm run lint

# Fix linting issues
npm run lint:fix

# Format code
npm run format

# Check formatting
npm run format:check

Documentation Automation

# Update project structure in README.md
npm run update-structure

# Add changelog entry from recent commits
npm run update-changelog        # Uses version from package.json
npm run update-changelog 1.0.2  # Uses specific version

These simple scripts automate the mechanical parts of documentation maintenance:

  • Project Structure: Scans directories and updates the ## πŸ“ Project Structure section
  • Changelog: Extracts git commits since last tag and adds formatted entries to CHANGELOG.md

Run these manually when preparing releases or updating documentation. The scripts handle the boring stuff while leaving creative content for manual editing.

πŸ“š API Documentation

Compilation Endpoints

  • POST /api/compile - Compile GGcode to G-code
  • POST /api/validate - Validate GGcode syntax
  • GET /api/compiler/status - Get compiler status

Examples Endpoints

  • GET /api/examples - List available examples
  • GET /api/examples/:filename - Get specific example

Help Endpoints

  • GET /api/help - Get help content
  • GET /api/help/:section - Get specific help section

πŸ—οΈ Architecture

Client-Side Architecture

The client uses a modular ES6 architecture with the following key components:

  • Monaco Editor Manager: Handles code editing with syntax highlighting
  • API Manager: Centralized API communication
  • Configurator Manager: Dynamic form generation and validation
  • Annotation System: Real-time G-code analysis
  • Modal Manager: UI modal management
  • File Operations: Import/export functionality

Server-Side Architecture

The server follows a layered architecture:

  • Routes Layer: Express route handlers
  • Services Layer: Business logic and data processing
  • Middleware Layer: Request processing and security
  • Configuration Layer: Environment and application settings

Module System

  • Client: ES6 modules for modern browser compatibility
  • Server: CommonJS modules for Node.js compatibility
  • Backward Compatibility: Global function exports for legacy HTML

πŸ”§ Configuration

Environment Variables

NODE_ENV=development|production|test
PORT=6990
HOST=localhost
COMPILER_LIB_PATH=/path/to/libggcode.so

Application Configuration

Configuration is managed through environment-specific files in src/server/config/:

  • environment.js - Environment-specific settings
  • index.js - Configuration manager

πŸ§ͺ Testing Strategy

Test Structure

  • Unit Tests: Individual component testing
  • Integration Tests: API endpoint testing
  • Client Tests: Browser-based component testing
  • Coverage: Comprehensive code coverage reporting

Test Commands

npm test              # Run all tests
npm run test:watch    # Watch mode
npm run test:coverage # With coverage report

πŸ“ˆ Performance

Optimization Features

  • Lazy Loading: Dynamic module loading
  • Code Splitting: Separate bundles for different features
  • Caching: Static asset caching in production
  • Compression: Gzip compression for responses
  • Rate Limiting: API rate limiting for security

Monitoring

  • Health Checks: /api/health endpoint
  • Error Tracking: Comprehensive error logging
  • Performance Metrics: Request timing and resource usage

πŸ”’ Security

Security Features

  • Input Validation: Comprehensive input sanitization
  • Rate Limiting: Protection against abuse
  • Security Headers: CSRF, XSS, and clickjacking protection
  • Content Security Policy: Strict CSP implementation
  • Error Handling: Secure error responses

🀝 Contributing

Development Workflow

  1. Fork the repository
  2. Create a feature branch
    git checkout -b feature/your-feature-name
  3. Make changes and test
    npm run build
    npm test
  4. Commit with conventional commits
    git commit -m "feat: add new feature"
  5. Push and create PR

Code Standards

  • ESLint: Code linting with custom rules
  • Prettier: Code formatting
  • Conventional Commits: Standardized commit messages
  • Test Coverage: Maintain >80% coverage

πŸ“„ License

ISC License - see LICENSE file for details

πŸ†˜ Support

Documentation

  • API Docs: Available at /api/docs when running
  • Help System: Built-in help at /help
  • Examples: Sample files in /examples

Troubleshooting

Common issues and solutions:

  1. Compilation Errors: Check libggcode.so path and permissions
  2. Port Conflicts: Change PORT in environment variables
  3. Module Errors: Ensure Node.js version >= 16.0.0

Getting Help

  • Issues: GitHub Issues for bug reports
  • Discussions: GitHub Discussions for questions
  • Documentation: In-app help system

Version History

  • v1.0.0: Initial modular architecture implementation
  • v0.9.x: Legacy monolithic structure

About

No description, website, or topics provided.

Resources

Contributing

Stars

Watchers

Forks

Packages

No packages published