# mistextreme/rup-vehiclespawner architecture

> Architecture diagram of the GitHub repository mistextreme/rup-vehiclespawner, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-09). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mistextreme/rup-vehiclespawner
- Repository: https://github.com/mistextreme/rup-vehiclespawner

## Overview

#### Purpose and Runtime
`rup-vehiclespawner` is a FiveM resource for browsing and spawning vehicles through an in-game NUI menu. The resource manifest at `fxmanifest.lua` defines the client/server scripts and web UI entry page.

#### Resource Entry Points
- `fxmanifest.lua` is the FiveM integration boundary, loading shared configuration plus client and server runtime scripts.
- `client/client.lua` is the main gameplay-side entry point: it receives user input/menu actions and performs vehicle-spawn behavior.
- `server/server.lua` is the server-side entry point for authoritative events and coordination.
- `web/index.html` starts the browser-based NUI interface.

#### Client Menu and Spawn Flow
The client layer opens the NUI, supplies vehicle/menu data, and receives browser callbacks:
- `client/client.lua` owns player-facing control flow and native FiveM interactions.
- `client/export_menu.lua` exposes menu-opening behavior for other resources.
- `client/export_result.lua` exposes selection/spawn results or related integration output.

The browser sends the selected vehicle/action back to the Lua client; the client is the boundary between untrusted UI input and FiveM game natives.

#### Vehicle Data and Custom Images
Vehicle catalog/content is data-driven:
- `data.json` provides the primary vehicle data source.
- `1.json` is an additional packaged data file.
- `custom_images.json` and `web/custom-images.json` map vehicles to custom UI imagery.

The web layer consumes the catalog/image mappings to render choices, while the client/server scripts use selection identifiers to drive spawning or export behavior.

#### NUI Front End
The embedded web application renders the vehicle selector and interaction feedback:
- `web/index.html` defines the NUI document.
- `web/script.js` implements menu state, selection handling, and FiveM NUI messaging/callbacks.
- `web/style.css` provides presentation.
- `web/images` contains vehicle/menu imagery; `web/sound` contains UI feedback audio.

This is not a standalone web deployment: it runs in FiveM’s Chromium NUI environment and communicates with Lua through NUI messages.

#### Server Responsibilities and Updates
Server logic is split between operational event handling and update support:
- `server/server.lua` handles server runtime behavior and client-triggered server events.
- `server/export_vehicles.lua` exposes vehicle-related functionality to dependent FiveM resources.
- `server/updater.lua` implements resource update/version-related behavior, likely involving an external remote endpoint.

Server code forms the trust/coordination boundary for actions that should not be left solely to the client.

#### Configuration and Integration Surface
- `config.lua` centralizes resource behavior/settings shared by runtime scripts.
- `client/export_menu.lua`, `client/export_result.lua`, and `server/export_vehicles.lua` are the intended cross-resource API surface.
- FiveM/Cfx.re is the material host platform; its client natives, server event system, exports, and NUI bridge are the core infrastructure dependencies.

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_fivem["FiveM Host"]
  node_manifest["Resource Manifest<br/>FiveM manifest<br/>[fxmanifest.lua]"]
  node_platform{{"FiveM/Cfx.re<br/>host platform"}}
  node_config["Shared Config<br/>Lua configuration<br/>[config.lua]"]
end

subgraph group_client["Client Runtime"]
  node_client_main["Gameplay Controller<br/>client Lua<br/>[client.lua]"]
  node_menu_export["Menu Export<br/>client export<br/>[export_menu.lua]"]
  node_result_export["Result Export<br/>client export<br/>[export_result.lua]"]
end

subgraph group_server["Server Runtime"]
  node_server_main["Server Coordinator<br/>server Lua<br/>[server.lua]"]
  node_vehicle_export["Vehicle Export<br/>server export"]
  node_updater["Update Support<br/>server updater<br/>[updater.lua]"]
end

subgraph group_nui["NUI Front End"]
  node_nui_page["NUI Document<br/>HTML entry<br/>[index.html]"]
  node_nui_app["Vehicle Selector<br/>browser JavaScript<br/>[script.js]"]
  node_nui_style["NUI Presentation<br/>CSS<br/>[style.css]"]
  node_nui_assets["Images and Sounds<br/>UI assets"]
