Development ​
Layout ​
fxmanifest.lua
shared/lib/ Ident namespace, bridge selection, validation (Ident.v.*), JSON, dates, serials
shared/config.lua Config.*
shared/locales.lua Lua strings (de / en), including error.<code>
shared/documents.lua built-in document types (Documents) and exams (Exams)
shared/np_admin_settings.lua settings registered in np_admin
bridge/np_admin.lua vendored np_admin lib (npAdmin.*), works without np_admin
bridge/framework/ client + server: 0_common 1_qbx 2_qb 3_esx 9_standalone
bridge/inventory/server/ 0_common 1_ox 2_qb 3_esx 9_none
bridge/mdt/server/ 9_none
server/core/ 00_init 01_schema 02_rpc 03_types 04_players 05_notify 06_log 07_api
server/modules/ documents desk issue police badge forger weapons designer phone maintenance np_admin
client/core/ 00_state 01_nui 02_rpc 03_framework 04_anim
client/modules/ picker viewer badge desk issue police forger designer notify
sql/install.sql schema (also created at start)
web/ NUI (React 18 + Vite 5 + TS strict + Zustand) and the np_phone app
docs/ ARCHITECTURE.md (contract), items.md
tests/ plain-Lua harness + run.lua
Load order: shared lib → config → locales → documents → bridges → core → modules. There is one global table,
Ident. Code resolves Ident.X when it is called, never in a file-level local, because X may be defined by a file
that loads later. Lua files must also parse with plain lua 5.4 / 5.5, so the harness can load them.
NUI ​
cd web
npm install
npm run dev # http://localhost:5181/?view=viewer browser dev mode with a mock backend and a dev panel
npm run build # FiveM guard check + typecheck + vite build → dist/index.html, dist/phone.html
npm test # contract check + vitest
npm run check:contract # RPC names, NUI actions, net events and error codes vs the Lua side
npm run gen:types # regenerate src/dev/types.generated.ts from ../shared/documents.lua (needs lua 5.4 / 5.5)
Outside FiveM, rpc() goes to src/dev/mock.ts, an in-memory backend with the server's shapes and error codes
(sample character Aiden Pearce, nearby players, documents in every state). Keep it in sync: the contract check fails
when an RPC has no mock case. npm run build also runs a guard that fails when backdrop-filter isn't disabled for
FiveM.
| URL parameter | Values |
|---|---|
view |
picker, viewer, badge, desk, issue, check, forger, designer, or gallery (every built-in type front and back, §ion=types|states) |
shot |
1: hide the dev panel (for screenshots) |
request |
1: show the police request toast |
locale |
en |
step |
Desk: data, exam, photo, pay |
tab |
Designer: design, fields, back, versions |
type |
Designer: a type key |
demo |
Designer: 1 publishes v1 and leaves a v2 draft plus a local edit |
publish / desk |
Designer: 1 opens the publish dialog / the desk dialog |
compare |
Designer versions tab: v0 compares with an archived version |
The phone app runs from phone.html (http://localhost:5181/phone.html) with its own mock.
Screenshots ​
The view screenshots in web/screenshots/ are 1920 × 1080 renders of the dev build with &shot=1 (for example
?view=check&shot=1 or ?view=designer&type=service_id&tab=fields&demo=1&shot=1); the phone ones are 400 × 860 from
phone.html. Built files use ES modules, so serve them (npx vite preview --port 4321) instead of opening them from
file://:
"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" --headless=new --disable-gpu --hide-scrollbars \
--virtual-time-budget=6000 --window-size=2300,3700 --screenshot=/tmp/g.png "http://localhost:4321/?view=gallery"
Then run npm run sync:images in this docs repo.
Card renderer ​
web/src/card/ renders every card: <Card def doc side uv? tilt? scale? editable? … /> on a 680 × 400 canvas, scaled
with CSS zoom. defaultLayout(def, side) builds the classic template; the designer passes editable and gets
drag, resize, snapping and a grid. A new view is the default export of src/views/<Name>.tsx, registered in
src/views/registry.ts, types.ts and wire.ts. See
web/README.md for the full renderer,
store and RPC APIs.
Tests ​
lua tests/run.lua
tests/harness.lua boots shared, bridges and server in plain Lua with fake natives, a scheduler, an in-memory
oxmysql, a fake framework and inventory, and runs 43 scenarios. Among them:
- Desks: offers and distance, the happy path,
maxActive, missing money (nothing issued), requirements, input, photo and signature validation, exams. - Showing, handing over, stolen cards (owner's data, holder check fails, no owner rights), digital-only mode.
- Police: permissions, checks on the shown document, points → automatic suspension → lift → points expire, suspend and revoke validation, seizure, ID requests with accept and timeout.
- Clerks, badges, owner actions (renew, report lost, replace), reminders, the audit log, cooldowns and locks.
- Designer: permissions and validation, publish with every migration mode, rollback, export / import, exams, preview, delete, archived versions, desks placed in game.
- Forger: offers, purchase, the forged view, the registry miss in a check.
- Exports, the standalone economy, the ox_inventory and qbx bridges against fake exports.
- A fuzz pass that calls every RPC with junk parameters (no Lua errors, always a clean error code), and a final check
for thread errors, unknown SQL and
nilin oxmysql parameter arrays.
The web side has its own tests: cd web && npm test (contract check plus vitest for card layout, codes, MRZ, the
designer logic, views and the phone logic) and npm run build (TypeScript strict).
Contract ​
docs/ARCHITECTURE.md is the
contract for the data model, the document type schema, the NUI protocol, every RPC, the events, the bridges, the phone
app and the server rules. It changes in the same commit as the code. See the NUI contract for a
summary.