# andreswang0703/bloomfilter architecture

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

- Interactive diagram: https://gitdiagram.com/andreswang0703/bloomfilter
- Repository: https://github.com/andreswang0703/bloomfilter

## Overview

##### Main components
- Command Entry Point: The "cmd" directory containing main.go. This is where execution begins.
- Core Bloom Filter Package: In the pkg/bloomfilter directory. It contains the key logic for creating and managing Bloom Filters (bit_array.go, bloom_filter.go, factory.go, option.go).
- Hash Utilities: The pkg/hash directory, which provides composite hashing functions used by the bloom filter.
- Parser Module: The pkg/parser directory, which likely handles input parsing (for example, reading or converting URL lists or other input data).
- Data Input: The "data" directory with urlList.txt, which serves as an input resource for demonstration or testing purposes.

##### Relationships and Interactions
- The main.go (cmd/main.go) acts as the orchestrator. It initializes the Bloom Filter using the factory pattern (likely defined in pkg/bloomfilter/factory.go) and interacts with various components.
- The Bloom Filter itself depends on:
- The bit array logic (pkg/bloomfilter/bit_array.go) to manage bits efficiently.
- The configuration and option settings (pkg/bloomfilter/option.go) to tune the filter.
- The hash utilities (pkg/hash) that provide underlying hash functions required for setting/checking bits.
- The Parser (pkg/parser/parser.go) is used to ingest and parse input data (e.g., urlList.txt from the data directory), feeding the Bloom Filter with items.
- The dependencies are relatively lightweight, each module playing a clear, interlocking role.

##### Architectural Patterns
- Modular design with separation of concerns: Each package in the "pkg" directory handles a single responsibility (Bloom Filter logic, hashing, parsing).
- Factory Pattern: The use of a factory (in pkg/bloomfilter/factory.go) suggests that object creation (likely of Bloom Filter instances) is abstracted for flexibility.
- Utility-driven library design: This is more of a tool or library than a full application, with clear, reusable components.

## Diagram (Mermaid)

```mermaid
flowchart TD
    A["Command Entry Point"]:::core
    GM["Go Module (go.mod)"]:::build
    A -->|"instantiates"| BF1
    A -->|"build_dependency"| GM

    subgraph "Core Bloom Filter Module"
        BF1["Bloom Filter Logic"]:::core
        BF2["Bit Array Logic"]:::core
        BF3["Factory (Creation)"]:::core
        BF4["Option Settings"]:::core
    end

    BF1 -->|"uses"| BF2
    BF1 -->|"factory_instantiates"| BF3
    BF1 -->|"configured_by"| BF4

    subgraph "Hash Utilities"
        HU1["Composite Hash"]:::utility
        HU2["Hash Functions"]:::utility
    end

    BF1 -->|"calls_hash"| HU1
    BF1 -->|"calls_hash"| HU2

    P["Parser Module"]:::utility
    D["Data Input Resource"]:::external
    P -->|"reads_input"| D
    P -->|"populates"| BF1

    classDef core fill:#ADD8E6,stroke:#0000FF,stroke-width:2px;
    classDef utility fill:#90EE90,stroke:#008000,stroke-width:2px;
    classDef external fill:#D3D3D3,stroke:#808080,stroke-width:2px;
    classDef build fill:#FFD700,stroke:#DAA520,stroke-width:2px;

    click A "https://github.com/andreswang0703/bloomfilter/blob/main/cmd/main.go"
    click BF1 "https://github.com/andreswang0703/bloomfilter/blob/main/pkg/bloomfilter/bloom_filter.go"
    click BF2 "https://github.com/andreswang0703/bloomfilter/blob/main/pkg/bloomfilter/bit_array.go"
    click BF3 "https://github.com/andreswang0703/bloomfilter/blob/main/pkg/bloomfilter/factory.go"
    click BF4 "https://github.com/andreswang0703/bloomfilter/blob/main/pkg/bloomfilter/option.go"
    click HU1 "https://github.com/andreswang0703/bloomfilter/blob/main/pkg/hash/composit_hash.go"
    click HU2 "https://github.com/andreswang0703/bloomfilter/blob/main/pkg/hash/hash.go"
    click P "https://github.com/andreswang0703/bloomfilter/blob/main/pkg/parser/parser.go"
    click D "https://github.com/andreswang0703/bloomfilter/blob/main/data/urlList.txt"
    click GM "https://github.com/andreswang0703/bloomfilter/blob/main/go.mod"
```
