How dipenarathod/python-code-quality-visualizer works
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: main_branch_metrics_server.py Main-branch runner · BranchMetrics.py Branch metrics workflow · pr_metrics_server.py PR runner · PullRequestMetrics.py PR metric aggregation
Components 21
Dash UI
- Dash bootstrap
AST Research/app.py - Metric views · Details and Halstead exploration views.
AST Research/pages/Details.py - Shared styling
AST Research/assets/style.css
Metric Computation
- Metrics controller · Coordinates quality metric calculation.
AST Research/MetricsClasses/MetricsController.py - Halstead metrics
AST Research/MetricsClasses/HalsteadMetricsClass.py - OO metrics
AST Research/MetricsClasses/OOMetricsClass.py
Main-Branch Pipeline
- Main-branch runner
AST Research/main_branch_metrics_server.py - Main runner config · Repository parameters and GitHub credentials.
AST Research/main_branch_metrics_server_config.json - Branch metrics workflow
AST Research/Branch/BranchMetrics.py - Main metric persistence
AST Research/Branch/MetricsFileManager.py - Main presentation data
AST Research/Branch/MetricsDataFrames.py
Pull-Request Pipeline
- PR runner
AST Research/pr_metrics_server.py - PR runner config
AST Research/pr_config.json - PR collection
AST Research/PullRequests/AllPullRequests.py - PR metric aggregation
AST Research/PullRequests/PullRequestMetrics.py - PR presentation data
AST Research/PullRequests/PullRequestMetricsDataFrames.py
Local State & Outputs
- Main metric snapshots
AST Research/metrics/dipenarathod_desktop-tutorial/Traditional_Metrics.json - PR metric snapshots
AST Research/pull_request_metrics/dipenarathod_desktop-tutorial/Traditional_PRs.json - Processed PR checkpoint
AST Research/processed_prs.json - Server status
AST Research/server_status.json
Other components
- GitHub API · Repository source and pull-request input.
Connections 22
- 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