# dipenarathod/python-code-quality-visualizer architecture

> Architecture diagram of the GitHub repository dipenarathod/python-code-quality-visualizer, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-22). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/dipenarathod/python-code-quality-visualizer
- Repository: https://github.com/dipenarathod/python-code-quality-visualizer

## Overview

#### Purpose and Entry Points
This is a Python proof-of-concept code-quality visualizer supporting a research project. It retrieves GitHub repository content, derives AST-based quality metrics, persists metric snapshots as JSON, and presents them through a multi-page Dash application.

Primary entry points:
- Dash UI bootstrap: `AST Research/app.py`
- Main-branch collection/service runner: `AST Research/main_branch_metrics_server.py`
- Pull-request collection/service runner: `AST Research/pr_metrics_server.py`

#### Dash Presentation Layer
The application is a multi-page Dash UI with a shared stylesheet and metric-specific views. Pages consume stored/calculated metrics and render detail, Halstead, object-oriented, and traditional metric views.
- `AST Research/app.py`
- `AST Research/pages/Details.py`
- `AST Research/pages/Halstead.py`
- `AST Research/assets/style.css`

#### Metric Computation Core
AST-analysis calculator classes define the quality-model boundary. Traditional, Halstead, and OO metrics are distinct computation families; changing metric definitions belongs here rather than in collection or UI code.
- `AST Research/MetricsClasses/MetricsController.py`
- `AST Research/MetricsClasses/HalsteadMetricsClass.py`
- `AST Research/MetricsClasses/OOMetricsClass.py`

#### Main-Branch Processing Pipeline
The branch pipeline coordinates main-branch source processing: calculate metrics, manage metric-file persistence, convert results into DataFrames, and plot/prepare presentation data. `main_branch_metrics_server.py` is the operational boundary around this workflow.
- `AST Research/main_branch_metrics_server.py`
- `AST Research/Branch/BranchMetrics.py`
- `AST Research/Branch/MetricsFileManager.py`
- `AST Research/Branch/MetricsDataFrames.py`

#### Pull-Request Processing Pipeline
PR analysis parallels main-branch analysis but models repository pull requests and PR-scoped metric aggregation separately. It produces stored outputs suitable for PR comparison or visualization.
- `AST Research/pr_metrics_server.py`
- `AST Research/PullRequests/AllPullRequests.py`
- `AST Research/PullRequests/PullRequestMetrics.py`
- `AST Research/PullRequests/PullRequestMetricsDataFrames.py`

#### Persistence and Processing State
Computed main-branch metrics are persisted per repository under `metrics`; PR results go under `pull_request_metrics`. JSON status and processed-item files provide local workflow/checkpoint state, creating a file-system boundary between collection jobs and the Dash UI.
- `AST Research/metrics/dipenarathod_desktop-tutorial/Traditional_Metrics.json`
- `AST Research/pull_request_metrics/dipenarathod_desktop-tutorial/Traditional_PRs.json`
- `AST Research/processed_prs.json`
- `AST Research/server_status.json`

#### External Boundaries and Runtime
The system runs in Python, uses Dash for the interactive application, and depends on GitHub API access authenticated with a Personal Access Token. Repository/API parameters and credentials are configured locally in JSON; the servers likely use these configs to drive GitHub ingestion.
- `AST Research/main_branch_metrics_server_config.json`
- `AST Research/pr_config.json`
- `AST Research/pr_server_status.json`

#### End-to-End Control Flow
A main-branch or PR server reads local configuration, accesses GitHub, obtains code/PR inputs, and sends source through the metrics controller and metric-family calculators. Results are serialized into repository-specific JSON and transformed into DataFrames/plots as needed. Dash pages then load or manage these metric results for user-facing exploration. Main-branch and PR paths intentionally remain separate after their common AST-metric calculation boundary.

