# jericofx/advance-mechanic architecture

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

- Interactive diagram: https://gitdiagram.com/jericofx/advance-mechanic
- Repository: https://github.com/jericofx/advance-mechanic

## Overview

#### Purpose and Runtime
This is a FiveM Lua resource implementing a multi-shop mechanic-job system: vehicle service, diagnostics, degradation, tuning, towing, missions, invoicing, and shop operations. FiveM loads it through `fxmanifest.lua`; side-specific bootstraps are `client/init.lua` and `server/init.lua`. Shared framework/config abstractions live in `shared/config.lua` and `shared/framework.lua`.

#### Client Interaction Layer
Client modules own player-facing interactions, vehicle natives, ox_lib menus/points/cache, and local effects. The mechanic workflow is assembled from inspection, maintenance, diagnostics, parts, shop, garage, and lift modules:
- `client/modules/inspection.lua`
- `client/modules/maintenance.lua`
- `client/modules/diagnostic.lua`
- `client/modules/shops.lua`
- `client/modules/lifts.lua`

Client actions must cross to the server for authorization, persistence, inventory/economic mutation, and other authoritative changes.

#### Shop and Business Domain
Shops are persistent businesses with ownership, employees, configurable zones, storage, and lifts. The server manages business records and access decisions, while clients materialize shop zones and owner/employee UI:
- `server/modules/business.lua`
- `server/modules/shops.lua`
- `client/modules/shops.lua`
- `client/modules/employees.lua`
- `client/modules/garage.lua`

Admin-driven shop creation is a client placement flow followed by server validation and database creation. Per-shop zones/lift positions form the boundary between spatial interaction and persisted business state.

#### Vehicle Service and Customization
Vehicle work is divided by service domain: damage/inspection, fluids and component state, engine replacement, suspension setup, paint/wrap, and performance tuning. Client modules apply visual/native vehicle behavior; matching server modules validate and persist eligible operations:
- `client/modules/damage.lua`
- `client/modules/engine_swap.lua`
- `client/modules/suspension_setup.lua`
- `client/modules/paint_booth.lua`
- `client/modules/tuning.lua`
- `server/modules/vehicles.lua`
- `server/modules/validation.lua`

Vehicle changes likely use framework vehicle ownership/storage conventions and require server authority before durable updates.

#### Fluid Degradation and Runtime Effects
Fluid/component degradation is a distinct continuous client-side state/effects subsystem. State tracking and degradation calculations are separated from handling, engine, braking, steering, and visual consequences:
- `client/modules/fluid/state.lua`
- `client/modules/fluid/degradation.lua`
- `client/modules/fluid/effects.lua`
- `client/modules/fluid_effects.lua`

It relies on FiveM entity state bags and ox_lib vehicle cache behavior for synchronization/monitoring, with server validation intended to prevent client-side fluid manipulation. Persistence is supported by the vehicle data path and SQL migration/schema.

#### Economy, Inventory, and Activities
Mechanic income and consumption flow through billing, parts inventory/supplier operations, and repair missions. These are paired client/server domains where the server should be the trust boundary for prices, rewards, stock, and invoice state:
- `client/modules/billing.lua`
- `server/modules/billing.lua`
- `client/modules/inventory.lua`
- `client/modules/parts.lua`
- `client/modules/missions.lua`
- `server/modules/missions.lua`

External integrations are ox_inventory for materials and QBCore or ESX for jobs, identities, money, and permissions.

#### Persistence, Dependencies, and Delivery
Database access is centralized in `server/modules/database.lua`; schemas are provided in `install.sql` and `sql/schema.sql`. MySQL stores shops/lifts and expected vehicle fluid data. Required FiveM ecosystem services are ox_lib, ox_target, ox_inventory, and either QBCore or ESX. Release automation is defined in `.github/workflows/release.yml`; `version_check.lua` supports resource version checking.

