# unity-technologies/projectauditor architecture

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

- Interactive diagram: https://gitdiagram.com/unity-technologies/projectauditor
- Repository: https://github.com/unity-technologies/projectauditor

## Overview

##### Main Components
- Project Auditor Core – the central engine that coordinates analysis.
- Data & Configuration – the “Data” folder contains JSON files (e.g., ApiDatabase.json, ProjectSettings.json, RoslynTextLookup.json) which act as configuration and lookup data for the analysis.
- Editor Integration:
- API Layer – located under the Editor/API folder; exposes types like AnalysisParams, Rule, Report, etc., which are key to configuring and triggering audits.
- Code Analysis & Assembly Utilities – found under Editor/CodeAnalysis and Editor/AssemblyUtils; these components are responsible for collecting and processing metadata from code and assemblies.
- Modules – under Editor/Modules and Editor/SettingsAnalysis; these provide specialized analyzers for different domains (Animation, Assets, AudioClips, Code, Meshes, Shaders, Texture, etc.).
- UI – under Editor/UI; manages the presentation layer for audit reports and diagnostic information. The framework subfolder further contains components for views, charts, tables, and selection windows.
- Roslyn Analyzers – the “RoslynAnalyzers” directory indicates the integration with Roslyn for additional code diagnostics.
- Testing – the “Tests” directory supports unit and integration testing for nearly all major functionalities.

##### Relationships and Interactions
- The Unity Editor triggers Project Auditor (as it is a Unity package installed into the project) and loads the Project Auditor window.
- The UI layer interacts with the core API to request analyses and display results.
- The core modules (API, CodeAnalysis, AssemblyUtils, Modules, SettingsAnalysis) work together to process assets, code, settings, and build reports.
- Data and configuration files feed into the analysis routines by providing reference data and settings.
- Roslyn Analyzers complement the built-in analysis engines, adding code diagnostic capabilities.
- Test suites are set up to simulate these interactions and provide feedback to developers.

##### Architectural Patterns and Principles
- Modular design: The system is divided into highly focused modules (each in its own directory) handling specific aspects of the analysis. This promotes maintainability and extensibility.
- Separation of concerns: The API, Analysis, UI, and Data layers are distinctly separated. Each handles its own logic without excessive coupling.
- Extensibility: By exposing an API and definable module analyzers, the tool can be extended with additional analysis types or integrations.
- Dependency Management: The project uses Unity’s package distribution and integration conventions. The clear file/tree separation (Editor vs. Data vs. Tests) reflects this pattern.

##### Final Advice
- Break the Editor folder into sub-components that reflect logical groups (API, Analysis, UI).
- How these components interact in terms of both data flow and control flow. For instance, when a user triggers a scan in the ProjectAuditorWindow, it calls into the API, which then delegates work among various Analyzer Modules, each possibly consulting configuration data.

## Diagram (Mermaid)

```mermaid
flowchart TD
    UE["Unity Editor"]:::external
    UI["ProjectAuditorWindow (Editor UI)"]:::ui
    API["API Layer (Exposes AnalysisParams,Rule,Report)"]:::api
    CORE["Project Auditor Core (Analysis Engine)"]:::core

    subgraph "Analysis Engines"
        CA["Code Analysis (Editor/CodeAnalysis)"]:::module
        AU["Assembly Utilities (Editor/AssemblyUtils)"]:::module
        MOD["Module Analyzers (Editor/Modules)"]:::module
        SA["Settings Analysis (Editor/SettingsAnalysis)"]:::module
    end

    DATA["Data & Configuration (JSON Files)"]:::data
    ROS["Roslyn Analyzers"]:::analyzer
    TEST["Testing Suite"]:::test

    UE -->|"triggers"| UI
    UI -->|"invokes"| API
    API -->|"delegates to"| CORE
    DATA -->|"supplies data to"| CORE
    CORE -->|"processes using"| CA
    CORE -->|"processes using"| AU
    CORE -->|"processes using"| MOD
    CORE -->|"processes using"| SA
    CA -->|"complements"| ROS
    TEST ---|"validates"| CORE

    click CORE "https://github.com/unity-technologies/projectauditor/tree/0.11.0/Editor/Core"
    click DATA "https://github.com/unity-technologies/projectauditor/tree/0.11.0/Data"
    click API "https://github.com/unity-technologies/projectauditor/tree/0.11.0/Editor/API"
    click CA "https://github.com/unity-technologies/projectauditor/tree/0.11.0/Editor/CodeAnalysis"
    click AU "https://github.com/unity-technologies/projectauditor/tree/0.11.0/Editor/AssemblyUtils"
    click MOD "https://github.com/unity-technologies/projectauditor/tree/0.11.0/Editor/Modules"
    click SA "https://github.com/unity-technologies/projectauditor/tree/0.11.0/Editor/SettingsAnalysis"
    click UI "https://github.com/unity-technologies/projectauditor/tree/0.11.0/Editor/UI"
    click ROS "https://github.com/unity-technologies/projectauditor/tree/0.11.0/RoslynAnalyzers"
    click TEST "https://github.com/unity-technologies/projectauditor/tree/0.11.0/Tests"

    classDef external fill:#F5F5F5,stroke:#333,stroke-width:2px;
    classDef ui fill:#FFCC00,stroke:#333,stroke-width:2px;
    classDef api fill:#66CCFF,stroke:#333,stroke-width:2px;
    classDef core fill:#FFA500,stroke:#333,stroke-width:2px;
    classDef module fill:#90EE90,stroke:#333,stroke-width:2px;
    classDef data fill:#CCCCFF,stroke:#333,stroke-width:2px;
    classDef analyzer fill:#DDA0DD,stroke:#333,stroke-width:2px;
    classDef test fill:#FF9999,stroke:#333,stroke-width:2px;
```