end

subgraph group_content["Vehicle Content"]
  node_catalog[("Vehicle Catalog<br/>vehicle data<br/>[data.json]")]
  node_extra_catalog[("Additional Vehicle Data<br/>[1.json]")]
  node_image_map["Custom Image Maps<br/>image mapping data<br/>[custom_images.json]"]
  node_web_image_map["Web Image Map<br/>image mapping data<br/>[custom-images.json]"]
end

node_manifest -->|"resource registration"| node_platform
node_manifest -->|"loads"| node_config
node_manifest -->|"loads client"| node_client_main
node_manifest -->|"loads server"| node_server_main
node_manifest -->|"sets UI page"| node_nui_page
node_config -->|"settings"| node_client_main
node_config -->|"settings"| node_server_main
node_menu_export -->|"opens menu"| node_client_main
node_client_main -->|"publishes result"| node_result_export
node_client_main -->|"NUI messages"| node_nui_app
node_nui_app -->|"selection callback"| node_client_main
node_client_main -->|"vehicle natives"| node_platform
node_client_main -->|"server events"| node_server_main
node_server_main -->|"exposes vehicles"| node_vehicle_export
node_server_main -->|"update support"| node_updater
node_nui_page -->|"loads"| node_nui_app
node_nui_page -->|"styles"| node_nui_style
node_nui_app -->|"uses"| node_nui_assets
node_catalog -->|"vehicle choices"| node_nui_app
node_extra_catalog -->|"additional choices"| node_nui_app
node_image_map -->|"image mapping"| node_nui_app
node_web_image_map -->|"web image mapping"| node_nui_app
node_nui_app -->|"vehicle identifier"| node_client_main