Main entry points: [`client/init.lua`](https://github.com/jericofx/advance-mechanic/blob/main/client/init.lua) (Client Bootstrap), [`server/modules/billing.lua`](https://github.com/jericofx/advance-mechanic/blob/main/server/modules/billing.lua) (Billing & Mission Authority), [`server/modules/validation.lua`](https://github.com/jericofx/advance-mechanic/blob/main/server/modules/validation.lua) (Operation Validation), [`server/modules/database.lua`](https://github.com/jericofx/advance-mechanic/blob/main/server/modules/database.lua) (Database Access)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["FiveM Runtime"]
  node_manifest["Resource Manifest<br/>FiveM manifest<br/>[fxmanifest.lua]"]
  node_client_init["Client Bootstrap<br/>Lua bootstrap<br/>[init.lua]"]
  node_server_init["Server Bootstrap<br/>Lua bootstrap<br/>[init.lua]"]
  node_shared["Framework &amp; Config<br/>shared abstractions<br/>[framework.lua]"]
end

subgraph group_client["Client Systems"]
  node_interaction["Mechanic Interaction<br/>client workflow<br/>[inspection.lua]"]
  node_shop_ui["Shop Operations UI<br/>client shop domain<br/>[shops.lua]"]
  node_vehicle_visuals["Vehicle Service UI<br/>client vehicle domain<br/>[damage.lua]"]
  node_fluid_runtime["Fluid Degradation Effects<br/>client state pipeline<br/>[state.lua]"]
  node_economy_ui["Billing, Parts &amp; Missions<br/>client activities<br/>[billing.lua]"]
end

subgraph group_server["Server Authority"]
  node_business["Business Access &amp; Shops<br/>server business domain<br/>[business.lua]"]
  node_vehicle_authority["Vehicle Persistence<br/>server vehicle domain<br/>[vehicles.lua]"]
  node_validation{{"Operation Validation<br/>server trust boundary<br/>[validation.lua]"}}
  node_economy_authority["Billing &amp; Mission Authority<br/>server economy domain<br/>[billing.lua]"]
end

subgraph group_data["Persistence &amp; Integrations"]
  node_database[("Database Access<br/>server data access<br/>[database.lua]")]
  node_schema["SQL Schema<br/>database schema<br/>[schema.sql]"]
  node_framework["QBCore or ESX<br/>framework integration"]
  node_ox_services["ox Services<br/>FiveM integrations"]
  node_release["Release Automation<br/>delivery workflow<br/>[release.yml]"]
end

node_manifest -->|"loads client"| node_client_init
node_manifest -->|"loads server"| node_server_init
node_client_init -->|"uses"| node_shared
node_server_init -->|"uses"| node_shared
node_client_init -->|"starts"| node_interaction
node_client_init -->|"starts"| node_shop_ui
node_client_init -->|"starts"| node_vehicle_visuals
node_client_init -->|"starts"| node_fluid_runtime
node_client_init -->|"starts"| node_economy_ui
node_interaction -->|"requests authority"| node_validation
node_shop_ui -->|"shop actions"| node_business
node_vehicle_visuals -->|"service requests"| node_validation
node_fluid_runtime -.->|"state validation"| node_validation
node_economy_ui -->|"billing and activities"| node_economy_authority
node_validation -->|"permits updates"| node_vehicle_authority
node_business -->|"persists shops"| node_database
node_vehicle_authority -->|"persists vehicle data"| node_database
node_economy_authority -->|"persists invoices and stock"| node_database
node_database -->|"uses schema"| node_schema
node_business -->|"jobs and permissions"| node_framework
node_economy_authority -->|"money and identity"| node_framework
node_interaction -->|"menus and targeting"| node_ox_services
node_fluid_runtime -->|"vehicle cache"| node_ox_services
node_economy_authority -->|"inventory mutation"| node_ox_services
node_release -.->|"releases resource"| node_manifest

click node_manifest "https://github.com/jericofx/advance-mechanic/blob/main/fxmanifest.lua"
click node_client_init "https://github.com/jericofx/advance-mechanic/blob/main/client/init.lua"
click node_server_init "https://github.com/jericofx/advance-mechanic/blob/main/server/init.lua"
click node_shared "https://github.com/jericofx/advance-mechanic/blob/main/shared/framework.lua"
click node_interaction "https://github.com/jericofx/advance-mechanic/blob/main/client/modules/inspection.lua"
click node_shop_ui "https://github.com/jericofx/advance-mechanic/blob/main/client/modules/shops.lua"
click node_vehicle_visuals "https://github.com/jericofx/advance-mechanic/blob/main/client/modules/damage.lua"
click node_fluid_runtime "https://github.com/jericofx/advance-mechanic/blob/main/client/modules/fluid/state.lua"
click node_economy_ui "https://github.com/jericofx/advance-mechanic/blob/main/client/modules/billing.lua"
click node_business "https://github.com/jericofx/advance-mechanic/blob/main/server/modules/business.lua"
click node_vehicle_authority "https://github.com/jericofx/advance-mechanic/blob/main/server/modules/vehicles.lua"
click node_validation "https://github.com/jericofx/advance-mechanic/blob/main/server/modules/validation.lua"
click node_economy_authority "https://github.com/jericofx/advance-mechanic/blob/main/server/modules/billing.lua"
click node_database "https://github.com/jericofx/advance-mechanic/blob/main/server/modules/database.lua"
click node_schema "https://github.com/jericofx/advance-mechanic/blob/main/sql/schema.sql"
click node_release "https://github.com/jericofx/advance-mechanic/blob/main/.github/workflows/release.yml"

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_client_init,node_server_init,node_shared toneBlue
class node_interaction,node_shop_ui,node_vehicle_visuals,node_fluid_runtime,node_economy_ui toneAmber
class node_business,node_vehicle_authority,node_validation,node_economy_authority toneMint
class node_database,node_schema,node_framework,node_ox_services,node_release toneRose
```

## Components

### FiveM Runtime

- [Resource Manifest](https://github.com/jericofx/advance-mechanic/blob/main/fxmanifest.lua): FiveM manifest · Declares resource loading and dependencies. · `fxmanifest.lua`
- [Client Bootstrap](https://github.com/jericofx/advance-mechanic/blob/main/client/init.lua): Lua bootstrap · `client/init.lua`
- [Server Bootstrap](https://github.com/jericofx/advance-mechanic/blob/main/server/init.lua): Lua bootstrap · `server/init.lua`
- [Framework & Config](https://github.com/jericofx/advance-mechanic/blob/main/shared/framework.lua): shared abstractions · `shared/framework.lua`

### Client Systems

- [Mechanic Interaction](https://github.com/jericofx/advance-mechanic/blob/main/client/modules/inspection.lua): client workflow · Player inspection, maintenance, and diagnostics interactions. · `client/modules/inspection.lua`
- [Shop Operations UI](https://github.com/jericofx/advance-mechanic/blob/main/client/modules/shops.lua): client shop domain · Materializes zones, employee UI, garages, and lifts. · `client/modules/shops.lua`
- [Vehicle Service UI](https://github.com/jericofx/advance-mechanic/blob/main/client/modules/damage.lua): client vehicle domain · Applies native visual and handling changes. · `client/modules/damage.lua`
- [Fluid Degradation Effects](https://github.com/jericofx/advance-mechanic/blob/main/client/modules/fluid/state.lua): client state pipeline · Tracks degradation and applies runtime vehicle effects. · `client/modules/fluid/state.lua`
- [Billing, Parts & Missions](https://github.com/jericofx/advance-mechanic/blob/main/client/modules/billing.lua): client activities · `client/modules/billing.lua`

### Server Authority

- [Business Access & Shops](https://github.com/jericofx/advance-mechanic/blob/main/server/modules/business.lua): server business domain · Owns shop records, employees, zones, storage, and lifts. · `server/modules/business.lua`
- [Vehicle Persistence](https://github.com/jericofx/advance-mechanic/blob/main/server/modules/vehicles.lua): server vehicle domain · Authorizes and persists durable vehicle work. · `server/modules/vehicles.lua`
- [Operation Validation](https://github.com/jericofx/advance-mechanic/blob/main/server/modules/validation.lua): server trust boundary · Validates client-requested authoritative changes. · `server/modules/validation.lua`
- [Billing & Mission Authority](https://github.com/jericofx/advance-mechanic/blob/main/server/modules/billing.lua): server economy domain · Controls invoices, rewards, prices, and stock mutations. · `server/modules/billing.lua`

### Persistence & Integrations

- [Database Access](https://github.com/jericofx/advance-mechanic/blob/main/server/modules/database.lua): server data access · Centralizes MySQL persistence. · `server/modules/database.lua`
- [SQL Schema](https://github.com/jericofx/advance-mechanic/blob/main/sql/schema.sql): database schema · Defines shops, lifts, and vehicle-fluid persistence. · `sql/schema.sql`
- **QBCore or ESX**: framework integration · Provides jobs, identity, money, and permissions.
- **ox Services**: FiveM integrations · ox_lib, ox_target, and ox_inventory.
- [Release Automation](https://github.com/jericofx/advance-mechanic/blob/main/.github/workflows/release.yml): delivery workflow · `.github/workflows/release.yml`

## Connections

- Resource Manifest → Client Bootstrap: loads client
- Resource Manifest → Server Bootstrap: loads server
- Client Bootstrap → Framework & Config: uses
- Server Bootstrap → Framework & Config: uses
- Client Bootstrap → Mechanic Interaction: starts
- Client Bootstrap → Shop Operations UI: starts
- Client Bootstrap → Vehicle Service UI: starts
- Client Bootstrap → Fluid Degradation Effects: starts
- Client Bootstrap → Billing, Parts & Missions: starts
- Mechanic Interaction → Operation Validation: requests authority
- Shop Operations UI → Business Access & Shops: shop actions
- Vehicle Service UI → Operation Validation: service requests
- Fluid Degradation Effects → Operation Validation: state validation
- Billing, Parts & Missions → Billing & Mission Authority: billing and activities
- Operation Validation → Vehicle Persistence: permits updates
- Business Access & Shops → Database Access: persists shops
- Vehicle Persistence → Database Access: persists vehicle data
- Billing & Mission Authority → Database Access: persists invoices and stock
- Database Access → SQL Schema: uses schema
- Business Access & Shops → QBCore or ESX: jobs and permissions
- Billing & Mission Authority → QBCore or ESX: money and identity
- Mechanic Interaction → ox Services: menus and targeting
- Fluid Degradation Effects → ox Services: vehicle cache
- Billing & Mission Authority → ox Services: inventory mutation
- Release Automation → Resource Manifest: releases resource
