# denzyldick/phanalist architecture

> Architecture diagram of the GitHub repository denzyldick/phanalist, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/denzyldick/phanalist
- Repository: https://github.com/denzyldick/phanalist

## Overview

##### Main Components Identification

The system can be broken down into these primary components:

a) Input Processing Layer
- Configuration handling (config.rs)
- File system interaction (file.rs)

b) Analysis Core
- Main analyzer engine (analyse.rs)
- Rules engine (rules/mod.rs)
- Individual rule implementations (rules/e*.rs)

c) Output Generation
- Results processing (results.rs)
- Output formatting (output.rs)

**┌─ Input Layer ─────────┐**
- PHP Source Files    │
- Configuration YAML  │
- ┬───────────┘
- ↓
**┌─ Analysis Core ───────┐**
- ┌─ Rule Engine ────┐  │
- Rule Modules    │  │
- E0001-E0013   │  │
- ┘  │
- ┌─ AST Processing ─┐  │
- Parser & Visitor │  │
- ┘  │
- ┬───────────┘
- ↓
**┌─ Output Layer ────────┐**
- Text Format        │
- JSON Format        │
- SARIF Format       │
- ┘

##### Important Architectural Aspects to Highlight

a) Rule System Architecture:
- How rules are modular and independently implemented
- Rule registration system
- Relationship between rules and examples

b) Multi-format Output System:
- Different output format options
- How the output formatter interfaces with the results

c) Configuration System:
- How configuration affects both rule behavior and system operation
- Default configuration flow

##### Cross-cutting Concerns

- Multi-platform support (shown by release targets)
- Docker container support
- CI/CD integration points

##### Specific Implementation Details

- The AST-based analysis approach
- Rule configuration inheritance
- The visitor pattern implementation for PHP parsing
- The separation between analysis and reporting

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Input
        PHP[PHP Source Files]
        Config[Configuration YAML]:::config
        click Config "https://github.com/denzyldick/phanalist/blob/main/phanalist.yaml"
    end

    subgraph "Analysis Core"
        direction TB
        ConfigHandler[Configuration Handler]:::core
        click ConfigHandler "https://github.com/denzyldick/phanalist/blob/main/src/config.rs"
        FSHandler[File System Handler]:::core
        click FSHandler "https://github.com/denzyldick/phanalist/blob/main/src/file.rs"
        MainAnalyzer[Main Analyzer Engine]:::core
        click MainAnalyzer "https://github.com/denzyldick/phanalist/blob/main/src/analyse.rs"
        
        subgraph "Rule Engine"
            direction TB
            RuleEngine[Rules Engine]:::rules
            click RuleEngine "https://github.com/denzyldick/phanalist/blob/main/src/rules/mod.rs"
            Rules[Individual Rules]:::rules
            click Rules "https://github.com/denzyldick/phanalist/tree/main/src/rules"
            Examples[Rule Examples]:::rules
            click Examples "https://github.com/denzyldick/phanalist/tree/main/src/rules/examples/"
        end
        
        AST[AST Processing]:::core
        Visitor[Parser & Visitor]:::core
    end

    subgraph Output
        ResultsProc[Results Processor]:::output
        click ResultsProc "https://github.com/denzyldick/phanalist/blob/main/src/results.rs"
        OutputFmt[Output Formatter]:::output
        click OutputFmt "https://github.com/denzyldick/phanalist/blob/main/src/output.rs"
        
        Formats["Output Formats<br/>Text | JSON | SARIF"]:::output
    end

    subgraph "Entry Points"
        Main[Main Entry]:::entry
        click Main "https://github.com/denzyldick/phanalist/blob/main/src/main.rs"
        Lib[Core Library]:::entry
        click Lib "https://github.com/denzyldick/phanalist/blob/main/src/lib.rs"
    end

    PHP --> FSHandler
    Config --> ConfigHandler
    FSHandler --> MainAnalyzer
    ConfigHandler --> MainAnalyzer
    MainAnalyzer --> AST
    AST --> Visitor
    Visitor --> RuleEngine
    RuleEngine --> Rules
    Rules --> Examples
    Rules --> ResultsProc
    ResultsProc --> OutputFmt
    OutputFmt --> Formats
    Main --> Lib
    Lib --> MainAnalyzer

    classDef core fill:#90EE90,stroke:#333,stroke-width:2px
    classDef rules fill:#FFA500,stroke:#333,stroke-width:2px
    classDef output fill:#87CEEB,stroke:#333,stroke-width:2px
    classDef config fill:#FFE4B5,stroke:#333,stroke-width:2px
    classDef entry fill:#DDA0DD,stroke:#333,stroke-width:2px

    subgraph Legend
        L1[Core Components]:::core
        L2[Rule Components]:::rules
        L3[Output Components]:::output
        L4[Configuration]:::config
        L5[Entry Points]:::entry
    end
```
