# yao-mxu/discrimination_reporting architecture

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

- Interactive diagram: https://gitdiagram.com/yao-mxu/discrimination_reporting
- Repository: https://github.com/yao-mxu/discrimination_reporting

## Overview

##### Project Type & Purpose
- This is a full-stack R Shiny application for interactive descriptive analytics of employment discrimination data in California. Users point their browsers to a Shiny server, explore time-series charts, correlation matrices, and access static resources (PDFs).

##### File Structure
Top-level files:
- app.R, ui.R, server.R – Core Shiny entry points and logic
- Interactive_Descriptives_*.R – Archived scripts for data prep/visual exploration
- reporting_test_*.RData – Pre-processed datasets loaded by server.R
- www/ – Static assets (flowchart.pdf) served by Shiny
- Law/ – Static reference documents (PDFs/RTF)
- README.md – High-level description, flowcharts, feature list

##### Extract Architectural Insights from README
- Reactive UI inputs trigger server computations
- Plots and tables generated on the fly (ggplot2, dplyr, plotly?)
- Links to external DFEH resources
- Single-page, tabbed UI

##### Main Components & Their Relationships
A. Client (Web Browser)
- Sends HTTP/WebSocket requests to Shiny
- Renders HTML/CSS/JS returned by Shiny
B. Shiny Server (R Process)
- UI Layer (ui.R/app.R) – defines input controls & layout
- Server Layer (server.R/app.R) – reactive expressions, data loading, plotting functions
- Static Asset Handler – serves www/ folder contents
C. Data Store
- reporting_test_*.RData files loaded at startup
- Optional: raw data pipelines (Interactive_Descriptives_*.R scripts) run offline
D. External Services
- DFEH official website (links in UI)
- GitHub repository (for code updates, flowchart.png)

Interactions:
1. Browser → Shiny Server (user input events)
2. Server → Data Store (load RData, query in-memory data frames)
3. Server → UI (push updated plots/tables via reactive outputs)
4. UI → External Links (DFEH website in new tabs)

##### Architectural Patterns & Technologies
- MVC-like pattern: ui.R (view), server.R (controller), RData (model)
- Reactive programming (Shiny’s reactive, observeEvent)
- ggplot2/dplyr for data transformation & visualization
- Static asset hosting via www/

##### Detailed Component Breakdown (to include
1. Client
- Browser (HTML/CSS/JS)
- Shiny’s websocket connection
2. Shiny Server Process
- UI Definition (ui.R / app.R)
- Server Logic (server.R / app.R)
- Reactive Engine (reactive(), observeEvent())
- Static File Handler (serves www/)
3. Data Layer
- reporting_test_*.RData (pre-loaded data frames)
- Interactive_Descriptives_*.R (offline scripts—annotate as “data prep pipeline”)
- Law folder (static PDF references)
4. External Services
- DFEH Official Website
- GitHub asset links

