# policing-redefined/commondataframework architecture

> Architecture diagram of the GitHub repository policing-redefined/commondataframework, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-06-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/policing-redefined/commondataframework
- Repository: https://github.com/policing-redefined/commondataframework

## Overview

##### Project type and purpose
- This is an open-source C# plugin library for the LSPDFR (Los Santos Police Department First Response) mod in GTA V.
- Its purpose is to provide a shared, synchronized vehicle and pedestrian data API across all dependent plugins.

##### File structure
- Top-level solution: CommonDataFramework.sln
- Single C# project: CommonDataFramework/
· API folder: public entrypoints (`CDFEvents.cs`, `CDFFunctions.cs`)
· Engine folder: core runtime (event dispatch, IO, utilities, logging)
· Modules folder: domain-specific data handlers (PedDatabase, VehicleDatabase, Postals, etc.)
· Settings.cs and .ini reflector: configuration management
- No separate frontend/backend—this is a runtime plugin loaded into GTA V via RagePluginHook.

##### README for additional insights
- Architecture is event-driven: hooks into LSPDFR events (`OnOnDutyStateChanged`, GetPedData, GetVehicleData).
- Configurable via .ini and XML for IntelliSense.
- Data store is in-memory with optional persistence window via Engine.IO (IniReflector).

a. Main components
1. GTA V + RagePluginHook (host environment)
2. LSPDFR core plugin API (external service)
3. CommonDataFramework.dll
- API Layer (CDFEvents, CDFFunctions)
- Engine Core (event loop, IO, Logger)
- Utility helpers (extensions, resources)
- Modules (PedDatabase, VehicleDatabase, Postals, PedResidence)
4. Configuration store (.ini files, optional XML for IntelliSense)
5. Dependent plugins (e.g., “Policing Redefined”)

b. Relationships & interactions
- On game startup, RagePluginHook loads CDF DLL
- CDF registers to LSPDFR events via the API layer
- When events fire (e.g., ped created, on-duty state change), Engine Core dispatches to Modules
- Modules read/write data objects (PedData, VehicleData)
- Modules persist state temporarily in memory and optionally to .ini via IniReflector
- Dependent plugins call CDFFunctions.GetPedData()/GetVehicleData() to retrieve synchronized state

c. Architectural patterns/design principles
- Plugin architecture: loosely coupled via public API
- Event-driven design: subscribe/publish to LSPDFR events
- Modular domain decomposition: separate modules per data domain
- Single project, layered design (API → Engine → Modules → IO)

d. Key technologies & frameworks
- C#, .NET Framework (RagePluginHook host)
- LSPDFR Mod API
- RAGE engine
- IniReflector for configuration
- Visual Studio solution (.sln, .csproj)

