# bsse24017/niggaratoridk architecture

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

- Interactive diagram: https://gitdiagram.com/bsse24017/niggaratoridk
- Repository: https://github.com/bsse24017/niggaratoridk

## Overview

##### Project type and purpose
- This is a modular, console-based C++ application (Law Enforcement Management System – LEMS) that uses a menu-driven UI to manage five distinct subdomains: Officers, Crimes, Forensics, Patrol Vehicles, and Jail.
- It demonstrates key OOP concepts (inheritance, polymorphism, association, composition, aggregation, operator overloading, singletons) and persists data in JSON/text files via the nlohmann JSON library.

##### File structure
- Top-level files:
– main.cpp: entry point & CLI/menu router
– makefile: build script
– README.md
– JSON/text data files (crimes.json, officers.json, etc.)
- Module sources:
– {Officer, Crime, Forensics, PatrolVehicles, Jail}Module.cpp/.h
– ListTemplate.h (generic container template)
- Third-party library: nlohmann/json.hpp & json_fwd.hpp
- IDE configurations: .vs/, .vscode/

##### README for additional insights
- Modules correspond 1:1 with major subdomains; each uses inheritance hierarchies (e.g., SHO ← Officer, Theft ← Crime), singletons for centralized management, file I/O for persistence.
- Data folder is “data/” (though files sit in root here) for plain-text storage.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Presentation Layer
    main["main.cpp"]:::presentation
    click main "https://github.com/bsse24017/niggaratoridk/blob/main/main.cpp"

    %% Application Modules Layer
    subgraph "Application Modules" 
        direction TB
        subgraph "Officer Module" 
            direction TB
            OM["OfficerModule (Singleton)"]:::module
            click OM "https://github.com/bsse24017/niggaratoridk/blob/main/OfficerModule.cpp"
            OM_h["OfficerModule.h"]:::module
            click OM_h "https://github.com/bsse24017/niggaratoridk/blob/main/OfficerModule.h"
            OM -->|manages| Officer["Officer"]:::domain
            SHO["SHO"]:::domain
            Constable["Constable"]:::domain
            Officer -->|inherits| SHO
            Officer -->|inherits| Constable
            OM -->|uses| ListT1["ListTemplate<T>"]:::utility
        end

        subgraph "Crime Module"
            direction TB
            CM["CrimeModule (Singleton)"]:::module
            click CM "https://github.com/bsse24017/niggaratoridk/blob/main/CrimeModule.cpp"
            CM_h["CrimeModule.h"]:::module
            click CM_h "https://github.com/bsse24017/niggaratoridk/blob/main/CrimeModule.h"
            CM -->|manages| Crime["Crime"]:::domain
            Theft["Theft"]:::domain
            Assault["Assault"]:::domain
            Crime -->|inherits| Theft
            Crime -->|inherits| Assault
            CM -->|uses| ListT2["ListTemplate<T>"]:::utility
        end

        subgraph "Forensics Module"
            direction TB
            FM["ForensicsModule (Singleton)"]:::module
            click FM "https://github.com/bsse24017/niggaratoridk/blob/main/ForensicsModule.cpp"
            FM_h["ForensicsModule.h"]:::module
            click FM_h "https://github.com/bsse24017/niggaratoridk/blob/main/ForensicsModule.h"
            FM -->|manages| ForensicCase["ForensicCase"]:::domain
            FM -->|uses| ListT3["ListTemplate<T>"]:::utility
        end

        subgraph "Patrol Vehicles Module"
            direction TB
            PVM["PatrolVehiclesModule (Singleton)"]:::module
            click PVM "https://github.com/bsse24017/niggaratoridk/blob/main/PatrolVehiclesModule.cpp"
            PVM_h["PatrolVehiclesModule.h"]:::module
            click PVM_h "https://github.com/bsse24017/niggaratoridk/blob/main/PatrolVehiclesModule.h"
            PVM -->|manages| Vehicle["Vehicle"]:::domain
            PatrolCar["PatrolCar"]:::domain
            Vehicle -->|inherits| PatrolCar
            PVM -->|uses| ListT4["ListTemplate<T>"]:::utility
        end

        subgraph "Jail Module"
            direction TB
            JM["JailModule (Singleton)"]:::module
            click JM "https://github.com/bsse24017/niggaratoridk/blob/main/JailModule.cpp"
            JM_h["JailModule.h"]:::module
            click JM_h "https://github.com/bsse24017/niggaratoridk/blob/main/JailModule.h"
            JM -->|manages| Inmate["Inmate"]:::domain
            JM -->|uses| ListT5["ListTemplate<T>"]:::utility
        end
    end

    %% Utilities
    ListT["ListTemplate.h"]:::utility
    click ListT "https://github.com/bsse24017/niggaratoridk/blob/main/ListTemplate.h"

    %% Persistence Layer
    subgraph "Persistence Layer"
        direction TB
        JSONLib["nlohmann/json.hpp"]:::persistence
        click JSONLib "https://github.com/bsse24017/niggaratoridk/blob/main/nlohmann/json.hpp"
        JSONFwd["nlohmann/json_fwd.hpp"]:::persistence
        click JSONFwd "https://github.com/bsse24017/niggaratoridk/blob/main/nlohmann/json_fwd.hpp"
        crimes["crimes.json"]:::persistence
        click crimes "https://github.com/bsse24017/niggaratoridk/blob/main/crimes.json"
        officersF["officers.json"]:::persistence
        click officersF "https://github.com/bsse24017/niggaratoridk/blob/main/officers.json"
        forensicsF["forensics_data.json"]:::persistence
        click forensicsF "https://github.com/bsse24017/niggaratoridk/blob/main/forensics_data.json"
        patrollingF["patrolling.json"]:::persistence
        click patrollingF "https://github.com/bsse24017/niggaratoridk/blob/main/patrolling.json"
        vehiclesF["vehicles.json"]:::persistence
        click vehiclesF "https://github.com/bsse24017/niggaratoridk/blob/main/vehicles.json"
        jailJson["jail_data.json"]:::persistence
        click jailJson "https://github.com/bsse24017/niggaratoridk/blob/main/jail_data.json"
        jailTxt["jail_data.txt"]:::persistence
        click jailTxt "https://github.com/bsse24017/niggaratoridk/blob/main/jail_data.txt"
    end

    %% Build & Config
    makefile["makefile"]:::config
    click makefile "https://github.com/bsse24017/niggaratoridk/tree/main/makefile"
    readme["README.md"]:::config
    click readme "https://github.com/bsse24017/niggaratoridk/blob/main/README.md"

    %% Control flow from main to modules
    main -->|"getInstance()"| OM
    main -->|"getInstance()"| CM
    main -->|"getInstance()"| FM
    main -->|"getInstance()"| PVM
    main -->|"getInstance()"| JM

    %% Module to persistence interactions
    OM -->|"loadAll()/save()"| officersF
    CM -->|"loadAll()/save()"| crimes
    FM -->|"loadAll()/save()"| forensicsF
    PVM -->|"loadAll()/save()"| patrollingF
    PVM -->|"loadAll()/save()"| vehiclesF
    JM -->|"loadAll()/save()"| jailJson
    JM -->|"loadAll()/save()"| jailTxt

    %% Modules use JSON library
    OM -->|"parse()/serialize()"| JSONLib
    CM -->|"parse()/serialize()"| JSONLib
    FM -->|"parse()/serialize()"| JSONLib
    PVM -->|"parse()/serialize()"| JSONLib
    JM -->|"parse()/serialize()"| JSONLib

    %% Modules use ListTemplate
    OM --> ListT
    CM --> ListT
    FM --> ListT
    PVM --> ListT
    JM --> ListT

    %% Styles
    classDef presentation fill:#E8F1FB,stroke:#3778C2,stroke-width:1px
    classDef module fill:#D0E8FF,stroke:#2A6FAD,stroke-width:1px
    classDef domain fill:#E6F4EA,stroke:#2D8C56,stroke-width:1px
    classDef utility fill:#FFE8B0,stroke:#D69E00,stroke-width:1px
    classDef persistence fill:#FFF4E6,stroke:#D88F00,stroke-width:1px
    classDef config fill:#F3E8FF,stroke:#8A2BE2,stroke-width:1px
```
