# qbcore-framework/qb-core architecture

> Architecture diagram of the GitHub repository qbcore-framework/qb-core, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/qbcore-framework/qb-core
- Repository: https://github.com/qbcore-framework/qb-core

## Overview

##### Project's Main Purpose and Type
- The README and file structure clearly indicate this is the QBCore Framework—a core system for a FiveM roleplay server.
- It is a full-stack solution in the sense that it has a “client” side (with scripts like drawtext.lua, events.lua, etc.), a “server” side (with commands, events, and exports), and a “shared” component (handling jobs, gangs, and weapons), along with an HTML-based UI component.
- The configuration files (config.lua and fxmanifest.lua) and integration files (qbcore.sql) also highlight the need to manage both in-game logic and external resources like databases or web interfaces.

##### File Structure
- Top-level directories:
- .github: Contains CI/CD workflows, issue templates, and contributor guidelines.
- client: Contains Lua scripts that manage client-side actions and interface elements.
- server: Contains Lua scripts responsible for handling game server commands, events, and player data.
- shared: Places common logic and definitions that are used by both client and server (e.g., jobs, gangs, vehicles, weapons).
- html: Contains static web assets (HTML, CSS, JS) likely used for an in-game UI or external web dashboards.
- locale: Stores multiple language support files in Lua to offer internationalization.
- Key configuration files:
- fxmanifest.lua: Defines resource metadata for FiveM.
- config.lua: Likely governs core settings for the framework.
- qbcore.sql: Represents the database schema or sample SQL useful for backend database integration.
- The structure reinforces separation of concerns: client-side presentation and event-handling, server-side command processing and data handling, and shared modules to maintain consistency and reusability.

- From Client to Server: Mark events, remote calls, and data updates.
- From Server to Database: Mark data storage and retrieval operations.
- From Shared to both Client and Server: Indicate loading of common logic (jobs, gangs, vehicles, etc.).
- Use consistent labeling:
- Annotations:
- Notations explaining that fxmanifest.lua drives integration with the FiveM server environment.
- Comments on how locale files enable the internationalization support.

## Diagram (Mermaid)

```mermaid
flowchart TD

    %% Configuration & Metadata
    subgraph "Configuration & Metadata"
        FX["FXManifest (fxmanifest.lua)"]:::config
        CFG["Config File (config.lua)"]:::config
    end

    %% CI/CD and Contribution Guidelines
    subgraph "CI/CD & Contribution"
        CD["CI/CD (.github/)"]:::ci
    end

    %% Core Modules
    subgraph "Core Modules"
        SH["Shared Modules (Lua)"]:::core
        CL["Client Scripts (Lua)"]:::core
        SV["Server Scripts (Lua)"]:::core
    end

    %% Additional Components
    subgraph "Additional Components"
        UI["HTML UI"]:::ui
        LO["Localization"]:::locale
    end

    %% Database Layer
    DB["Database (qbcore.sql)"]:::db

    %% Connections
    CD --> FX
    FX --> SH
    CFG --> SH
    SH --> CL
    SH --> SV
    CL -->|"triggers"| SV
    CL -->|"renders"| UI
    SV -->|"stores"| DB
    LO ---|"localizes"| CL
    LO ---|"localizes"| SV

    %% Click Events
    click FX "https://github.com/qbcore-framework/qb-core/blob/main/fxmanifest.lua"
    click CFG "https://github.com/qbcore-framework/qb-core/blob/main/config.lua"
    click CD "https://github.com/qbcore-framework/qb-core/tree/main/.github/"
    click SH "https://github.com/qbcore-framework/qb-core/tree/main/shared/"
    click CL "https://github.com/qbcore-framework/qb-core/tree/main/client/"
    click SV "https://github.com/qbcore-framework/qb-core/tree/main/server/"
    click UI "https://github.com/qbcore-framework/qb-core/tree/main/html/"
    click LO "https://github.com/qbcore-framework/qb-core/tree/main/locale/"
    click DB "https://github.com/qbcore-framework/qb-core/blob/main/qbcore.sql"

    %% Styles
    classDef config fill:#f9e79f,stroke:#7d6608,stroke-width:2px;
    classDef ci fill:#aed6f1,stroke:#1b4f72,stroke-width:2px;
    classDef core fill:#abebc6,stroke:#186a3b,stroke-width:2px;
    classDef ui fill:#f5cba7,stroke:#943126,stroke-width:2px;
    classDef locale fill:#d6eaf8,stroke:#1f618d,stroke-width:2px;
    classDef db fill:#fadbd8,stroke:#922b21,stroke-width:2px;
```
