# lunarfn/autohost architecture

> Architecture diagram of the GitHub repository lunarfn/autohost, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-06-04). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/lunarfn/autohost
- Repository: https://github.com/lunarfn/autohost

## Overview

##### Project type and purpose
- From the file tree and README, “Lunar Engine” is a Node.js–based command‐line tool (no web frontend) whose primary function is to host dedicated game servers continuously and provide an SSL‐bypass mechanism via DLL injection.

##### File structure
- Top level:
- package.json / package-lock.json → Node.js dependencies and scripts
- install.cmd / start.cmd → Windows batch scripts to install & launch
- src/main.js → the application’s entry point
- src/utils/log.js → a logging utility
- No separate frontend or configuration sub‐apps; this is a single codebase orchestrating both npm modules and a native‐code injector.

##### Extract README insights
- Requires Visual Studio Build Tools to compile or package the DLL injector.
- install.cmd runs npm install; start.cmd runs the Node.js process.
- Features call out (a) hosting 24/7 dedicated servers and (b) performing an SSL bypass to interact with MCP (game-client).

##### Key components
a. Node.js Application
- main.js (“Orchestrator”)
- utils/log.js (Logging)
- npm dependencies (injected as modules at runtime)
b. Native Toolchain
- VS Build Tools (cl.exe, linker) → DLL injector build
- Resulting DLL
c. Game Process & Network
- Game Server process (spawned or proxied)
- Game Client (MCP) with SSL bypass
d. External Services (if any)
- Optional central server registry or matchmaking (not shown in code but might exist conceptually)

##### Relationships & interactions
- Node.js main.js launches or injects the DLL into the running Game Process.
- The DLL hooks SSL calls in the Game Client to bypass certificate checks.
- Node.js may start/monitor a local Game Server instance for 24/7 hosting.
- Logging utility records events, errors, and injection status.
- Batch scripts (install.cmd / start.cmd) wrap the npm and node commands.

##### Architectural patterns / principles
- Single‐process orchestrator with modularized utilities (logging)
- Hybrid JavaScript + native code (DLL injection)
- Separation of concerns:
- Build stage (install.cmd + VS Build Tools → compile .dll)
- Launch stage (start.cmd → node src/main.js)
- Runtime hooks (DLL + Node.js interop)

##### Detail
- Every module and script (package.json, .cmd files, utils).
- External dependencies (npm registry, VS Build Tools download link).
- Two main use cases: server hosting and SSL bypass.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Documentation
    DOC["README.md"]:::ext
    LIC["LICENSE"]:::ext

    %% Build Stage
    subgraph "Build Stage"
        ICS["install.cmd"]:::ext
        NPMI["npm install (package.json / package-lock.json)"]:::js
        VS["VS Build Tools"]:::native
        COMPILE["Compile DLL Injector"]:::native
        DLL["DLL Injector"]:::native

        DOC --> ICS
        LIC --> ICS
        ICS -->|"runs npm install"| NPMI
        NPMI -->|"requires VS Build Tools"| VS
        VS -->|"compiles"| COMPILE
        COMPILE -->|"produces"| DLL
    end

    %% Runtime Stage
    subgraph "Runtime Stage"
        SCS["start.cmd"]:::ext
        MAIN["src/main.js"]:::js
        LOG["src/utils/log.js"]:::js
        PKG["package.json"]:::js
        LOCK["package-lock.json"]:::js
        SERVER["Game Server Process"]:::ext
        CLIENT["Game Client Process (MCP)"]:::ext
        NETWORK["Network / SSL"]:::ext

        DOC --> SCS
        LIC --> SCS
        SCS -->|"runs node"| MAIN
        MAIN -->|"loads manifest"| PKG
        MAIN -->|"loads lockfile"| LOCK
        MAIN -->|"uses logging"| LOG
        MAIN -->|"spawns/monitors"| SERVER
        MAIN -->|"injects DLL"| CLIENT
        SERVER -->|"hosts server"| NETWORK
        CLIENT -->|"SSL bypass hooks"| NETWORK
        DLL -->|"injection payload"| CLIENT
    end

    %% Click Events
    click MAIN "https://github.com/lunarfn/autohost/blob/main/src/main.js"
    click LOG "https://github.com/lunarfn/autohost/blob/main/src/utils/log.js"
    click PKG "https://github.com/lunarfn/autohost/blob/main/package.json"
    click LOCK "https://github.com/lunarfn/autohost/blob/main/package-lock.json"
    click ICS "https://github.com/lunarfn/autohost/blob/main/install.cmd"
    click SCS "https://github.com/lunarfn/autohost/blob/main/start.cmd"
    click DOC "https://github.com/lunarfn/autohost/blob/main/README.md"
    click LIC "https://github.com/lunarfn/autohost/tree/main/LICENSE"

    %% Styles
    classDef js fill:#ADD8E6,stroke:#000,stroke-width:1px
    classDef native fill:#98FB98,stroke:#000,stroke-width:1px
    classDef ext fill:#D3D3D3,stroke:#000,stroke-width:1px
```
