# sushant1209/hybrid-homomorphic-encryption-for-privacy-preserving-search architecture

> Architecture diagram of the GitHub repository sushant1209/hybrid-homomorphic-encryption-for-privacy-preserving-search, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-07-15). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sushant1209/hybrid-homomorphic-encryption-for-privacy-preserving-search
- Repository: https://github.com/sushant1209/hybrid-homomorphic-encryption-for-privacy-preserving-search

## Overview

##### Project type and purpose
- This is a command-line research/benchmark tool (not a web app) that generates synthetic encrypted datasets, runs two encrypted keyword-search algorithms (SCIE-Enc baseline vs. Ultra-Optimized Hybrid PHE+SwHE), measures performance, and produces comparison charts.

##### Main architectural components
a. Data Generation Module
- Script: generate_metadata.py
- Outputs: JSON files (metadata_profiles.json, metadata_scie.json, metadata_hybrid.json) in execution01/
b. SCIE-Enc Baseline Algorithm
- Built into ultra_optimized_hybrid.py under “SCIE-Enc” branch
- Reads metadata_scie.json, applies binary vector encryption & simple overlap matching
c. Ultra-Optimized Hybrid PHE+SwHE Algorithm
- Also in ultra_optimized_hybrid.py under “Hybrid” branch
- Sub-modules:
- PHE (Paillier addition)
- SwHE (optimized boolean AND/OR)
- Parallel processing engine (4 threads)
- Caching layer (lookup tables)
- Pre-computed encrypted constants
- Reads metadata_hybrid.json & metadata_profiles.json
- Produces ultra_optimized_results.csv
d. Data Storage / Results Folder
- Directory: execution01/
- Contains raw JSON inputs, CSV results, and generated graph PNGs
e. Visualization Module
- Script: create_graphs.py
- Reads ultra_optimized_results.csv
- Generates execution_time_comparison.png & match_count_comparison.png

##### Relationships and data flows
1. generate_metadata.py → execution01/*.json
2. ultra_optimized_hybrid.py reads JSONs → executes both algorithms in parallel → writes results CSV
3. create_graphs.py reads CSV → writes PNG charts
4. (CI) .github/workflows/run-project.yml automates full run

##### Architectural patterns & design principles
- Modular CLI steps: data-generation → computation → visualization
- Pipeline pattern: clear stepwise flow of data transformations
- Parallel batch processing for performance
- Separation of concerns: algorithms and visualization decoupled
- Caching & pre-computation for optimized hot-path operations

##### Technologies & dependencies
- Python 3.8+
- Homomorphic encryption library (e.g., Python-Paillier)
- numpy, multiprocessing, json, csv
- matplotlib or seaborn for plotting

##### Additional notes for clarity
- CI workflow as an orchestration layer that triggers all scripts in sequence
[Parallel Engine] → [PHE Module]
→ [SwHE Module]

## Diagram (Mermaid)

```mermaid
flowchart TD
    CI["CI Workflow\n.github/workflows/run-project.yml"]:::external
    CI -->|triggers| DataGen

    subgraph "Pipeline"
        direction TB

        DataGen["Data Generation Module\ngenerate_metadata.py"]:::module
        DataGen -->|writes JSON| JSONInputs

        subgraph "Data Storage" 
            direction TB
            JSONInputs["JSON Inputs\nmetadata_profiles.json\nmetadata_scie.json\nmetadata_hybrid.json"]:::storage
            JSONInputs -->|reads| HybridAlgo
            HybridAlgo["Ultra-Optimized CLI\nultra_optimized_hybrid.py"]:::module
            subgraph "Hybrid Sub-components" 
                direction TB
                PHE["PHE (Paillier Addition)"]:::module
                SwHE["SwHE (Boolean AND/OR)"]:::module
                Threads["Parallel Engine\n(4 threads)"]:::module
                Cache["Caching & Pre-computed Constants"]:::module
            end
            HybridAlgo -->|writes results| ResultsOutputs
            ResultsOutputs["Results Outputs\nmetadata_scie_results.json\nmetadata_hybrid_results.json\nultra_optimized_results.csv"]:::storage
            ResultsOutputs -->|reads CSV| Viz

            Viz["Visualization Module\ncreate_graphs.py"]:::module
            Viz -->|writes charts| Charts
            Charts["Charts\nexecution_time_comparison.png\nmatch_count_comparison.png"]:::storage
        end
    end

    subgraph "External Libraries" 
        direction TB
        HEncLib["Homomorphic Encryption Library\n(Python-Paillier, numpy, multiprocessing)"]:::external
        PlotLib["Plotting Library\n(matplotlib, seaborn)"]:::external
    end

    HybridAlgo --> HEncLib
    Viz --> PlotLib

    click DataGen "https://github.com/sushant1209/hybrid-homomorphic-encryption-for-privacy-preserving-search/blob/master/generate_metadata.py"
    click HybridAlgo "https://github.com/sushant1209/hybrid-homomorphic-encryption-for-privacy-preserving-search/blob/master/ultra_optimized_hybrid.py"
    click PHE "https://github.com/sushant1209/hybrid-homomorphic-encryption-for-privacy-preserving-search/blob/master/ultra_optimized_hybrid.py"
    click SwHE "https://github.com/sushant1209/hybrid-homomorphic-encryption-for-privacy-preserving-search/blob/master/ultra_optimized_hybrid.py"
    click Threads "https://github.com/sushant1209/hybrid-homomorphic-encryption-for-privacy-preserving-search/blob/master/ultra_optimized_hybrid.py"
    click Cache "https://github.com/sushant1209/hybrid-homomorphic-encryption-for-privacy-preserving-search/blob/master/ultra_optimized_hybrid.py"
    click JSONInputs "https://github.com/sushant1209/hybrid-homomorphic-encryption-for-privacy-preserving-search/tree/master/execution01/"
    click ResultsOutputs "https://github.com/sushant1209/hybrid-homomorphic-encryption-for-privacy-preserving-search/tree/master/execution01/"
    click Charts "https://github.com/sushant1209/hybrid-homomorphic-encryption-for-privacy-preserving-search/tree/master/execution01/"
    click Viz "https://github.com/sushant1209/hybrid-homomorphic-encryption-for-privacy-preserving-search/blob/master/create_graphs.py"
    click CI "https://github.com/sushant1209/hybrid-homomorphic-encryption-for-privacy-preserving-search/blob/master/.github/workflows/run-project.yml"

    classDef module fill:#D2E5FF,stroke:#333,stroke-width:1px
    classDef storage fill:#E3FCEF,stroke:#333,stroke-width:1px
    classDef external fill:#FFE5CC,stroke:#333,stroke-width:1px
```
