EML Docs

Frontend architecture

Whether you are using our EML Template or building your launcher from scratch, the interface is the most important part for your players. It determines how they interact with your server.

This guide defines the recommended architecture, the necessary views to implement, and best practices for connecting your UI to the EML logic.

Architecture guidelines

The Single Page Application (SPA) model

We strongly recommend building your launcher as a Single Page Application. Instead of having multiple HTML files (login.html, home.html) that cause a white flash when switching pages, you should have one single index.html file.

How it works:

  • All “pages” (login, home, settings) are just <div> containers inside index.html.
  • You use JavaScript (or CSS) to hide/show these containers to simulate navigation.
  • Benefit: Instant transitions and a native app feel.

Understanding IPC (Inter-Process Communication)

The two-process model

This is the most critical concept to understand in Electron.

  • The UI (renderer): This is your HTML/button. It cannot download files or launch Java directly. It is sandboxed for security.
  • The logic (main): This is where EML Lib runs. It has access to the disk and network.

The flow:

  1. renderer: User clicks “Play”.
  2. renderer: Sends a message (ipcRenderer.send('start-game')) to the main process.
  3. main: Receives the message, runs launcher.launch(), and sends back progress events.
  4. renderer: Listens for progress (ipcRenderer.on('progress')) and updates the progress bar.

Setting up IPC

Best practices for code structure

If you are building from scratch, keeping your code organized is vital. Here is a recommended structure for a Vanilla JS/TS project (replace .js with .ts if using TypeScript):

/
├─ package.json
├─ vite.config.js
│
├─ electron/
│  ├─ main.js                     # Main process
│  ├─ preload.js                  # Expose IPC methods to renderer (via ipc.ts)
│  └─ handlers/
│     ├─ auth.js                  # IPC handlers for authentication
│     ├─ launcher.js              # IPC handlers for launcher actions
│     └─ ...                      # Other IPC handlers
│
├─ src/
│  ├─ index.html                  # Single HTML file with all views
│  ├─ app.js                      # Core app logic
│  ├─ init.js                     # Initialize launcher (auto-login, bootstrap, ...)
│  ├─ ipc.ts                      # Expose IPC methods to renderer
│  ├─ state.js                    # State management (switching views, ...)                  
│  ├─ views/
│  │  ├─ login.js                 # Login logic (buttons, forms, ...)
│  │  ├─ home.js                  # Home logic
│  │  └─ ...
│  └─ static/
│     ├─ images/
│     │  ├─ logo.png              # Launcher logo
│     │  └─ ...                   # Other static images
│     └─ styles/
│        ├─ _variables.scss       # Global SCSS variables
│        ├─ main.scss             # Main stylesheet
│        ├─ login.scss            # Login view styles
│        └─ ...                   # Other view styles
│
└─ build/                         # Build assets
   ├─ icon.png
   ├─ icon.icns
   └─ ...

Tip

If using EML Template, this structure is mostly already set up for you. If building from scratch, don’t hesitate to look at EML Template code for inspiration.

Designing the views

Here is the checklist of views (screens) you need to implement to handle all EML features.

Note

Every feature below is documented in later chapters.

Login view

This is the entry point.

Home view

This is the main hub where players land after logging in.

Settings view

Allow users to tweak the launcher performance.

Maintenance & Update views

These are “blocking” views. They should overlay everything else when active.

  • Maintenance: Controlled by EML AdminTool. It should show the reason for maintenance and prevent access to the “Play” button.

  • Bootstrap Update: When the launcher itself needs an update (managed by the Bootstraps feature), this view should show a spinner or a download bar while the new version is being downloaded.

Development tools

Using DevTools

Since Electron is based on Chromium, you have access to the full Chrome DevTools.

  • Shortcut: Ctrl + Shift + I (Windows/Linux) or Cmd + Option + I (macOS).
  • Use the Elements tab to debug your CSS.
  • Use the Console tab to see logs from the renderer process.

Note

Logs from EML Lib (download progress, auth errors) usually appear in your terminal (where you ran npm run dev), not in the browser console, because they run in the main process. You need to forward them via IPC if you want to see them in the browser console.

Important

The next chapters are API references. To implement the features described there, you need to understand the architecture outlined in this chapter. Do not hesitate to look at EML Template code for examples.