Main entry points: [`AST Research/main_branch_metrics_server.py`](https://github.com/dipenarathod/python-code-quality-visualizer/blob/main/AST%20Research/main_branch_metrics_server.py) (Main-branch runner), [`AST Research/Branch/BranchMetrics.py`](https://github.com/dipenarathod/python-code-quality-visualizer/blob/main/AST%20Research/Branch/BranchMetrics.py) (Branch metrics workflow), [`AST Research/pr_metrics_server.py`](https://github.com/dipenarathod/python-code-quality-visualizer/blob/main/AST%20Research/pr_metrics_server.py) (PR runner), [`AST Research/PullRequests/PullRequestMetrics.py`](https://github.com/dipenarathod/python-code-quality-visualizer/blob/main/AST%20Research/PullRequests/PullRequestMetrics.py) (PR metric aggregation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_dash["Dash UI"]
  node_dash_app["Dash bootstrap<br/>Dash application<br/>[app.py]"]
  node_dash_pages["Metric views<br/>Dash pages<br/>[Details.py]"]
  node_stylesheet["Shared styling<br/>CSS asset<br/>[style.css]"]
end

subgraph group_metrics["Metric Computation"]
  node_metrics_controller["Metrics controller<br/>AST metrics boundary"]
  node_halstead["Halstead metrics<br/>metric calculator"]
  node_oo_metrics["OO metrics<br/>metric calculator<br/>[OOMetricsClass.py]"]
end

subgraph group_main["Main-Branch Pipeline"]
  node_main_runner["Main-branch runner<br/>service runner"]
  node_main_config["Main runner config<br/>local JSON config"]
  node_branch_metrics["Branch metrics workflow<br/>pipeline coordinator<br/>[BranchMetrics.py]"]
  node_metrics_files["Main metric persistence<br/>JSON file manager"]
  node_main_dataframes["Main presentation data<br/>DataFrame adapter"]
end

subgraph group_pr["Pull-Request Pipeline"]
  node_pr_runner["PR runner<br/>service runner"]
  node_pr_config["PR runner config<br/>local JSON config<br/>[pr_config.json]"]
  node_all_prs["PR collection<br/>pull-request model<br/>[AllPullRequests.py]"]
  node_pr_metrics["PR metric aggregation<br/>pipeline coordinator"]
  node_pr_dataframes["PR presentation data<br/>DataFrame adapter"]
end

subgraph group_state["Local State &amp; Outputs"]
  node_main_output[("Main metric snapshots<br/>repository JSON output")]
  node_pr_output[("PR metric snapshots<br/>repository JSON output")]
  node_processed_prs["Processed PR checkpoint<br/>workflow state<br/>[processed_prs.json]"]
  node_server_status["Server status<br/>workflow state<br/>[server_status.json]"]
end

node_github{{"GitHub API<br/>external API"}}

node_dash_app -->|"hosts"| node_dash_pages
node_dash_app -->|"loads"| node_stylesheet
node_dash_pages -->|"reads metrics"| node_main_output
node_dash_pages -->|"reads PR metrics"| node_pr_output
node_main_config -->|"configures"| node_main_runner
node_main_runner -->|"fetches source"| node_github
node_main_runner -->|"runs"| node_branch_metrics
node_branch_metrics -->|"calculates"| node_metrics_controller
node_metrics_controller -->|"delegates"| node_halstead
node_metrics_controller -->|"delegates"| node_oo_metrics
node_branch_metrics -->|"persists through"| node_metrics_files
node_metrics_files -->|"writes"| node_main_output
node_branch_metrics -->|"prepares"| node_main_dataframes
node_main_runner -.->|"updates"| node_server_status
node_pr_config -->|"configures"| node_pr_runner
node_pr_runner -->|"fetches PRs"| node_github
node_pr_runner -->|"collects"| node_all_prs
node_all_prs -->|"supplies PR inputs"| node_pr_metrics
node_pr_metrics -->|"calculates"| node_metrics_controller
node_pr_metrics -->|"writes snapshots"| node_pr_output
node_pr_metrics -->|"prepares"| node_pr_dataframes
node_pr_runner -.->|"checkpoints"| node_processed_prs

click node_dash_app "https://github.com/dipenarathod/python-code-quality-visualizer/blob/main/AST%20Research/app.py"
click node_dash_pages "https://github.com/dipenarathod/python-code-quality-visualizer/blob/main/AST%20Research/pages/Details.py"
click node_stylesheet "https://github.com/dipenarathod/python-code-quality-visualizer/blob/main/AST%20Research/assets/style.css"
click node_metrics_controller "https://github.com/dipenarathod/python-code-quality-visualizer/blob/main/AST%20Research/MetricsClasses/MetricsController.py"
click node_halstead "https://github.com/dipenarathod/python-code-quality-visualizer/blob/main/AST%20Research/MetricsClasses/HalsteadMetricsClass.py"
click node_oo_metrics "https://github.com/dipenarathod/python-code-quality-visualizer/blob/main/AST%20Research/MetricsClasses/OOMetricsClass.py"
click node_main_runner "https://github.com/dipenarathod/python-code-quality-visualizer/blob/main/AST%20Research/main_branch_metrics_server.py"
click node_main_config "https://github.com/dipenarathod/python-code-quality-visualizer/blob/main/AST%20Research/main_branch_metrics_server_config.json"
click node_branch_metrics "https://github.com/dipenarathod/python-code-quality-visualizer/blob/main/AST%20Research/Branch/BranchMetrics.py"
click node_metrics_files "https://github.com/dipenarathod/python-code-quality-visualizer/blob/main/AST%20Research/Branch/MetricsFileManager.py"
click node_main_dataframes "https://github.com/dipenarathod/python-code-quality-visualizer/blob/main/AST%20Research/Branch/MetricsDataFrames.py"
click node_pr_runner "https://github.com/dipenarathod/python-code-quality-visualizer/blob/main/AST%20Research/pr_metrics_server.py"
click node_pr_config "https://github.com/dipenarathod/python-code-quality-visualizer/blob/main/AST%20Research/pr_config.json"
click node_all_prs "https://github.com/dipenarathod/python-code-quality-visualizer/blob/main/AST%20Research/PullRequests/AllPullRequests.py"
click node_pr_metrics "https://github.com/dipenarathod/python-code-quality-visualizer/blob/main/AST%20Research/PullRequests/PullRequestMetrics.py"
click node_pr_dataframes "https://github.com/dipenarathod/python-code-quality-visualizer/blob/main/AST%20Research/PullRequests/PullRequestMetricsDataFrames.py"
click node_main_output "https://github.com/dipenarathod/python-code-quality-visualizer/blob/main/AST%20Research/metrics/dipenarathod_desktop-tutorial/Traditional_Metrics.json"
click node_pr_output "https://github.com/dipenarathod/python-code-quality-visualizer/blob/main/AST%20Research/pull_request_metrics/dipenarathod_desktop-tutorial/Traditional_PRs.json"
click node_processed_prs "https://github.com/dipenarathod/python-code-quality-visualizer/blob/main/AST%20Research/processed_prs.json"
click node_server_status "https://github.com/dipenarathod/python-code-quality-visualizer/blob/main/AST%20Research/server_status.json"

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_dash_app,node_dash_pages,node_stylesheet toneBlue
class node_metrics_controller,node_halstead,node_oo_metrics toneAmber
class node_main_runner,node_main_config,node_branch_metrics,node_metrics_files,node_main_dataframes toneMint
class node_pr_runner,node_pr_config,node_all_prs,node_pr_metrics,node_pr_dataframes toneRose
class node_main_output,node_pr_output,node_processed_prs,node_server_status toneIndigo
class node_github toneNeutral
```

## Components

### Dash UI

- [Dash bootstrap](https://github.com/dipenarathod/python-code-quality-visualizer/blob/main/AST%20Research/app.py): Dash application · `AST Research/app.py`
- [Metric views](https://github.com/dipenarathod/python-code-quality-visualizer/blob/main/AST%20Research/pages/Details.py): Dash pages · Details and Halstead exploration views. · `AST Research/pages/Details.py`
- [Shared styling](https://github.com/dipenarathod/python-code-quality-visualizer/blob/main/AST%20Research/assets/style.css): CSS asset · `AST Research/assets/style.css`

### Metric Computation

- [Metrics controller](https://github.com/dipenarathod/python-code-quality-visualizer/blob/main/AST%20Research/MetricsClasses/MetricsController.py): AST metrics boundary · Coordinates quality metric calculation. · `AST Research/MetricsClasses/MetricsController.py`
- [Halstead metrics](https://github.com/dipenarathod/python-code-quality-visualizer/blob/main/AST%20Research/MetricsClasses/HalsteadMetricsClass.py): metric calculator · `AST Research/MetricsClasses/HalsteadMetricsClass.py`
- [OO metrics](https://github.com/dipenarathod/python-code-quality-visualizer/blob/main/AST%20Research/MetricsClasses/OOMetricsClass.py): metric calculator · `AST Research/MetricsClasses/OOMetricsClass.py`

### Main-Branch Pipeline

- [Main-branch runner](https://github.com/dipenarathod/python-code-quality-visualizer/blob/main/AST%20Research/main_branch_metrics_server.py): service runner · `AST Research/main_branch_metrics_server.py`
- [Main runner config](https://github.com/dipenarathod/python-code-quality-visualizer/blob/main/AST%20Research/main_branch_metrics_server_config.json): local JSON config · Repository parameters and GitHub credentials. · `AST Research/main_branch_metrics_server_config.json`
- [Branch metrics workflow](https://github.com/dipenarathod/python-code-quality-visualizer/blob/main/AST%20Research/Branch/BranchMetrics.py): pipeline coordinator · `AST Research/Branch/BranchMetrics.py`
- [Main metric persistence](https://github.com/dipenarathod/python-code-quality-visualizer/blob/main/AST%20Research/Branch/MetricsFileManager.py): JSON file manager · `AST Research/Branch/MetricsFileManager.py`
- [Main presentation data](https://github.com/dipenarathod/python-code-quality-visualizer/blob/main/AST%20Research/Branch/MetricsDataFrames.py): DataFrame adapter · `AST Research/Branch/MetricsDataFrames.py`

### Pull-Request Pipeline

- [PR runner](https://github.com/dipenarathod/python-code-quality-visualizer/blob/main/AST%20Research/pr_metrics_server.py): service runner · `AST Research/pr_metrics_server.py`
- [PR runner config](https://github.com/dipenarathod/python-code-quality-visualizer/blob/main/AST%20Research/pr_config.json): local JSON config · `AST Research/pr_config.json`
- [PR collection](https://github.com/dipenarathod/python-code-quality-visualizer/blob/main/AST%20Research/PullRequests/AllPullRequests.py): pull-request model · `AST Research/PullRequests/AllPullRequests.py`
- [PR metric aggregation](https://github.com/dipenarathod/python-code-quality-visualizer/blob/main/AST%20Research/PullRequests/PullRequestMetrics.py): pipeline coordinator · `AST Research/PullRequests/PullRequestMetrics.py`
- [PR presentation data](https://github.com/dipenarathod/python-code-quality-visualizer/blob/main/AST%20Research/PullRequests/PullRequestMetricsDataFrames.py): DataFrame adapter · `AST Research/PullRequests/PullRequestMetricsDataFrames.py`

### Local State & Outputs

- [Main metric snapshots](https://github.com/dipenarathod/python-code-quality-visualizer/blob/main/AST%20Research/metrics/dipenarathod_desktop-tutorial/Traditional_Metrics.json): repository JSON output · `AST Research/metrics/dipenarathod_desktop-tutorial/Traditional_Metrics.json`
- [PR metric snapshots](https://github.com/dipenarathod/python-code-quality-visualizer/blob/main/AST%20Research/pull_request_metrics/dipenarathod_desktop-tutorial/Traditional_PRs.json): repository JSON output · `AST Research/pull_request_metrics/dipenarathod_desktop-tutorial/Traditional_PRs.json`
- [Processed PR checkpoint](https://github.com/dipenarathod/python-code-quality-visualizer/blob/main/AST%20Research/processed_prs.json): workflow state · `AST Research/processed_prs.json`
- [Server status](https://github.com/dipenarathod/python-code-quality-visualizer/blob/main/AST%20Research/server_status.json): workflow state · `AST Research/server_status.json`

### Other components

- **GitHub API**: external API · Repository source and pull-request input.

## Connections

- Dash bootstrap → Metric views: hosts
- Dash bootstrap → Shared styling: loads
- Metric views → Main metric snapshots: reads metrics
- Metric views → PR metric snapshots: reads PR metrics
- Main runner config → Main-branch runner: configures
- Main-branch runner → GitHub API: fetches source
- Main-branch runner → Branch metrics workflow: runs
- Branch metrics workflow → Metrics controller: calculates
- Metrics controller → Halstead metrics: delegates
- Metrics controller → OO metrics: delegates
- Branch metrics workflow → Main metric persistence: persists through
- Main metric persistence → Main metric snapshots: writes
- Branch metrics workflow → Main presentation data: prepares
- Main-branch runner → Server status: updates
- PR runner config → PR runner: configures
- PR runner → GitHub API: fetches PRs
- PR runner → PR collection: collects
- PR collection → PR metric aggregation: supplies PR inputs
- PR metric aggregation → Metrics controller: calculates
- PR metric aggregation → PR metric snapshots: writes snapshots
- PR metric aggregation → PR presentation data: prepares
- PR runner → Processed PR checkpoint: checkpoints
