How hoophq/hoop works
1. This repository is a monorepo for a security gateway platform centered on the gateway service. The architecture is split into control plane, real-time proxy/data plane, edge helpers (agent, client), and two UI generations (webapp and webapp_v2).
2. gateway is the core server. It exposes the admin/API surface under gateway/api, owns auth, users, orgs, connections, sessions, runbooks, guardrails, AI features, audit, feature flags, plugins, and integrations. It is the main orchestration point for policy and session lifecycle.
3. The data plane lives in gateway/transport, gateway/broker, gateway/proxyproto, and protocol-specific packages like gateway/rdp and gateway/session. This layer accepts live traffic, applies interceptors, enforces guardrails/masking/review workflows, and forwards approved traffic to the target system while recording activity.
4. Protocol handling is a first-class boundary. The repo contains explicit adapters/parsers for PostgreSQL, MySQL, MSSQL, MongoDB, SSH, SSM, Kubernetes, HTTP/gRPC, and RDP. Shared low-level parsing/redaction primitives also exist in common/*types and _libhoop, which keeps protocol inspection separate from business APIs.
5. The agent service is the remote sidecar/helper that runs near infrastructure and connects back to the gateway. It handles backend-specific execution and provisioning tasks (dbprovisioner, pgmanager, bareexec, runbook hooks, SSH/SSM, EKS), and uses shared protobufs in common/proto for internal communication.
6. The client module is the operator-facing CLI/daemon. It handles login, session start/connect, local proxying, installs/upgrades, and command execution. It is the user entry point that tunnels the operator’s traffic into the gateway rather than connecting directly to resources.
7. Session capture and audit are built into the backend. gateway/session stores append-only event logs/WALs, gateway/audit and gateway/events derive searchable audit records, and gateway/models plus rootfs/app/migrations define the durable PostgreSQL schema. This is what makes replay, compliance logging, and session search possible.
8. Policy enforcement is layered into the gateway transport. Guardrails, access-request rules, data masking, reviews/approvals, and webhooks/plugins are all implemented as pipeline steps around the live session stream. Slack/Teams/Jira integrations are used for human approval and workflow notifications.
9. Identity and access are a major boundary. gateway/idp, gateway/api/login/*, gateway/externaljwt, gateway/machineidentity, and gateway/api/mcpauth support local auth plus OIDC/SAML/SPIFFE-style and machine identities. The gateway uses these identities to attach permissions, groups, and ABAC-like rules to both humans and AI agents.
10. There are two frontend stacks. webapp is the older ClojureScript SPA organized around events/subscriptions, while webapp_v2 is a newer React/Vite app with page-based features and service modules. Both talk to the gateway’s HTTP API for administration, sessions, resource setup, reviews, and settings.
11. agentrs is a Rust companion/runtime focused on proxying and session handling, including websocket, TLS, and RDP-specific logic. It appears to support performance-sensitive or alternate client/agent paths rather than replacing the main Go gateway.
12. Deployment is packaged for multiple environments: Docker/Docker Compose, Helm charts for gateway and agent, and AWS templates. rootfs and the various Dockerfiles assemble the runtime image, while the top-level scripts automate local dev, release, and migration checks.
Main entry points: api/server.go Gateway API · transport/server.go Transport · session.go Services · rdp.go RDP stack
Components 22
Gateway core
Control plane, APIs, persistence, and policy services.
- Gateway API · HTTP admin/API entrypoint for users, resources, sessions, reviews, integrations, and settings.
gateway/api/server.go - Identity · Local, OIDC, SAML, machine identity, and external JWT auth boundaries.
gateway/idp/core.go - Models · Durable PostgreSQL-backed domain models and migrations for the control plane.
gateway/models - Services · Business logic for access requests, guardrails, data masking, sessions, and feature flags.
gateway/services/session.go - Events · Event catalog, validation, derivation, publication, and routing into workers.
gateway/events/publish.go - Audit · Redaction and audit record generation for searchable session and security logs.
gateway/audit/audit.go - Session WAL · Session event logs and WAL formats used for replay and capture.
gateway/session/wal/wal.go
Data plane
Live session transport, protocol handling, and policy enforcement.
- Transport · Session transport server, interceptors, stream clients, system actions, and plugin pipelines.
gateway/transport/server.go - Broker · Protocol manager and live session broker that coordinate protocol-specific handlers.
gateway/broker/protocol_manager.go - Proxy adapters · Protocol-specific proxy adapters for SSH, Postgres, SSM, HTTP, gRPC, and TLS termination.
gateway/proxyproto/sshproxy/sshproxy.go - RDP stack · RDP parsing, recording, OCR, and analysis components.
gateway/rdp/rdp.go - Policy plugins · Access control, audit, DLP, review, Slack, and webhook steps around live traffic.
gateway/transport/plugins/review/review.go
Edge helpers
Operator client and remote agent runtimes.
- Agent · Remote helper that provisions databases, runs backend-specific tasks, and connects back to gateway.
agent/main.go - Client CLI · CLI/daemon used for login, connect, session start, proxying, installs, and upgrades.
client/cmd/root.go - Agent RS · Rust companion runtime for websocket, TLS, proxy, and RDP-sensitive paths.
agentrs/src/main.rs
User interfaces
Two generations of admin and session UIs.
Shared libs
Common code, protocol types, and low-level primitives.
- Proto common · Shared protobuf contracts for agent, client, gateway, transport, and system RPCs.
common/proto/transport.proto - Common types · Protocol parsers, redactors, logging, backoff, client config, and utility libraries.
common/pgtypes/packet.go - Libhoop · Shared low-level proxy and redaction primitives used by protocol inspection code.
_libhoop/libhoop.go
Packaging
Container, Helm, and migration/runtime assembly.
- Runtime image · Application image assembly, migrations, and bundled helper scripts for deployment/runtime.
rootfs/app/migrations/000001_init.up.sql - Deployments · Docker, Compose, Helm, and AWS packaging for gateway and agent environments.
deploy/helm-chart/chart/gateway/Chart.yaml
Connections 26
- Gateway API → Identity: auth · Delegates login and identity boundaries to local, OIDC, SAML, and machine identity flows.
- Gateway API → Services: orchestrates · API handlers call domain services for access requests, guardrails, sessions, and configuration.
- Gateway API → Models: persists · Reads and writes durable domain state through the PostgreSQL schema.
- Gateway API → Events: publishes · Emits routed events for integrations, audit, and asynchronous workflows.
- Services → Models: uses · Service layer persists and queries core business entities.
- Services → Audit: records · Service actions contribute to audit and compliance records.
- Session WAL → Audit: feeds · Session WAL and event logs are transformed into audit/searchable records.
- Transport → Broker: dispatches · Transport hands live streams to the broker for protocol coordination.
- Transport → Policy plugins: enforces · Live traffic passes through access control, DLP, review, Slack, and webhook steps.
- Transport → Session WAL: captures · Transport writes session activity into append-only event logs.
- Transport → Proxy adapters: adapts · Uses protocol-specific proxy adapters for SSH, Postgres, SSM, HTTP, gRPC, and TLS termination.
- Transport → RDP stack: inspects · Routes RDP traffic into parser, recorder, OCR, and analysis components.
- Broker → Proxy adapters: routes · Broker selects protocol handlers and forwards approved traffic.
- RDP stack → Audit: analyzes · RDP analysis contributes detections and session artifacts to compliance and review.
- Agent → Proto common: rpc · Communicates with gateway using shared protobuf contracts.
- Client CLI → Gateway API: admin api · CLI and daemon use the HTTP/API surface for login, sessions, resources, and administration.
- Client CLI → Transport: tunnels · Operator traffic is tunneled into the live gateway transport path.
- Agent RS → Proto common: ws/rpc · Rust runtime shares message contracts and session semantics with the rest of the platform.
- Webapp → Gateway API: admin ui · Legacy SPA talks to the gateway HTTP API for management and session views.
- Webapp V2 → Gateway API: admin ui · React/Vite UI consumes the same gateway API for modern administration flows.
- Gateway API → Runtime image: deployed with · Gateway runtime and schema migrations are packaged into the app image.
- Gateway API → Deployments: shipped via · Gateway is deployed through Docker, Helm, and cloud templates.
- Agent → Deployments: shipped via · Agent runtime is packaged for container and Helm-based deployment.
- Common types → Libhoop: builds on · Protocol and redaction helpers lean on low-level shared primitives.
- Proxy adapters → Common types: parses · Protocol adapters rely on shared packet/type definitions.
- RDP stack → Libhoop: reuses · RDP inspection shares low-level redaction and proxy primitives.