# hey-granth/api-detection-tool architecture

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

- Interactive diagram: https://gitdiagram.com/hey-granth/api-detection-tool
- Repository: https://github.com/hey-granth/api-detection-tool

## Overview

##### Main Components

a) Core Detection Engine
- Represented by the src/core.py component
- Should be shown as the primary processing unit

b) Git Integration Layer
- This as an input layer
- Represents the git_hooks/pre_commit.py component
- Shows interaction with Git's commit process

c) Utility Services
- As a supporting layer
- Represents src/utils.py
- Shows helper functions and shared services

##### Flow and Interactions

**Git Repository → Git Hook → Detection Engine → Results/Actions**

##### Component Details

a) External Systems (Rectangles):
- Git Repository
- Developer's Working Directory

b) Core Components (Hexagons):
- Detection Engine
- Pattern Matching System

c) Integration Points (Diamonds):
- Pre-commit Hook
- CLI Interface

##### Specific Implementation Details

Technical elements:
- Pattern matching system
- File filtering mechanism
- Configuration management
- Hook integration points

##### Additional Elements

Annotations for:
- Supported file types
- Detection patterns
- Configuration points
- Security boundaries

##### Security Focus
- Clear boundaries between trusted and untrusted data
- Validation points

##### Integration Points
- Git hook integration
- CLI interface
- Configuration management

##### Processing Flow
- File selection
- Pattern matching
- Result reporting

##### System Boundaries
- Local system components
- Git repository interaction
- Developer interface points

Remember to maintain a balance between showing the security-critical paths and the general workflow, as this is primarily a security tool integrated into the development process.

This approach will create a comprehensive yet clear representation of the API Key Detection Tool's architecture while emphasizing its security-focused nature and Git integration capabilities.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles and classes
    classDef core fill:#3498db,stroke:#2980b9,color:white
    classDef git fill:#2ecc71,stroke:#27ae60,color:white
    classDef util fill:#f1c40f,stroke:#f39c12,color:black
    classDef security fill:#e74c3c,stroke:#c0392b,color:white
    classDef config fill:#95a5a6,stroke:#7f8c8d,color:white
    classDef test fill:#9b59b6,stroke:#8e44ad,color:white

    %% Main Components
    GitRepo["Git Repository"]:::git
    WorkDir["Developer's Working Directory"]:::git
    DetectionEngine["Core Detection Engine"]:::core
    GitHook["Pre-commit Hook"]:::git
    CLI["CLI Interface"]:::util
    Utils["Utility Services"]:::util
    Config["Configuration Management"]:::config

    %% Testing Components
    CoreTests["Core Detection Tests"]:::test
    UtilTests["Utility Services Tests"]:::test

    %% Security Components
    PatternMatch["Pattern Matching System"]:::security
    FileFilter["File Filtering Mechanism"]:::security
    ValidationPoint["Security Validation"]:::security

    %% Flow Connections
    GitRepo --> WorkDir
    WorkDir --> GitHook
    GitHook --> DetectionEngine
    DetectionEngine --> PatternMatch
    DetectionEngine --> FileFilter
    PatternMatch --> ValidationPoint
    FileFilter --> ValidationPoint
    Utils --> DetectionEngine
    Utils --> GitHook
    Config --> DetectionEngine
    CLI --> DetectionEngine
    CoreTests -.-> DetectionEngine
    UtilTests -.-> Utils

    %% Click Events
    click DetectionEngine "https://github.com/hey-granth/api-detection-tool/blob/main/src/core.py"
    click GitHook "https://github.com/hey-granth/api-detection-tool/blob/main/git_hooks/pre_commit.py"
    click Utils "https://github.com/hey-granth/api-detection-tool/blob/main/src/utils.py"
    click CLI "https://github.com/hey-granth/api-detection-tool/blob/main/src/__main__.py"
    click CoreTests "https://github.com/hey-granth/api-detection-tool/blob/main/tests/test_core.py"
    click UtilTests "https://github.com/hey-granth/api-detection-tool/blob/main/tests/test_utils.py"
    click Config "https://github.com/hey-granth/api-detection-tool/blob/main/pyproject.toml"

    %% Legend
    subgraph Legend
        CoreComp["Core Components"]:::core
        GitComp["Git Integration"]:::git
        UtilComp["Utility Components"]:::util
        SecComp["Security Components"]:::security
        TestComp["Test Components"]:::test
        ConfigComp["Configuration"]:::config
    end
```
