# zama-ai/httpz-solidity architecture

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

- Interactive diagram: https://gitdiagram.com/zama-ai/httpz-solidity
- Repository: https://github.com/zama-ai/httpz-solidity

## Overview

##### Main Architectural Components and Their Roles
- Smart Contract / Blockchain Layer: Represent the underlying confidential smart contracts (the “HTTPZ” logic) that integrate FHE directly into Solidity contracts. This is the core of the project.
- Code Generation Module: Based on the “codegen” folder, this component generates operator overloads, templates, and tests to support FHE operations in smart contracts. It automates the creation of boilerplate code to support encrypted integer operations.
- Deployment & Task Scripts: The “tasks” directory (with files like taskDeploy.ts and getEthereumAddress.ts) encapsulates scripts to deploy and interact with contracts. This part ensures that the smart contract functionality integrates with the development workflow.
- Testing & Validation Module: The “test” directory (with various tests such as blind auctions, encrypted ERC20 tests, reencryption tests, etc.) along with the “ci/tests” folder indicate a comprehensive testing strategy. This module tests encryption, decryption, and overall smart contract logic.
- Continuous Integration/Continuous Deployment (CI/CD) Environment: Using GitHub Actions (see workflows in .github/workflows) and the “ci” directory (including Dockerfile, docker-compose.yml, and preparation scripts), this component automates linting, testing, building, and publishing.
- Configuration & Developer Tools: Global configuration files (e.g., tsconfig.json, package.json, ESLint, Prettier, Hardhat config), along with environment and deployment settings, allow developers to configure and run the system reliably.

##### Interactions and Data Flows
- The Developer/Build Phase: Developers use environment configurations and tools (as defined in package.json, Hardhat, and tasks scripts) to generate code (via the codegen module) and compile/deploy the smart contracts.
- Testing / CI Flow: After code generation and deployment tasks, the testing module runs unit and integration tests to validate smart contract behavior (including FHE operations, reencryption, etc.). CI/CD pipelines are activated via GitHub Actions and Docker to ensure consistency.
- Deployment/Execution: Once deployed, the smart contracts operate on the Ethereum network (or a test network), ensuring that encrypted transactions and state updates occur. External FHE libraries or service providers (from Zama’s ecosystem) might be integrated at this level.
- Monitoring & Updating: The CI/CD infrastructure (including workflows that check for dependency updates, lint issues, etc.) keeps the software quality in check.

##### Relevant Technologies and Patterns
- Technologies: TypeScript, Node.js (for tasks, codegen, tests), Solidity (for smart contracts), Hardhat (for development and deployment), Docker, GitHub Actions, and standard configuration tools (ESLint, Prettier).
- Architectural Patterns: Modular separation of concerns (different directories for code generation, tasks, tests, and documentation), layered architecture (developer tools and build systems on top of the blockchain layer), and a CI/CD pipeline ensuring continuous integration and testing.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Configuration & Developer Tools Subgraph
    subgraph "Configuration & Developer Tools"
        pkg["package.json"]:::config
        ts["tsconfig.json"]:::config
        eslint[".eslintrc.yml"]:::config
        prettier[".prettierrc.json"]:::config
    end

    %% Code Generation Module Subgraph
    subgraph "Code Generation Module"
        codegen["Code Generation (codegen)"]:::codegen
    end

    %% Deployment & Task Scripts Subgraph
    subgraph "Deployment & Task Scripts"
        tasks["Deployment Scripts (tasks)"]:::deploy
    end

    %% Testing & Validation Module Subgraph
    subgraph "Testing & Validation Module"
        tests["Testing Suite (test)"]:::testing
        ci_tests["CI Testing (ci/tests)"]:::testing
    end

    %% CI/CD Environment Subgraph
    subgraph "CI/CD Environment"
        gha["GitHub Actions (.github/workflows)"]:::ci
        ci_env["CI Scripts (ci)"]:::ci
    end

    %% Smart Contract / Blockchain Layer Subgraph
    subgraph "Smart Contract/Blockchain Layer"
        contract["Smart Contracts (HTTPZ & FHE)"]:::contract
        docs["Smart Contract Docs (docs/smart_contracts/)"]:::doc
        hardhat["Hardhat Config (hardhat.config.ts)"]:::contract
    end

    %% Interactions and Data Flows
    pkg -->|"informs"| codegen
    pkg -->|"drives"| tasks
    pkg -->|"configures"| hardhat

    codegen -->|"generates"| contract

    tasks -->|"deploys"| contract
    tasks -->|"triggers"| tests

    gha -->|"automates"| tasks
    gha -->|"runs"| tests

    tests -->|"validates"| contract
    ci_tests -->|"validates"| contract

    %% Styles
    classDef config fill:#a2d5f2,stroke:#333,stroke-width:2px;
    classDef codegen fill:#a8e6cf,stroke:#333,stroke-width:2px;
    classDef deploy fill:#ffeb99,stroke:#333,stroke-width:2px;
    classDef testing fill:#ffb3ba,stroke:#333,stroke-width:2px;
    classDef ci fill:#ffd1dc,stroke:#333,stroke-width:2px;
    classDef contract fill:#d3d3d3,stroke:#333,stroke-width:2px;
    classDef doc fill:#c9c9ff,stroke:#333,stroke-width:2px;

    %% Click Events
    click pkg "https://github.com/zama-ai/httpz-solidity/blob/main/package.json"
    click ts "https://github.com/zama-ai/httpz-solidity/blob/main/tsconfig.json"
    click eslint "https://github.com/zama-ai/httpz-solidity/blob/main/.eslintrc.yml"
    click prettier "https://github.com/zama-ai/httpz-solidity/blob/main/.prettierrc.json"
    click codegen "https://github.com/zama-ai/httpz-solidity/tree/main/codegen"
    click tasks "https://github.com/zama-ai/httpz-solidity/tree/main/tasks"
    click tests "https://github.com/zama-ai/httpz-solidity/tree/main/test"
    click ci_tests "https://github.com/zama-ai/httpz-solidity/tree/main/ci/tests"
    click gha "https://github.com/zama-ai/httpz-solidity/tree/main/.github/workflows"
    click ci_env "https://github.com/zama-ai/httpz-solidity/tree/main/ci"
    click docs "https://github.com/zama-ai/httpz-solidity/tree/main/docs/smart_contracts/"
    click hardhat "https://github.com/zama-ai/httpz-solidity/blob/main/hardhat.config.ts"
```
