# r-niemans/nhr_excepties architecture

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

- Interactive diagram: https://gitdiagram.com/r-niemans/nhr_excepties
- Repository: https://github.com/r-niemans/nhr_excepties

## Overview

##### Project type and purpose
- This is a standalone Python automation tool whose purpose is to ingest NHR data, extract “exceptions” according to configurable rules, assemble those into a formatted NHR Excel file, and copy or deploy the result.

##### File structure
- Top-level scripts:
- controller_main.py – the orchestration entrypoint
- copy_files.py – handles copying/deploying the final workbook
- Configuration:
- config/datasets_config.py – dataset paths, names, parameters
- Exception-handling module:
- excepties/excepties_main.py – high-level exception pipeline
- excepties/excepties_functies.py – rule application, filtering functions
- Template creation module:
- nhr_template_creation/nhr_main.py – coordinates Excel template generation
- nhr_template_creation/nhr_template_class.py – encapsulates workbook/sheet logic
- nhr_template_creation/nhr_rules_functie.py – transforms exception data to template format
- nhr_template_creation/rules/*.json – JSON rule definitions per data category

##### README
- Confirms: automation of extracting exceptions from NHR data and compiling an NHR Excel.
- No other high-level architecture described, so we infer a simple layered pipeline.

##### Detail
- JSON rule files as a sub-component of the Template and Exception services
- Excel library as an external dependency used by the Template Generator

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% External trigger
    UserCron["User / Cron"]:::external

    %% Orchestration
    Controller["Controller\n(controller_main.py)"]:::orchestration
    Copier["File Copier\n(copy_files.py)"]:::orchestration

    %% I/O
    InputData["Input Data\n(Raw NHR files)"]:::io
    Output["Output Excel File\n(Output Directory)"]:::io

    %% Configuration
    subgraph "Configuration"
        Config["Config Service\n(datasets_config.py)"]:::config
    end

    %% Rules Store
    JSONStore[(Rules Store)]:::config
    subgraph "Rules Files"
        Rules1["abl_rules.json"]:::config
        Rules2["oho_rules.json"]:::config
        Rules3["pci_rules.json"]:::config
        Rules4["pmicd_rules.json"]:::config
    end

    %% Exception Module
    subgraph "Exception Module"
        ExcMain["Exception Processor\n(excepties_main.py)"]:::processing
        ExcFuncs["Exception Functions\n(excepties_functies.py)"]:::processing
    end

    %% Template Module
    subgraph "Template Module"
        TempMain["Template Generator\n(nhr_main.py)"]:::processing
        TempClass["Template Class\n(nhr_template_class.py)"]:::processing
        TempFuncs["Template Functions\n(nhr_rules_functie.py)"]:::processing
        ExcelLib["Excel Library\n(openpyxl/pandas)"]:::external
    end

    %% Data Flow
    UserCron --> Controller
    Controller --> Config
    Controller --> InputData
    Controller --> ExcMain
    ExcMain --> ExcFuncs
    ExcMain --> JSONStore
    JSONStore --> Rules1
    JSONStore --> Rules2
    JSONStore --> Rules3
    JSONStore --> Rules4
    ExcFuncs --> TempMain
    TempMain --> TempClass
    TempMain --> TempFuncs
    TempClass --> ExcelLib
    TempMain --> Copier
    Copier --> Output

    %% Click Events
    click Controller "https://github.com/r-niemans/nhr_excepties/blob/master/controller_main.py"
    click Config "https://github.com/r-niemans/nhr_excepties/blob/master/config/datasets_config.py"
    click ExcMain "https://github.com/r-niemans/nhr_excepties/blob/master/excepties/excepties_main.py"
    click ExcFuncs "https://github.com/r-niemans/nhr_excepties/blob/master/excepties/excepties_functies.py"
    click TempMain "https://github.com/r-niemans/nhr_excepties/blob/master/nhr_template_creation/nhr_main.py"
    click TempClass "https://github.com/r-niemans/nhr_excepties/blob/master/nhr_template_creation/nhr_template_class.py"
    click TempFuncs "https://github.com/r-niemans/nhr_excepties/blob/master/nhr_template_creation/nhr_rules_functie.py"
    click Rules1 "https://github.com/r-niemans/nhr_excepties/blob/master/nhr_template_creation/rules/abl_rules.json"
    click Rules2 "https://github.com/r-niemans/nhr_excepties/blob/master/nhr_template_creation/rules/oho_rules.json"
    click Rules3 "https://github.com/r-niemans/nhr_excepties/blob/master/nhr_template_creation/rules/pci_rules.json"
    click Rules4 "https://github.com/r-niemans/nhr_excepties/blob/master/nhr_template_creation/rules/pmicd_rules.json"
    click Copier "https://github.com/r-niemans/nhr_excepties/blob/master/copy_files.py"

    %% Styles
    classDef orchestration fill:#cce5ff,stroke:#0366d6,color:#0366d6;
    classDef processing fill:#d4edda,stroke:#28a745,color:#155724;
    classDef config fill:#fff3cd,stroke:#856404,color:#856404;
    classDef io fill:#ffe5b4,stroke:#ff8c00,color:#8b4513;
    classDef external fill:#f0f0f0,stroke:#6c757d,color:#6c757d,stroke-dasharray: 5 5;
```
