Skip to content

Architecture

System Overview

wtf_group is a FiveM resource built on a client-server architecture with a React-based NUI (tablet UI) that communicates through a Lua bridge layer.

┌─────────────────────────────────────────────────────────────────┐
│                        FiveM Client                              │
│                                                                  │
│  ┌──────────┐  ┌──────────────────┐  ┌────────────────────────┐ │
│  │  Bridge   │  │   Client Lua     │  │   NUI (React UI)       │ │
│  │           │  │                  │  │                        │ │
│  │  QBX      │◄─┤  tablet.lua      │◄─┤  TabletShell           │ │
│  │  QBCore   │  │  sync.lua        │  │  ├── Desktop            │ │
│  │  ESX      │  │  nui.lua         │  │  ├── Taskbar            │ │
│  │  Stand    │  │  blips.lua       │  │  ├── Windows            │ │
│  │           │  │  vpn.lua         │  │  ├── StartMenu          │ │
│  │           │  │  auction.lua     │  │  ├── SystemTray         │ │
│  │           │  │  contracts.lua   │  │  └── 18 Apps            │ │
│  └──────────┘  └────────┬─────────┘  └────────────────────────┘ │
│                          │                                        │
├──────────────────────────┼────────────────────────────────────────┤
│                     FiveM Server                                  │
│                          │                                        │
│  ┌──────────┐  ┌────────┴─────────┐  ┌────────────────────────┐ │
│  │  Bridge   │  │   Server Lua     │  │   MySQL (oxmysql)      │ │
│  │           │◄─┤                  │◄─┤                        │ │
│  │           │  │  database.lua    │  │   32 tables            │ │
│  │           │  │  group.lua       │  │                        │ │
│  │           │  │  tablet.lua      │  │                        │ │
│  │           │  │  vpn.lua         │  │                        │ │
│  │           │  │  auction.lua     │  │                        │ │
│  │           │  │  contracts.lua   │  │                        │ │
│  │           │  │  weather.lua     │  │                        │ │
│  │           │  │  sync.lua        │  │                        │ │
│  └──────────┘  └──────────────────┘  └────────────────────────┘ │
└─────────────────────────────────────────────────────────────────┘

Data Flow

NUI → Server

React Component
  → nuiFetch(callbackName, data)       -- ui/src/nui.js
  → RegisterNUICallback()              -- client/*.lua
  → TriggerServerEvent()               -- client → server
  → MySQL.query/insert/update          -- oxmysql
  → TriggerClientEvent()               -- server → client
  → SendNUIMessage()                   -- client → React
  → window.addEventListener('message') -- ui/src/nui.js

Settings & App Data

React UI ←→ useTablet() hook ←→ localStorage (instant)

         dbStorage.js → NUI callback → Client → Server → MySQL

Settings are written to both localStorage (instant UI response) and MySQL (durable persistence). On mount, MySQL values override localStorage.

Key Components

Bridge Layer (bridge/)

Framework abstraction that provides a unified API across Qbox, QBCore, ESX, and standalone:

lua
Bridge.GetPlayerData(source)
Bridge.GetMoney(source, 'bank')
Bridge.AddMoney(source, 'bank', amount, reason)
Bridge.RemoveMoney(source, 'bank', amount, reason)
Bridge.GetPlayerJob(source)
Bridge.GetPlayerGang(source)

See Bridge Overview for details.

Client Lua (client/)

FilePurpose
main.luaResource init, command registration, keybinds
tablet.luaTablet open/close, NUI bridge, app messaging
sync.luaReal-time group state synchronization
nui.luaNUI callback handlers for group operations
blips.luaGPS blip system, vehicle detection
vpn.luaVPN NUI callbacks + event listeners
auction.luaAuction NUI callbacks + event listeners
contracts.luaContract NUI callbacks + event listeners

Server Lua (server/)

FilePurpose
database.luaSchema (32 tables), all DB functions
group.luaCore group logic, create/disband/leave
tablet.luaServer-side tablet handlers, data API
sync.luaServer→client state broadcasting
task.luaTask creation, activation, completion
reputation.luaXP, levels, perks
roles.luaRole assignment, permissions
alliance.luaAlliance/war system
turfs.luaTerritory claiming, challenges
bounty.luaBounty board, claiming
mailbox.luaInternal mail system
garage.luaVehicle storage, spawning
dashboard.luaDashboard data aggregation
cooldown.luaGlobal and per-activity cooldowns
vpn.luaVPN proxy management, license keys
auction.luaAuction server logic, bidding, wallet
contracts.luaContract buying, starting, stock, queue
weather_control.luaRenewed-Weathersync admin controls

React UI (ui/src/)

DirectoryPurpose
apps/18 tablet apps (VPN, Auction, Weather, etc.)
components/26+ shared UI components
context/React contexts (Group, Tablet, App)
shell/Tablet OS shell (Desktop, Taskbar, Window, etc.)
lib/Utilities (settings, icons, sounds, DB storage)
styles/CSS (tablet theme, animations)

Database Schema

32 MySQL tables organized by feature:

GroupTables
Group Corewtf_groups, wtf_group_members, wtf_group_roles, wtf_group_activity_log, wtf_group_reputation, wtf_group_spawns
Featureswtf_tasks, wtf_global_cooldowns, wtf_group_alliances, wtf_turfs, wtf_turf_challenges, wtf_bounties, wtf_mailbox, wtf_garage
Tabletwtf_tablet_app_data, wtf_tablet_notifications, wtf_tablet_settings, wtf_tablet_installed_apps
VPNwtf_vpn_proxies, wtf_vpn_license_keys
Auctionauction_listings, auction_bids, auction_watchlist, auction_balances, auction_accounts, auction_sessions, auction_settings
Contractswtf_contract_stock, wtf_contract_active, wtf_contract_inventory, wtf_contract_start_queue, wtf_contract_history

See Database Reference for full schema.

NUI Message Protocol

All React ↔ Lua communication uses SendNUIMessage with action strings:

ActionDirectionDescription
groupSyncServer→ReactGroup state update
vpnDataServer→ReactVPN connection status
auctionResponseServer→ReactAuction action result
contractsResponseServer→ReactContract action result
tablet:settingsLoadedServer→ReactSettings loaded from DB
tablet:appDataLoadedServer→ReactApp data loaded from DB

See Events Reference for the complete list.

AIFAZI — FiveM Resources