# uber-go/nilaway architecture

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

- Interactive diagram: https://gitdiagram.com/uber-go/nilaway
- Repository: https://github.com/uber-go/nilaway

## Overview

##### Main Components

a. Entry Points Layer:
- Command-line interfaces (cmd/nilaway, cmd/gclplugin)
- Integration points (golangci-lint, nogo, standalone)

b. Core Analysis Layer:
- Analyzer components
- Inference engine
- Diagnostic engine

c. Analysis Components Layer:
- Annotation system
- Assertion handling
- Accumulation system

d. Utility Layer:
- AST helpers
- Analysis helpers
- Configuration management

##### Specific Implementation Details

**[Entry Points Layer]**

- v
**[Configuration Layer]**

- v
**[Core Analysis Pipeline]**

- > [Annotation System] --> [Assertion Handler]

- > [Inference Engine] --> [Analysis Cache]

- > [Diagnostic Engine] --> [Error Reporting]

- v
**[Integration Layer]**

##### Technical Details to Emphasize

- Fact mechanism integration
- Cross-package analysis capabilities
- Caching mechanisms
- Plugin system architecture

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Entry
        CLI["Command Line Interface"]
        GCL["GolangCI-Lint Plugin"]
        NOGO["Nogo Integration"]
    end

    subgraph Config
        CONF["Configuration Management"]
    end

    subgraph Core
        ANALYZER["Core Analyzer"]
        INFER["Inference Engine"]
        DIAG["Diagnostic Engine"]
    end

    subgraph Analysis
        ANNOT["Annotation System"]
        ASSERT["Assertion Handler"]
        ACCUM["Accumulation System"]
        FUNC["Function Analysis"]
        CONT["Contract System"]
    end

    subgraph Utils
        AST["AST Helpers"]
        AHELP["Analysis Helpers"]
    end

    subgraph Testing
        TEST["Integration Tests"]
    end

    %% Relationships
    CLI --> CONF
    GCL --> CONF
    NOGO --> CONF

    CONF --> ANALYZER

    ANALYZER --> INFER
    ANALYZER --> DIAG
    ANALYZER --> ANNOT

    INFER --> ASSERT
    INFER --> ACCUM
    
    ASSERT --> FUNC
    FUNC --> CONT

    ANNOT --> AST
    ASSERT --> AST
    ACCUM --> AST

    ANNOT --> AHELP
    ASSERT --> AHELP
    ACCUM --> AHELP

    TEST -.-> ANALYZER

    %% Click events
    click CLI "https://github.com/uber-go/nilaway/blob/main/cmd/nilaway/main.go"
    click GCL "https://github.com/uber-go/nilaway/blob/main/cmd/gclplugin/gclplugin.go"
    click INFER "https://github.com/uber-go/nilaway/blob/main/inference/engine.go"
    click DIAG "https://github.com/uber-go/nilaway/blob/main/diagnostic/engine.go"
    click ANNOT "https://github.com/uber-go/nilaway/blob/main/annotation/analyzer.go"
    click ASSERT "https://github.com/uber-go/nilaway/blob/main/assertion/analyzer.go"
    click ACCUM "https://github.com/uber-go/nilaway/blob/main/accumulation/analyzer.go"
    click AST "https://github.com/uber-go/nilaway/blob/main/util/asthelper/asthelper.go"
    click AHELP "https://github.com/uber-go/nilaway/blob/main/util/analysishelper/analyzer.go"
    click CONF "https://github.com/uber-go/nilaway/blob/main/config/config.go"
    click ANALYZER "https://github.com/uber-go/nilaway/blob/main/nilaway.go"
    click FUNC "https://github.com/uber-go/nilaway/blob/main/assertion/function/analyzer.go"
    click CONT "https://github.com/uber-go/nilaway/blob/main/assertion/function/functioncontracts/analyzer.go"
    click TEST "https://github.com/uber-go/nilaway/blob/main/tools/cmd/integration-test/main.go"

    %% Styling
    classDef entry fill:#f9f,stroke:#333
    classDef config fill:#ff9,stroke:#333
    classDef core fill:#9ff,stroke:#333
    classDef analysis fill:#f99,stroke:#333
    classDef utils fill:#ddd,stroke:#333
    classDef testing fill:#9f9,stroke:#333

    class CLI,GCL,NOGO entry
    class CONF config
    class ANALYZER,INFER,DIAG core
    class ANNOT,ASSERT,ACCUM,FUNC,CONT analysis
    class AST,AHELP utils
    class TEST testing
```