##### Essential details
- Modules individually to reflect domain separation
- Event loop: GTA V → LSPDFR event → CDFFunctions → Module handler
- Config loader (IniReflector) as a distinct IO component

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Host Environment"
        Host["GTA V + RagePluginHook"]:::external
    end

    subgraph "External Services"
        LSPDFR["LSPDFR API"]:::external
    end

    Host -->|"loads DLL"| CDFDLL["CommonDataFramework.dll"]:::runtime

    subgraph "CommonDataFramework.dll"
        subgraph "API Layer"
            CDFEvents["CDFEvents"]:::internal
            CDFFunctions["CDFFunctions"]:::internal
        end
        subgraph "Engine Core"
            Main["Main.cs"]:::internal
        end
        subgraph "IO Component"
            IniReflector["IniReflector"]:::internal
            Settings["Settings.cs"]:::internal
        end
        subgraph "Utility Helpers"
            Logger["Logger"]:::internal
            Helper["Helper"]:::internal
            Extensions["Extensions"]:::internal
            Resources["WeightedList"]:::internal
        end
        subgraph "Modules"
            subgraph "PedDatabase"
                PedData["PedData"]:::internal
                PedDataController["PedDataController"]:::internal
                Permits["Permits"]:::internal
            end
            subgraph "VehicleDatabase"
                VehicleData["VehicleData"]:::internal
                VehicleDataController["VehicleDataController"]:::internal
                VehicleDocuments["VehicleDocuments"]:::internal
            end
            subgraph "Postals"
                NearestPostalCode["NearestPostalCode"]:::internal
                Postal["Postal"]:::internal
                PostalCodeController["PostalCodeController"]:::internal
                PostalCodeSet["PostalCodeSet"]:::internal
            end
            subgraph "PedResidence"
                PedAddress["PedAddress"]:::internal
            end
            EDocumentStatus["EDocumentStatus"]:::internal
        end
    end

    CDFDLL -->|"registers events"| LSPDFR
    LSPDFR -->|"event fires"| CDFEvents
    CDFEvents -->|"dispatch"| Main
    Main -->|"invoke IO"| IniReflector
    IniReflector -->|"reads/writes"| Settings
    Main -->|"dispatch"| PedDataController
    Main -->|"dispatch"| VehicleDataController
    Main -->|"dispatch"| PostalCodeController
    Main -->|"dispatch"| PedAddress
    PedDataController -->|"uses"| PedData
    PedDataController -->|"uses"| Permits
    VehicleDataController -->|"uses"| VehicleData
    VehicleDataController -->|"uses"| VehicleDocuments
    PostalCodeController -->|"uses"| NearestPostalCode
    PostalCodeController -->|"uses"| PostalCodeSet
    PostalCodeController -->|"uses"| Postal
    CDFFunctions -->|"GetPedData/GetVehicleData"| PedDataController
    CDFFunctions -->|"GetPedData/GetVehicleData"| VehicleDataController

    subgraph "Storage"
        INIFiles[".ini Files"]:::storage
    end
    IniReflector -->|"persist"| INIFiles

    subgraph "Dependent Plugins"
        DepPlugin["Policing Redefined"]:::external
    end
    DepPlugin -->|"calls API"| CDFFunctions

    click CDFEvents "https://github.com/policing-redefined/commondataframework/blob/main/CommonDataFramework/API/CDFEvents.cs"
    click CDFFunctions "https://github.com/policing-redefined/commondataframework/blob/main/CommonDataFramework/API/CDFFunctions.cs"
    click Main "https://github.com/policing-redefined/commondataframework/blob/main/CommonDataFramework/Main.cs"
    click IniReflector "https://github.com/policing-redefined/commondataframework/blob/main/CommonDataFramework/Engine/IO/IniReflector.cs"
    click Settings "https://github.com/policing-redefined/commondataframework/blob/main/CommonDataFramework/Settings.cs"
    click Logger "https://github.com/policing-redefined/commondataframework/blob/main/CommonDataFramework/Engine/Utility/Logger.cs"
    click Helper "https://github.com/policing-redefined/commondataframework/blob/main/CommonDataFramework/Engine/Utility/Helper.cs"
    click Extensions "https://github.com/policing-redefined/commondataframework/tree/main/CommonDataFramework/Engine/Utility/Extensions/"
    click Resources "https://github.com/policing-redefined/commondataframework/blob/main/CommonDataFramework/Engine/Utility/Resources/WeightedList.cs"
    click PedData "https://github.com/policing-redefined/commondataframework/blob/main/CommonDataFramework/Modules/PedDatabase/PedData.cs"
    click PedDataController "https://github.com/policing-redefined/commondataframework/blob/main/CommonDataFramework/Modules/PedDatabase/PedDataController.cs"
    click Permits "https://github.com/policing-redefined/commondataframework/blob/main/CommonDataFramework/Modules/PedDatabase/Permits.cs"
    click VehicleData "https://github.com/policing-redefined/commondataframework/blob/main/CommonDataFramework/Modules/VehicleDatabase/VehicleData.cs"
    click VehicleDataController "https://github.com/policing-redefined/commondataframework/blob/main/CommonDataFramework/Modules/VehicleDatabase/VehicleDataController.cs"
    click VehicleDocuments "https://github.com/policing-redefined/commondataframework/blob/main/CommonDataFramework/Modules/VehicleDatabase/VehicleDocuments.cs"
    click NearestPostalCode "https://github.com/policing-redefined/commondataframework/blob/main/CommonDataFramework/Modules/Postals/NearestPostalCode.cs"
    click Postal "https://github.com/policing-redefined/commondataframework/blob/main/CommonDataFramework/Modules/Postals/Postal.cs"
    click PostalCodeController "https://github.com/policing-redefined/commondataframework/blob/main/CommonDataFramework/Modules/Postals/PostalCodeController.cs"
    click PostalCodeSet "https://github.com/policing-redefined/commondataframework/blob/main/CommonDataFramework/Modules/Postals/PostalCodeSet.cs"
    click PedAddress "https://github.com/policing-redefined/commondataframework/blob/main/CommonDataFramework/Modules/PedResidence/PedAddress.cs"
    click EDocumentStatus "https://github.com/policing-redefined/commondataframework/blob/main/CommonDataFramework/Modules/EDocumentStatus.cs"

    classDef external fill:#ccc,stroke:#333,stroke-width:1px
    classDef runtime fill:#88f,stroke:#000,stroke-width:2px
    classDef internal fill:#8f8,stroke:#080,stroke-width:1px
    classDef storage fill:#ff8,stroke:#aa0,stroke-width:2px
```
