# skveer1902/fairrl architecture

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

- Interactive diagram: https://gitdiagram.com/skveer1902/fairrl
- Repository: https://github.com/skveer1902/fairrl

## Overview

FairRL trains and compares baseline and fairness-aware Double DQN agents for binary loan decisions using the Adult dataset. Its main workflow preprocesses applicant data, runs decisions in a loan environment, applies fairness-adjusted rewards during training, then evaluates fairness and utility and analyzes bias attributions. The README also identifies prioritized replay and curriculum learning as capabilities. Edges are limited to relationships shown in excerpts or documented in the README; some internal wiring is not visible in the sampled source.

Main entry points: [`main.py`](https://github.com/skveer1902/fairrl/blob/main/main.py) (Pipeline orchestration), [`fairrl/models/models.py`](https://github.com/skveer1902/fairrl/blob/main/fairrl/models/models.py) (Double DQN agent), [`fairrl/fairness/constraints.py`](https://github.com/skveer1902/fairrl/blob/main/fairrl/fairness/constraints.py) (Fairness constraints), [`fairrl/fairness/metrics.py`](https://github.com/skveer1902/fairrl/blob/main/fairrl/fairness/metrics.py) (Fairness metrics)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["Applicant data"]
  node_adult["Adult data loader<br/>[loader.py]"]
end

subgraph group_learning["RL decision learning"]
  node_environment["Loan environment<br/>[environment.py]"]
  node_qnet["Q-network<br/>[models.py]"]
  node_agent["Double DQN agent<br/>[models.py]"]
  node_replay[("Fairness-prioritized replay<br/>[models.py]")]
end

subgraph group_fairness["Fairness and attribution"]
  node_constraints["Fairness constraints<br/>[constraints.py]"]
  node_optimizer["Constraint optimizer<br/>[constraints.py]"]
  node_metrics["Fairness metrics<br/>[metrics.py]"]
  node_explainer["Integrated Gradients<br/>[ig.py]"]
end

subgraph group_workflow["Training and evaluation"]
  node_main["Pipeline orchestration<br/>[main.py]"]
  node_results["Metrics and artifacts"]
end

node_user(("Researcher"))

node_user -->|"runs pipeline"| node_main
node_main -->|"loads data"| node_adult
node_main -->|"sets up decisions"| node_environment
node_main -->|"trains agents"| node_agent
node_agent -->|"estimates actions"| node_qnet
node_agent -->|"stores experience"| node_replay
node_main -->|"computes fair rewards"| node_optimizer
node_optimizer -->|"applies penalties"| node_constraints
node_constraints -->|"creates explainer"| node_explainer
node_constraints -.-> node_metrics
node_main -->|"evaluates fairness"| node_metrics
node_main -->|"analyzes attribution"| node_explainer
node_main -->|"produces comparisons"| node_results

click node_adult "https://github.com/skveer1902/fairrl/blob/main/fairrl/data/loader.py"
click node_environment "https://github.com/skveer1902/fairrl/blob/main/fairrl/models/environment.py"
click node_qnet "https://github.com/skveer1902/fairrl/blob/main/fairrl/models/models.py"
click node_agent "https://github.com/skveer1902/fairrl/blob/main/fairrl/models/models.py"
click node_replay "https://github.com/skveer1902/fairrl/blob/main/fairrl/models/models.py"
click node_constraints "https://github.com/skveer1902/fairrl/blob/main/fairrl/fairness/constraints.py"
click node_optimizer "https://github.com/skveer1902/fairrl/blob/main/fairrl/fairness/constraints.py"
click node_metrics "https://github.com/skveer1902/fairrl/blob/main/fairrl/fairness/metrics.py"
click node_explainer "https://github.com/skveer1902/fairrl/blob/main/fairrl/explainability/ig.py"
click node_main "https://github.com/skveer1902/fairrl/blob/main/main.py"
click node_results "https://github.com/skveer1902/fairrl/tree/main/results"

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_adult toneBlue
class node_environment,node_qnet,node_agent,node_replay toneAmber
class node_constraints,node_optimizer,node_metrics,node_explainer toneMint
class node_main,node_results toneRose
class node_user toneIndigo
```

## Components

### Applicant data

- [Adult data loader](https://github.com/skveer1902/fairrl/blob/main/fairrl/data/loader.py): `fairrl/data/loader.py`

### RL decision learning

- [Loan environment](https://github.com/skveer1902/fairrl/blob/main/fairrl/models/environment.py): `fairrl/models/environment.py`
- [Q-network](https://github.com/skveer1902/fairrl/blob/main/fairrl/models/models.py): `fairrl/models/models.py`
- [Double DQN agent](https://github.com/skveer1902/fairrl/blob/main/fairrl/models/models.py): `fairrl/models/models.py`
- [Fairness-prioritized replay](https://github.com/skveer1902/fairrl/blob/main/fairrl/models/models.py): `fairrl/models/models.py`

### Fairness and attribution

- [Fairness constraints](https://github.com/skveer1902/fairrl/blob/main/fairrl/fairness/constraints.py): `fairrl/fairness/constraints.py`
- [Constraint optimizer](https://github.com/skveer1902/fairrl/blob/main/fairrl/fairness/constraints.py): `fairrl/fairness/constraints.py`
- [Fairness metrics](https://github.com/skveer1902/fairrl/blob/main/fairrl/fairness/metrics.py): `fairrl/fairness/metrics.py`
- [Integrated Gradients](https://github.com/skveer1902/fairrl/blob/main/fairrl/explainability/ig.py): `fairrl/explainability/ig.py`

### Training and evaluation

- [Pipeline orchestration](https://github.com/skveer1902/fairrl/blob/main/main.py): `main.py`
- [Metrics and artifacts](https://github.com/skveer1902/fairrl/tree/main/results): `results`

### Other components

- **Researcher**

## Connections

- Researcher → Pipeline orchestration: runs pipeline (evidence: `README.md`)
- Pipeline orchestration → Adult data loader: loads data (evidence: `main.py`)
- Pipeline orchestration → Loan environment: sets up decisions (evidence: `README.md`)
- Pipeline orchestration → Double DQN agent: trains agents (evidence: `README.md`)
- Double DQN agent → Q-network: estimates actions (evidence: `fairrl/models/models.py`)
- Double DQN agent → Fairness-prioritized replay: stores experience (evidence: `fairrl/models/models.py`)
- Pipeline orchestration → Constraint optimizer: computes fair rewards (evidence: `main.py`)
- Constraint optimizer → Fairness constraints: applies penalties (evidence: `fairrl/fairness/constraints.py`)
- Fairness constraints → Integrated Gradients: creates explainer (evidence: `fairrl/fairness/constraints.py`)
- Fairness constraints → Fairness metrics (evidence: `fairrl/fairness/constraints.py`)
- Pipeline orchestration → Fairness metrics: evaluates fairness (evidence: `README.md`)
- Pipeline orchestration → Integrated Gradients: analyzes attribution (evidence: `main.py`)
- Pipeline orchestration → Metrics and artifacts: produces comparisons (evidence: `main.py`)
