# zerodevelops/zpause architecture

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

- Interactive diagram: https://gitdiagram.com/zerodevelops/zpause
- Repository: https://github.com/zerodevelops/zpause

## Overview

##### Project Type and Purpose
- zPause is a small standalone pause-menu “resource” for the FiveM framework (GTA V modding), implemented in Lua and an embedded HTML UI.
- It hooks into the client game, shows a minimal NUI (in-game browser) overlay, and communicates back to the client script; optionally the server script can handle remote logic (future extensibility).

##### File-Structure Analysis
- fxmanifest.lua
- Defines the resource, lists client.lua, server.lua, and NUI assets (HTML/CSS/JS).
- client/client.lua
- Listens for pause requests (e.g., key binds or game events), invokes the NUI resource, and handles NUI callbacks.
- server/server.lua
- (Optional) Receives events from the client for server-side checks or data; can broadcast events back to clients.
- html/
- index.html, listener.js, style.css, reset.css — the NUI interface loaded into the game’s browser context.
- LICENSE & README.md
- Documentation only; not part of runtime.

##### Key Components
a. Client Component (Lua)
- Sub-components: Input listener (pause key), NUI invoker, NUI callback handler.
b. NUI (HTML/JS/CSS)
- Static assets served by FiveM’s built-in HTTP server to the in-game browser.
- JS listens for DOM events (hover, click), sends messages to the client via `SendNuiMessage` & listens to `RegisterNuiCallbackType`.
c. Server Component (Lua)
- Receives events from client (e.g., “pauseMenuOpened”) via `TriggerServerEvent`; optionally sends back via `TriggerClientEvent`.
d. fxmanifest
- Resource manifest orchestrating registration of client, server, and NUI files.

##### Relationships & Data Flows
1. Client Input → Client Lua
2. Client Lua → NUI (Load HTML/CSS/JS)
3. User Interaction (Hover/Click) → listener.js → Client Lua (via NUI events)
4. Client Lua → Server Lua (TriggerServerEvent)
5. Server Lua → Client Lua (TriggerClientEvent), if used
- That all UI assets are local files loaded via the resource; there is no external HTTP dependency.

##### Architectural Patterns & Principles
- Separation of concerns: UI (HTML/CSS/JS) is completely decoupled from game logic (Lua).
- Event-driven communication: NUI events ↔ client Lua ↔ server Lua.
- Resource manifest pattern: fxmanifest orchestrates registrations and asset bundling.

## Diagram (Mermaid)

```mermaid
flowchart TD
    fx["fxmanifest.lua\n(Resource Manifest)"]:::manifest

    subgraph "zPause Resource"
        direction TB

        fx --> cl

        subgraph "Client Script"
            direction TB
            cl["Client Lua\n(client/client.lua)"]:::client
        end

        subgraph "NUI UI Layer"
            direction TB
            ui1["index.html"]:::ui
            ui2["listener.js"]:::ui
            ui3["style.css"]:::ui
            ui4["reset.css"]:::ui
        end

        subgraph "Server Script"
            direction TB
            sv["Server Lua\n(server/server.lua)"]:::server
        end
    end

    cl -->|Load UI| ui1
    ui2 -->|NUI Callback| cl
    cl -->|TriggerServerEvent| sv
    sv -->|TriggerClientEvent| cl

    click fx "https://github.com/zerodevelops/zpause/blob/main/fxmanifest.lua"
    click cl "https://github.com/zerodevelops/zpause/blob/main/client/client.lua"
    click sv "https://github.com/zerodevelops/zpause/blob/main/server/server.lua"
    click ui1 "https://github.com/zerodevelops/zpause/blob/main/html/index.html"
    click ui2 "https://github.com/zerodevelops/zpause/blob/main/html/listener.js"
    click ui3 "https://github.com/zerodevelops/zpause/blob/main/html/style.css"
    click ui4 "https://github.com/zerodevelops/zpause/blob/main/html/reset.css"

    classDef ui fill:#ffcc99,stroke:#e69500;
    classDef client fill:#cce5ff,stroke:#3399ff;
    classDef server fill:#d5f5e3,stroke:#27ae60;
    classDef manifest fill:#ebd6ff,stroke:#8e44ad;
```