##### Final Checklist
- Call out major R packages & frameworks
- No “black hole”: every input has a corresponding output or data source

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Presentation Layer"
        direction TB
        Browser["Web Browser<br/>(HTML/CSS/JS)"]:::presentation
    end

    %% Application Layer
    subgraph "Application Layer"
        direction TB
        UI_Definition["UI Definition<br/>(ui.R / app.R)"]:::application
        Server_Logic["Server Logic<br/>(server.R / app.R)"]:::application
        Reactive_Engine["Reactive Engine<br/>(reactive(), observeEvent())"]:::application
        Static_Asset_Handler["Static Asset Handler<br/>(serves www/)"]:::application
    end

    %% Data Layer
    subgraph "Data Layer"
        direction TB
        Preloaded_Data_Store["Pre-loaded Data Store<br/>(.RData files)"]:::data
        Data_Prep_Pipeline["Data Prep Pipeline<br/>(Offline Scripts)"]:::data
        Reference_Documents["Reference Documents<br/>(Law/ PDFs/RTF)"]:::data
    end

    %% External Services
    subgraph "External Services"
        direction TB
        DFEH_Website["DFEH Official Website"]:::external
        GitHub_Repo["GitHub Repository"]:::external
    end

    %% Documentation
    README["README.md"]:::external
    Flowchart_Diagram["Flowchart Diagram<br/>(DFEH_EmploymentFlowchart_ENG.pdf)"]:::external

    %% Connections
    Browser -->|"HTTP/WebSocket"| UI_Definition
    UI_Definition -->|"defines layout & inputs"| Reactive_Engine
    Reactive_Engine -->|"triggers"| Server_Logic
    Server_Logic -->|"load .RData"| Preloaded_Data_Store
    Server_Logic -->|"serves static files"| Static_Asset_Handler
    Static_Asset_Handler -->|"deliver PDFs/Assets"| Browser
    UI_Definition -->|"link click"| DFEH_Website
    UI_Definition -->|"link to code/assets"| GitHub_Repo
    UI_Definition -->|"show docs"| README
    Static_Asset_Handler -->|"serve flowchart"| Flowchart_Diagram
    Data_Prep_Pipeline --> Preloaded_Data_Store

    %% Click Events
    click UI_Definition "https://github.com/yao-mxu/discrimination_reporting/blob/master/ui.R"
    click UI_Definition "https://github.com/yao-mxu/discrimination_reporting/blob/master/app.R"
    click Server_Logic "https://github.com/yao-mxu/discrimination_reporting/blob/master/server.R"
    click Server_Logic "https://github.com/yao-mxu/discrimination_reporting/blob/master/app.R"
    click Reactive_Engine "https://github.com/yao-mxu/discrimination_reporting/blob/master/ui.R"
    click Reactive_Engine "https://github.com/yao-mxu/discrimination_reporting/blob/master/server.R"
    click Static_Asset_Handler "https://github.com/yao-mxu/discrimination_reporting/tree/master/www/"
    click Preloaded_Data_Store "https://github.com/yao-mxu/discrimination_reporting/blob/master/reporting_test_20220512.RData"
    click Preloaded_Data_Store "https://github.com/yao-mxu/discrimination_reporting/blob/master/reporting_test_20220628.RData"
    click Preloaded_Data_Store "https://github.com/yao-mxu/discrimination_reporting/blob/master/reporting_test_poli_20220625.RData"
    click Data_Prep_Pipeline "https://github.com/yao-mxu/discrimination_reporting/blob/master/Interactive_Descriptives_20220512.R"
    click Data_Prep_Pipeline "https://github.com/yao-mxu/discrimination_reporting/blob/master/Interactive_Descriptives_20220514.R"
    click Data_Prep_Pipeline "https://github.com/yao-mxu/discrimination_reporting/blob/master/Interactive_Descriptives_20220515.R"
    click Data_Prep_Pipeline "https://github.com/yao-mxu/discrimination_reporting/blob/master/Interactive_Descriptives_20220516.R"
    click Data_Prep_Pipeline "https://github.com/yao-mxu/discrimination_reporting/blob/master/Interactive_Descriptives_20220517.R"
    click Data_Prep_Pipeline "https://github.com/yao-mxu/discrimination_reporting/blob/master/Interactive_Descriptives_20220519.R"
    click Data_Prep_Pipeline "https://github.com/yao-mxu/discrimination_reporting/blob/master/Interactive_Descriptives_20220525.R"
    click Data_Prep_Pipeline "https://github.com/yao-mxu/discrimination_reporting/blob/master/Interactive_Descriptives_20220629.R"
    click Data_Prep_Pipeline "https://github.com/yao-mxu/discrimination_reporting/blob/master/Interactive_Descriptives_20220706.R"
    click Data_Prep_Pipeline "https://github.com/yao-mxu/discrimination_reporting/blob/master/Interactive_Descriptives_20220710.R"
    click Data_Prep_Pipeline "https://github.com/yao-mxu/discrimination_reporting/blob/master/Interactive_Descriptives_20220720.R"
    click Reference_Documents "https://github.com/yao-mxu/discrimination_reporting/tree/master/Law/"
    click README "https://github.com/yao-mxu/discrimination_reporting/blob/master/README.md"
    click Flowchart_Diagram "https://github.com/yao-mxu/discrimination_reporting/blob/master/DFEH_EmploymentFlowchart_ENG.pdf"

    %% Styles
    classDef presentation fill:#D6E4FF,stroke:#333,stroke-width:1px;
    classDef application fill:#D0F0C0,stroke:#333,stroke-width:1px;
    classDef data fill:#FFE4B5,stroke:#333,stroke-width:1px;
    classDef external fill:#E0E0E0,stroke:#333,stroke-width:1px;
```
