# reddragonelite/rde_aipd architecture

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

- Interactive diagram: https://gitdiagram.com/reddragonelite/rde_aipd
- Repository: https://github.com/reddragonelite/rde_aipd

## Overview

rde_aipd is a FiveM police-and-crime resource for ox_core. Its principal workflow detects crimes, manages wanted status and police response, and records selected events through optional Nostr logging. The README also documents witnesses, fatigue, tackles, jail, StateBag synchronization, and localized UI. Source excerpts were unavailable, so links between implementation components are limited to documented relationships; unverified links are dashed.

Main entry points: [`server/main.lua`](https://github.com/reddragonelite/rde_aipd/blob/main/server/main.lua) (Police authority), [`server/nostr.lua`](https://github.com/reddragonelite/rde_aipd/blob/main/server/nostr.lua) (Nostr logging), [`config.lua`](https://github.com/reddragonelite/rde_aipd/blob/main/config.lua) (Configuration), [`client/crime.lua`](https://github.com/reddragonelite/rde_aipd/blob/main/client/crime.lua) (Crime detection)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Client gameplay"]
  node_crime_detection["Crime detection<br/>[crime.lua]"]
  node_police_ai["Police AI<br/>[main.lua]"]
end

subgraph group_server["Server authority"]
  node_witnesses["Witness system"]
  node_authority["Police authority<br/>[main.lua]"]
  node_wanted["Wanted system<br/>[main.lua]"]
  node_prison["Prison system<br/>[main.lua]"]
  node_nostr_logging["Nostr logging<br/>[nostr.lua]"]
end

subgraph group_presentation["Presentation and settings"]
  node_wanted_display["Wanted display<br/>[wanted_stars.html]"]
  node_configuration["Configuration<br/>[config.lua]"]
  node_locales["Locales"]
end

subgraph group_integrations["External integrations"]
  node_ox_core["ox_core"]
  node_nostr_service["Nostr service"]
end

node_player(("Player"))

node_player -.->|"commits crimes"| node_crime_detection
node_crime_detection -.->|"reports crimes"| node_wanted
node_wanted -.->|"dispatches response"| node_police_ai
node_police_ai -.->|"pursues suspect"| node_player
node_witnesses -.->|"reports witnessed crimes"| node_authority
node_authority -.->|"validates actions"| node_wanted
node_authority -.->|"syncs StateBags"| node_ox_core
node_authority -.->|"manages jail"| node_prison
node_wanted -.->|"updates stars"| node_wanted_display
node_authority -.->|"logs events"| node_nostr_logging
node_nostr_logging -.->|"sends logs"| node_nostr_service
node_configuration -.->|"configures behavior"| node_witnesses
node_configuration -.->|"configures logging"| node_nostr_logging
node_locales -.->|"localizes text"| node_wanted_display

click node_crime_detection "https://github.com/reddragonelite/rde_aipd/blob/main/client/crime.lua"
click node_police_ai "https://github.com/reddragonelite/rde_aipd/blob/main/client/main.lua"
click node_witnesses "https://github.com/reddragonelite/rde_aipd/blob/main/server/crime_witness_handler.lua"
click node_authority "https://github.com/reddragonelite/rde_aipd/blob/main/server/main.lua"
click node_wanted "https://github.com/reddragonelite/rde_aipd/blob/main/server/main.lua"
click node_prison "https://github.com/reddragonelite/rde_aipd/blob/main/server/main.lua"
click node_nostr_logging "https://github.com/reddragonelite/rde_aipd/blob/main/server/nostr.lua"
click node_wanted_display "https://github.com/reddragonelite/rde_aipd/blob/main/html/wanted_stars.html"
click node_configuration "https://github.com/reddragonelite/rde_aipd/blob/main/config.lua"
click node_locales "https://github.com/reddragonelite/rde_aipd/tree/main/locales"

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_crime_detection,node_police_ai toneBlue
class node_witnesses,node_authority,node_wanted,node_prison,node_nostr_logging toneAmber
class node_wanted_display,node_configuration,node_locales toneMint
class node_ox_core,node_nostr_service toneRose
class node_player toneIndigo
```

## Components

### Client gameplay

- [Crime detection](https://github.com/reddragonelite/rde_aipd/blob/main/client/crime.lua): `client/crime.lua`
- [Police AI](https://github.com/reddragonelite/rde_aipd/blob/main/client/main.lua): `client/main.lua`

### Server authority

- [Witness system](https://github.com/reddragonelite/rde_aipd/blob/main/server/crime_witness_handler.lua): `server/crime_witness_handler.lua`
- [Police authority](https://github.com/reddragonelite/rde_aipd/blob/main/server/main.lua): `server/main.lua`
- [Wanted system](https://github.com/reddragonelite/rde_aipd/blob/main/server/main.lua): `server/main.lua`
- [Prison system](https://github.com/reddragonelite/rde_aipd/blob/main/server/main.lua): `server/main.lua`
- [Nostr logging](https://github.com/reddragonelite/rde_aipd/blob/main/server/nostr.lua): `server/nostr.lua`

### Presentation and settings

- [Wanted display](https://github.com/reddragonelite/rde_aipd/blob/main/html/wanted_stars.html): `html/wanted_stars.html`
- [Configuration](https://github.com/reddragonelite/rde_aipd/blob/main/config.lua): `config.lua`
- [Locales](https://github.com/reddragonelite/rde_aipd/tree/main/locales): `locales`

### External integrations

- **ox_core**
- **Nostr service**

### Other components

- **Player**

## Connections

- Player → Crime detection: commits crimes
- Crime detection → Wanted system: reports crimes
- Wanted system → Police AI: dispatches response
- Police AI → Player: pursues suspect
- Witness system → Police authority: reports witnessed crimes
- Police authority → Wanted system: validates actions (evidence: `README.md`)
- Police authority → ox_core: syncs StateBags (evidence: `README.md`)
- Police authority → Prison system: manages jail (evidence: `README.md`)
- Wanted system → Wanted display: updates stars
- Police authority → Nostr logging: logs events (evidence: `README.md`)
- Nostr logging → Nostr service: sends logs (evidence: `README.md`)
- Configuration → Witness system: configures behavior (evidence: `README.md`)
- Configuration → Nostr logging: configures logging (evidence: `README.md`)
- Locales → Wanted display: localizes text (evidence: `README.md`)
