# har9421/codereviewproject architecture

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

- Interactive diagram: https://gitdiagram.com/har9421/codereviewproject
- Repository: https://github.com/har9421/codereviewproject

## Overview

##### Project type and purpose
- This is a standalone code‐review automation tool written in .NET Core (C#) that also supports JavaScript/TypeScript via ESLint.
- It’s designed to run in a CI/CD pipeline (Azure Pipelines) to fetch coding standards (JSON), analyze code (Roslyn for C#, ESLint for JS/TS), post inline comments on Azure DevOps pull requests, and optionally block the PR on error‐level violations.

##### File structure
Top level
- azure-pipelines.yml / azure-pipelines-github-bot.yml → pipeline definitions
- package.json → JS/TS ESLint dependencies (for React support)
- run-test.sh, test-*.sh → local automation scripts
- src/CodeReviewRunner → .NET Core service project
– Configuration (CodeReviewOptions, ResilienceOptions)
– Interfaces (IAnalysisService, IAzureDevOpsService, ICodeReviewService, IRulesService)
– Services (AnalysisService, AzureDevOpsService, CSharpAnalyzer, CodeReviewService, RuleFetcher, RulesService)
– Models (CodeIssue, CodingRule)
– HealthChecks (e.g., AzureDevOpsHealthCheck)
– appsettings*.json → environment-specific configuration
- tests/CodeReviewRunner.Tests → unit tests

##### README for additional insights
- Reads coding standards from remote JSON
- Runs analyzers on C# and JS/TS
- Posts comments directly on Azure DevOps PR
- Pipeline variables: CODING_STANDARDS_URL, OAuth token

##### Detail
- Retry/resilience policy around external calls
- That CodeIssue objects flow from analyzers to the review poster
- Don’t overthink: break the runner into as many logical components as shown in the file tree

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External CI/CD
    subgraph "CI/CD Pipeline"
        Pipelines["Azure Pipelines"]:::external
    end

    %% Application Entry
    Pipelines -->|"trigger"| Runner["CodeReviewRunner"]:::service
    click Pipelines "https://github.com/har9421/codereviewproject/blob/main/azure-pipelines.yml"
    click Pipelines "https://github.com/har9421/codereviewproject/blob/main/azure-pipelines-github-bot.yml"
    click Runner "https://github.com/har9421/codereviewproject/blob/main/src/CodeReviewRunner/Program.cs"

    %% Configuration Layer
    subgraph "Configuration Layer"
        ConfigLoader["Configuration Loader"]:::config
        AppSettings["appsettings.json / Development / Production"]:::config
    end
    Runner --> ConfigLoader
    ConfigLoader --> AppSettings
    click ConfigLoader "https://github.com/har9421/codereviewproject/tree/main/src/CodeReviewRunner/Configuration"
    click AppSettings "https://github.com/har9421/codereviewproject/blob/main/src/CodeReviewRunner/appsettings.json"
    click AppSettings "https://github.com/har9421/codereviewproject/blob/main/src/CodeReviewRunner/appsettings.Development.json"
    click AppSettings "https://github.com/har9421/codereviewproject/blob/main/src/CodeReviewRunner/appsettings.Production.json"

    %% Rule Management
    subgraph "Rule Management"
        RuleFetcher["RuleFetcher"]:::service
        RulesService["RulesService"]:::service
        RemoteJSON["Remote JSON Store"]:::external
    end
    ConfigLoader --> RuleFetcher
    RuleFetcher --> RulesService
    RuleFetcher -->|fetch JSON| RemoteJSON
    click RuleFetcher "https://github.com/har9421/codereviewproject/blob/main/src/CodeReviewRunner/Services/RuleFetcher.cs"
    click RulesService "https://github.com/har9421/codereviewproject/blob/main/src/CodeReviewRunner/Services/RulesService.cs"

    %% Analysis Layer
    subgraph "Analysis Layer"
        AnalysisService["AnalysisService"]:::service
        CSharpAnalyzer["CSharpAnalyzer"]:::service
        ESLintRunner["ESLint Runner"]:::service
    end
    RulesService --> AnalysisService
    AnalysisService --> CSharpAnalyzer
    AnalysisService --> ESLintRunner
    click AnalysisService "https://github.com/har9421/codereviewproject/blob/main/src/CodeReviewRunner/Services/AnalysisService.cs"
    click CSharpAnalyzer "https://github.com/har9421/codereviewproject/blob/main/src/CodeReviewRunner/Services/CSharpAnalyzer.cs"
    click ESLintRunner "https://github.com/har9421/codereviewproject/blob/main/package.json"

    %% ESLint Scripts
    ESLintRunner --> Scripts["Shell Scripts"]:::service
    click Scripts "https://github.com/har9421/codereviewproject/blob/main/run-test.sh"
    click Scripts "https://github.com/har9421/codereviewproject/blob/main/test-azure-api.sh"
    click Scripts "https://github.com/har9421/codereviewproject/blob/main/test-azure-fix.sh"
    click Scripts "https://github.com/har9421/codereviewproject/blob/main/test-fixed-logic.sh"
    click Scripts "https://github.com/har9421/codereviewproject/blob/main/test-local.sh"
    click Scripts "https://github.com/har9421/codereviewproject/blob/main/debug-azure-api-direct.sh"

    %% Reporting Layer
    subgraph "Reporting Layer"
        CodeReviewService["CodeReviewService"]:::service
        AzureDevOpsService["AzureDevOpsService"]:::service
        DevOpsAPI["Azure DevOps REST API"]:::external
    end
    AnalysisService --> CodeReviewService
    CodeReviewService --> AzureDevOpsService
    AzureDevOpsService -->|post comments / block PR| DevOpsAPI
    click CodeReviewService "https://github.com/har9421/codereviewproject/blob/main/src/CodeReviewRunner/Services/CodeReviewService.cs"
    click AzureDevOpsService "https://github.com/har9421/codereviewproject/blob/main/src/CodeReviewRunner/Services/AzureDevOpsService.cs"

    %% Health Checks
    subgraph "Health Checks"
        HealthCheck["AzureDevOpsHealthCheck"]:::service
    end
    Runner --> HealthCheck
    click HealthCheck "https://github.com/har9421/codereviewproject/blob/main/src/CodeReviewRunner/HealthChecks/AzureDevOpsHealthCheck.cs"

    %% Models
    subgraph "Data Models"
        CodeIssue["CodeIssue"]:::model
        CodingRule["CodingRule"]:::model
    end
    AnalysisService --> CodeIssue
    RulesService --> CodingRule
    click CodeIssue "https://github.com/har9421/codereviewproject/blob/main/src/CodeReviewRunner/Models/CodeIssue.cs"
    click CodingRule "https://github.com/har9421/codereviewproject/blob/main/src/CodeReviewRunner/Models/CodingRule.cs"

    %% Interfaces
    subgraph "Interfaces"
        IAnalysis["IAnalysisService"]:::interface
        ICodeReview["ICodeReviewService"]:::interface
        IAzureDevOps["IAzureDevOpsService"]:::interface
    end
    AnalysisService --> IAnalysis
    CodeReviewService --> ICodeReview
    AzureDevOpsService --> IAzureDevOps
    click IAnalysis "https://github.com/har9421/codereviewproject/blob/main/src/CodeReviewRunner/Interfaces/IAnalysisService.cs"
    click ICodeReview "https://github.com/har9421/codereviewproject/blob/main/src/CodeReviewRunner/Interfaces/ICodeReviewService.cs"
    click IAzureDevOps "https://github.com/har9421/codereviewproject/blob/main/src/CodeReviewRunner/Interfaces/IAzureDevOpsService.cs"

    %% Tests
    subgraph "Unit Tests"
        Tests["CodeReviewRunner.Tests"]:::test
    end
    Tests --> CSharpAnalyzer
    click Tests "https://github.com/har9421/codereviewproject/blob/main/tests/CodeReviewRunner.Tests/CSharpAnalyzerTests.cs"
    click Tests "https://github.com/har9421/codereviewproject/blob/main/tests/CodeReviewRunner.Tests/CodeReviewRunner.Tests.csproj"

    %% Solution
    Runner --> Solution["Solution File"]:::service
    click Solution "https://github.com/har9421/codereviewproject/blob/main/CodeReviewProject.sln"

    %% Styles
    classDef external fill:#dddddd,stroke:#888888,stroke-width:1px;
    classDef service fill:#add8e6,stroke:#0366d6,stroke-width:1px;
    classDef config fill:#d4edda,stroke:#28a745,stroke-width:1px;
    classDef model fill:#ffeeba,stroke:#d39e00,stroke-width:1px;
    classDef interface fill:#f5c6cb,stroke:#a71d2a,stroke-width:1px;
    classDef test fill:#e2e3e5,stroke:#6c757d,stroke-width:1px;
```
