# github/codeql-action architecture

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

- Interactive diagram: https://gitdiagram.com/github/codeql-action
- Repository: https://github.com/github/codeql-action

## Overview

##### Main Components

a. Core Action Components:
- Init Action
- Action
- Upload SARIF Action
- Autobuild Action
- Resolve Environment Action
- Start Proxy Action

b. Supporting Systems:
- CodeQL CLI Integration
- GitHub API Integration
- SARIF Processing System
- Build System Integration
- Language-specific Analysis Engines

**┌─────────────────────────────────────────────────────────┐**
- GitHub Actions Layer                    │
- ┤
- CodeQL Action Core                     │
- ┬───────────────┬────────────────────────┤
- Init System  │ Analysis Core │    Upload System       │
- ┴───────────────┴────────────────────────┤
- Supporting Services                      │
- ┘

##### Detailed Component Breakdown

a. Init Action:
- CodeQL setup
- Environment configuration
- Language detection
- Build mode selection

b. Action:
- Database finalization
- Query execution
- Results processing
- SARIF generation

c. Upload System:
- SARIF validation
- GitHub API integration
- Results reporting

##### Integration Points

Clearly mark:
- GitHub API endpoints
- CodeQL CLI interaction points
- Source code access points
- Results storage and retrieval

##### Workflow Direction

**Init → Build Configuration → Analysis → Results Processing → Upload**

##### Additional Elements

- Version compatibility matrix
- Security permission requirements
- Enterprise server support indicators
- Language support indicators

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph GitHub_Actions
        Init["Init Action"]:::core
        Analyze["Analyze Action"]:::core
        Upload["Upload SARIF Action"]:::core
        Autobuild["Autobuild Action"]:::core
        ResolveEnv["Resolve Environment Action"]:::core
        StartProxy["Start Proxy Action"]:::core
    end

    subgraph Core_Processing
        CodeQLCLI["CodeQL CLI Integration"]:::processing
        SARIF["SARIF Processing"]:::processing
        LangAnalysis["Language Analysis System"]:::processing
        BuildSystem["Build System Integration"]:::processing
        Config["Configuration System"]:::processing
    end

    subgraph External_Systems
        GitHubAPI["GitHub API"]:::external
        SourceCode["Source Code Repository"]:::external
        ResultsStorage["Results Storage"]:::external
    end

    %% Relationships
    Init --> CodeQLCLI
    Init --> LangAnalysis
    Init --> Config
    
    Analyze --> CodeQLCLI
    Analyze --> SARIF
    Analyze --> BuildSystem
    
    Upload --> GitHubAPI
    Upload --> SARIF
    Upload --> ResultsStorage
    
    Autobuild --> BuildSystem
    Autobuild --> LangAnalysis
    
    ResolveEnv --> Config
    StartProxy --> GitHubAPI

    CodeQLCLI --> SourceCode
    SARIF --> ResultsStorage
    
    %% Click Events
    click Init "https://github.com/github/codeql-action/blob/main/init/action.yml"
    click Analyze "https://github.com/github/codeql-action/blob/main/analyze/action.yml"
    click Upload "https://github.com/github/codeql-action/blob/main/upload-sarif/action.yml"
    click Autobuild "https://github.com/github/codeql-action/blob/main/autobuild/action.yml"
    click ResolveEnv "https://github.com/github/codeql-action/blob/main/resolve-environment/action.yml"
    click StartProxy "https://github.com/github/codeql-action/blob/main/start-proxy/action.yml"
    click CodeQLCLI "https://github.com/github/codeql-action/blob/main/lib/codeql.js"
    click SARIF "https://github.com/github/codeql-action/blob/main/src/sarif-schema-2.1.0.json"
    click LangAnalysis "https://github.com/github/codeql-action/blob/main/lib/languages.js"
    click BuildSystem "https://github.com/github/codeql-action/tree/main/actions-extractor/tools"
    click Config "https://github.com/github/codeql-action/blob/main/lib/config-utils.js"

    %% Styling
    classDef core fill:#2374e1,stroke:#164b91,color:#fff
    classDef processing fill:#ffd700,stroke:#b8860b,color:#000
    classDef external fill:#98ff98,stroke:#228b22,color:#000
    
    %% Legend
    subgraph Legend
        L1["Core Actions"]:::core
        L2["Processing Systems"]:::processing
        L3["External Systems"]:::external
    end
```