click node_manifest "https://github.com/mistextreme/rup-vehiclespawner/blob/main/fxmanifest.lua"
click node_config "https://github.com/mistextreme/rup-vehiclespawner/blob/main/config.lua"
click node_client_main "https://github.com/mistextreme/rup-vehiclespawner/blob/main/client/client.lua"
click node_menu_export "https://github.com/mistextreme/rup-vehiclespawner/blob/main/client/export_menu.lua"
click node_result_export "https://github.com/mistextreme/rup-vehiclespawner/blob/main/client/export_result.lua"
click node_server_main "https://github.com/mistextreme/rup-vehiclespawner/blob/main/server/server.lua"
click node_vehicle_export "https://github.com/mistextreme/rup-vehiclespawner/blob/main/server/export_vehicles.lua"
click node_updater "https://github.com/mistextreme/rup-vehiclespawner/blob/main/server/updater.lua"
click node_nui_page "https://github.com/mistextreme/rup-vehiclespawner/blob/main/web/index.html"
click node_nui_app "https://github.com/mistextreme/rup-vehiclespawner/blob/main/web/script.js"
click node_nui_style "https://github.com/mistextreme/rup-vehiclespawner/blob/main/web/style.css"
click node_nui_assets "https://github.com/mistextreme/rup-vehiclespawner/tree/main/web/images"
click node_catalog "https://github.com/mistextreme/rup-vehiclespawner/blob/main/data.json"
click node_extra_catalog "https://github.com/mistextreme/rup-vehiclespawner/blob/main/1.json"
click node_image_map "https://github.com/mistextreme/rup-vehiclespawner/blob/main/custom_images.json"
click node_web_image_map "https://github.com/mistextreme/rup-vehiclespawner/blob/main/web/custom-images.json"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_manifest,node_platform,node_config toneBlue
class node_client_main,node_menu_export,node_result_export toneAmber
class node_server_main,node_vehicle_export,node_updater toneMint
class node_nui_page,node_nui_app,node_nui_style,node_nui_assets toneRose
class node_catalog,node_extra_catalog,node_image_map,node_web_image_map toneIndigo
```

## Components

### FiveM Host

- [Resource Manifest](https://github.com/mistextreme/rup-vehiclespawner/blob/main/fxmanifest.lua): FiveM manifest · Registers runtime scripts and the NUI page. · `fxmanifest.lua`
- **FiveM/Cfx.re**: host platform · Provides natives, events, exports, and the NUI bridge.
- [Shared Config](https://github.com/mistextreme/rup-vehiclespawner/blob/main/config.lua): Lua configuration · `config.lua`

### Client Runtime

- [Gameplay Controller](https://github.com/mistextreme/rup-vehiclespawner/blob/main/client/client.lua): client Lua · Controls menu input and vehicle spawning through FiveM natives. · `client/client.lua`
- [Menu Export](https://github.com/mistextreme/rup-vehiclespawner/blob/main/client/export_menu.lua): client export · Cross-resource menu-opening API. · `client/export_menu.lua`
- [Result Export](https://github.com/mistextreme/rup-vehiclespawner/blob/main/client/export_result.lua): client export · Cross-resource selection and spawn result API. · `client/export_result.lua`

### Server Runtime

- [Server Coordinator](https://github.com/mistextreme/rup-vehiclespawner/blob/main/server/server.lua): server Lua · Handles authoritative events and coordination. · `server/server.lua`
- [Vehicle Export](https://github.com/mistextreme/rup-vehiclespawner/blob/main/server/export_vehicles.lua): server export · Vehicle API for dependent resources. · `server/export_vehicles.lua`
- [Update Support](https://github.com/mistextreme/rup-vehiclespawner/blob/main/server/updater.lua): server updater · Performs version and resource update checks. · `server/updater.lua`

### NUI Front End

- [NUI Document](https://github.com/mistextreme/rup-vehiclespawner/blob/main/web/index.html): HTML entry · `web/index.html`
- [Vehicle Selector](https://github.com/mistextreme/rup-vehiclespawner/blob/main/web/script.js): browser JavaScript · Maintains menu state and sends NUI callbacks. · `web/script.js`
- [NUI Presentation](https://github.com/mistextreme/rup-vehiclespawner/blob/main/web/style.css): CSS · `web/style.css`
- [Images and Sounds](https://github.com/mistextreme/rup-vehiclespawner/tree/main/web/images): UI assets · `web/images`

### Vehicle Content

- [Vehicle Catalog](https://github.com/mistextreme/rup-vehiclespawner/blob/main/data.json): vehicle data · Primary packaged vehicle definitions. · `data.json`
- [Additional Vehicle Data](https://github.com/mistextreme/rup-vehiclespawner/blob/main/1.json): vehicle data · `1.json`
- [Custom Image Maps](https://github.com/mistextreme/rup-vehiclespawner/blob/main/custom_images.json): image mapping data · Maps vehicle identifiers to UI imagery. · `custom_images.json`
- [Web Image Map](https://github.com/mistextreme/rup-vehiclespawner/blob/main/web/custom-images.json): image mapping data · `web/custom-images.json`

## Connections

- Resource Manifest → FiveM/Cfx.re: resource registration
- Resource Manifest → Shared Config: loads
- Resource Manifest → Gameplay Controller: loads client
- Resource Manifest → Server Coordinator: loads server
- Resource Manifest → NUI Document: sets UI page
- Shared Config → Gameplay Controller: settings
- Shared Config → Server Coordinator: settings
- Menu Export → Gameplay Controller: opens menu
- Gameplay Controller → Result Export: publishes result
- Gameplay Controller → Vehicle Selector: NUI messages
- Vehicle Selector → Gameplay Controller: selection callback · Untrusted browser input enters the game client here.
- Gameplay Controller → FiveM/Cfx.re: vehicle natives
- Gameplay Controller → Server Coordinator: server events
- Server Coordinator → Vehicle Export: exposes vehicles
- Server Coordinator → Update Support: update support
- NUI Document → Vehicle Selector: loads
- NUI Document → NUI Presentation: styles
- Vehicle Selector → Images and Sounds: uses
- Vehicle Catalog → Vehicle Selector: vehicle choices
- Additional Vehicle Data → Vehicle Selector: additional choices
- Custom Image Maps → Vehicle Selector: image mapping
- Web Image Map → Vehicle Selector: web image mapping
- Vehicle Selector → Gameplay Controller: vehicle identifier
