# dstotijn/hetty architecture

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

- Interactive diagram: https://gitdiagram.com/dstotijn/hetty
- Repository: https://github.com/dstotijn/hetty

## Overview

##### Project type and purpose
- Hetty is a full-stack HTTP toolkit for security research. It runs as a single CLI-launched process that:
- Acts as a man-in-the-middle (MITM) HTTP proxy.
- Hosts a GraphQL API.
- Serves a Next.js-based web admin interface.
- Users point their browser or tools at the proxy, then use the web UI to inspect, edit, replay, and search HTTP traffic.

##### File structure
- Top-level “cmd/hetty”: Go code for CLI entrypoint, proxy instantiation, server wiring.
- “pkg/…”: Core Go libraries for proxy (pkg/proxy), database (pkg/db/bolt), filtering (pkg/filter), request logging (pkg/reqlog), scope and sender logic, Chrome helper integration.
- “pkg/api” + “gqlgen.yml”: GraphQL schema, generated types, resolvers back the web UI.
- “admin/”: Next.js React app (TypeScript) powered by Apollo-GraphQL, with features under “features/…”, shared components under “lib/…”, and pages under “pages/…”.
- Config/build files: Dockerfile, Makefile, gqlgen.yml, Go module files, workflows for CI.

##### README insights
- Confirms triad of proxy / GraphQL / web UI.
- Notes embedded Bolt DB for per-project storage.
- Describes key features: intercept, scope, sender, HTTP request logs, project isolation.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% External Entities
    Browser["External HTTP Client"]:::network
    Target["Target Web Servers"]:::network

    %% Backend Process
    subgraph "Backend (Go Process)" 
        direction TB
        CLI["CLI Process\n(hetty binary)"]:::process
        Proxy["MITM Proxy Module"]:::process
        API["GraphQL API Server"]:::api
        DB["Bolt DB Storage"]:::storage
        Helper["Chrome Launcher Helper"]:::process
    end

    %% Frontend
    subgraph "Frontend (Admin UI)"
        direction TB
        UI["Next.js Admin UI"]:::ui
        Apollo["Apollo GraphQL Client"]:::ui
    end

    %% Data Flows
    Browser -->|"HTTP/HTTPS"| Proxy
    Proxy -->|"forwards HTTP"| Target
    Proxy -->|"writes logs"| DB
    Proxy -->|"emits events"| API
    API -->|"reads/writes"| DB
    UI -->|"GraphQL queries/mutations"| API
    API -->|"GraphQL responses"| UI
    CLI -->|"launches"| Proxy
    CLI -->|"configures certs/DB"| DB
    CLI -->|"flags for API"| API
    CLI -->|"invokes"| Helper
    Apollo -->|"integrated in"| UI

    %% Click Events
    click CLI "https://github.com/dstotijn/hetty/blob/main/cmd/hetty/main.go"
    click Proxy "https://github.com/dstotijn/hetty/blob/main/pkg/proxy/proxy.go"
    click API "https://github.com/dstotijn/hetty/blob/main/pkg/api/http.go"
    click DB "https://github.com/dstotijn/hetty/blob/main/pkg/db/bolt/bolt.go"
    click UI "https://github.com/dstotijn/hetty/blob/main/admin/next.config.js"
    click Apollo "https://github.com/dstotijn/hetty/blob/main/admin/src/lib/useApollo.ts"
    click Helper "https://github.com/dstotijn/hetty/blob/main/pkg/chrome/chrome.go"

    %% Styles
    classDef network fill:#ccffcc,stroke:#339933,color:#003300;
    classDef storage fill:#cce5ff,stroke:#3366cc,color:#003399;
    classDef api fill:#e5ccff,stroke:#9933cc,color:#330066;
    classDef ui fill:#ffe5cc,stroke:#cc6633,color:#663300;
    classDef process fill:#f2f2f2,stroke:#999999,color:#333333;
```
