# azatakmyradov/sagex3-compiler-server architecture

> Architecture diagram of the GitHub repository azatakmyradov/sagex3-compiler-server, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/azatakmyradov/sagex3-compiler-server
- Repository: https://github.com/azatakmyradov/sagex3-compiler-server

## Overview

##### Project Type Analysis
This is a specialized development tool that serves as a compiler service for Sage X3 Adonix, with integration into VSCode through an extension. It's designed to run as a persistent service using PM2 process manager.

##### Main Components

A. Core Service Components:
- Adonix Compiler Service (Main Process)
- Configuration Manager
- Command Handler
- Type Definitions System

B. External Integrations:
- VSCode Extension (External Component)
- Sage X3 Environment
- PM2 Process Manager

**┌─────────────────────────────────────────────┐**
- VSCode Extension               │
- ┘
- ↕
**┌─────────────────────────────────────────────┐**
- Adonix Compiler Service          │
- ┬──────────────┬───────────┤
- Adonix.ts    │  Command.ts  │ helpers.ts│
- (Core Logic)  │(CMD Handler) │(Utilities)│
- ┴──────────────┴───────────┘
- ↕
**┌─────────────────────────────────────────────┐**
- Sage X3 Environment            │
- ┘

##### Component Details

a) Service Layer:
- Main service entry point (main.ts)
- Adonix compiler core (Adonix.ts)
- Command handling system (Command.ts)
- Helper utilities (helpers.ts)

b) Configuration Layer:
- Environment configuration (.env)
- Application configuration (app.config.cjs)
- TypeScript configuration (tsconfig.json)

c) Integration Points:
- VSCode Extension connection
- Sage X3 environment interaction
- PM2 process management

##### Important Elements to Emphasize

a) Data Flow:
- How commands flow from VSCode to the compiler service
- How the compiler interacts with the Sage X3 environment
- Configuration loading paths

b) Process Management:
- PM2's role in maintaining the service
- Startup/shutdown flows (start.bat, stop.bat)

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph IDE
        VSCode[VSCode Extension]
    end

    subgraph Core ["Core Service Layer"]
        Main["Main Process"]:::core
        Adonix["Adonix Compiler"]:::core
        Command["Command Handler"]:::core
        Helpers["Utility Functions"]:::core
        Types["Type Definitions"]:::core
    end

    subgraph Config ["Configuration Layer"]
        EnvConfig[".env Configuration"]:::config
        AppConfig["Application Config"]:::config
        TSConfig["TypeScript Config"]:::config
    end

    subgraph Process ["Process Management"]
        PM2["PM2 Process Manager"]:::process
        Start["Start Script"]:::process
        Stop["Stop Script"]:::process
        Update["Update Script"]:::process
    end

    subgraph External ["External Systems"]
        SageX3["Sage X3 Environment"]:::external
    end

    %% Relationships
    VSCode --> Main
    Main --> Adonix
    Main --> Command
    Adonix --> Helpers
    Adonix --> Types
    Command --> Helpers
    
    EnvConfig --> Main
    AppConfig --> Main
    TSConfig --> Main
    
    PM2 --> Main
    Start --> PM2
    Stop --> PM2
    Update --> PM2
    
    Adonix --> SageX3

    %% Click Events
    click Main "https://github.com/azatakmyradov/sagex3-compiler-server/blob/main/src/main.ts"
    click Adonix "https://github.com/azatakmyradov/sagex3-compiler-server/blob/main/src/Adonix.ts"
    click Command "https://github.com/azatakmyradov/sagex3-compiler-server/blob/main/src/Command.ts"
    click Types "https://github.com/azatakmyradov/sagex3-compiler-server/blob/main/src/types/index.d.ts"
    click EnvConfig "https://github.com/azatakmyradov/sagex3-compiler-server/blob/main/.env.example"
    click AppConfig "https://github.com/azatakmyradov/sagex3-compiler-server/blob/main/app.config.cjs"
    click TSConfig "https://github.com/azatakmyradov/sagex3-compiler-server/blob/main/tsconfig.json"
    click Start "https://github.com/azatakmyradov/sagex3-compiler-server/blob/main/start.bat"
    click Stop "https://github.com/azatakmyradov/sagex3-compiler-server/blob/main/stop.bat"
    click Update "https://github.com/azatakmyradov/sagex3-compiler-server/blob/main/update.bat"
    click Helpers "https://github.com/azatakmyradov/sagex3-compiler-server/blob/main/src/helpers.ts"

    %% Styles
    classDef core fill:#2374ab,stroke:#2374ab,color:#fff
    classDef config fill:#ffd400,stroke:#ffd400,color:#000
    classDef process fill:#ff7d00,stroke:#ff7d00,color:#fff
    classDef external fill:#4caf50,stroke:#4caf50,color:#fff

    %% Legend
    subgraph Legend
        CoreLegend["Core Components"]:::core
        ConfigLegend["Configuration"]:::config
        ProcessLegend["Process Management"]:::process
        ExternalLegend["External Systems"]:::external
    end
```
