# prajith48/airlock architecture

> Architecture diagram of the GitHub repository prajith48/airlock, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-09). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/prajith48/airlock
- Repository: https://github.com/prajith48/airlock

## Overview

Airlock is a local-first security CLI with three distinct protections: a development-server reverse proxy, an MCP stdio watcher, and an in-memory secrets broker. The principal workflow starts at the CLI, which dispatches to a protection component; the Guard then validates requests before proxying them to the private development server. The README documents the MCP and Secret Gate workflows, but their full implementation was not sampled, so those relationships are cited to the README. The shared logging and error-handling layer is included; no unshown integrations are inferred.

Main entry points: [`src/cli.ts`](https://github.com/prajith48/airlock/blob/main/src/cli.ts) (Airlock CLI), [`src/mcpwatch/watcher.ts`](https://github.com/prajith48/airlock/blob/main/src/mcpwatch/watcher.ts) (MCP Watcher), [`src/guard/runner.ts`](https://github.com/prajith48/airlock/blob/main/src/guard/runner.ts) (Guard Runner), [`src/guard/proxy.ts`](https://github.com/prajith48/airlock/blob/main/src/guard/proxy.ts) (Reverse Proxy)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["CLI"]
  node_cli["Airlock CLI<br/>[cli.ts]"]
end

subgraph group_guard["Dev Server Guard"]
  node_runner["Guard Runner<br/>[runner.ts]"]
  node_validation["Header Validation<br/>[validation.ts]"]
  node_proxy["Reverse Proxy<br/>[proxy.ts]"]
end

subgraph group_mcp["MCP Watch"]
  node_watcher["MCP Watcher<br/>[watcher.ts]"]
end

subgraph group_secrets["Secret Gate"]
  node_broker["Secret Broker<br/>[broker.ts]"]
  node_client["Secret Client<br/>[client.ts]"]
end

subgraph group_shared["Shared Utilities"]
  node_pathcheck["Path Detection<br/>[pathValidation.ts]"]
  node_logger["Structured Logger<br/>[logger.ts]"]
  node_errors["Error Handler<br/>[errorHandler.ts]"]
  node_banner["CLI Output<br/>[banner.ts]"]
end

node_developer(("Developer"))
node_browser(("Browser"))
node_devserver["Dev Server"]
node_agent(("AI Agent"))
node_mcpserver["MCP Server"]
node_app(("Secrets Consumer"))

node_developer -->|"runs commands"| node_cli
node_cli -->|"starts guard"| node_runner
node_runner -->|"validates requests"| node_validation
node_runner -->|"starts proxy"| node_proxy
node_browser -->|"sends requests"| node_proxy
node_proxy -->|"proxies traffic"| node_devserver
node_cli -->|"starts watcher"| node_watcher
node_agent -->|"uses stdio relay"| node_watcher
node_watcher -->|"relays stdio"| node_mcpserver
node_watcher -->|"checks paths"| node_pathcheck
node_cli -->|"loads secrets"| node_broker
node_app -->|"requests secrets"| node_client
node_client -->|"fetches over socket"| node_broker
node_cli -->|"prints status"| node_banner
node_cli -->|"handles errors"| node_errors
node_proxy -->|"reports failures"| node_errors
node_errors -->|"logs events"| node_logger
node_runner -->|"logs events"| node_logger
node_validation -->|"logs warnings"| node_logger
node_watcher -->|"logs alerts"| node_logger

click node_cli "https://github.com/prajith48/airlock/blob/main/src/cli.ts"
click node_runner "https://github.com/prajith48/airlock/blob/main/src/guard/runner.ts"
click node_validation "https://github.com/prajith48/airlock/blob/main/src/guard/validation.ts"
click node_proxy "https://github.com/prajith48/airlock/blob/main/src/guard/proxy.ts"
click node_watcher "https://github.com/prajith48/airlock/blob/main/src/mcpwatch/watcher.ts"
click node_pathcheck "https://github.com/prajith48/airlock/blob/main/src/utils/pathValidation.ts"
click node_broker "https://github.com/prajith48/airlock/blob/main/src/secretgate/broker.ts"
click node_client "https://github.com/prajith48/airlock/blob/main/src/secretgate/client.ts"
click node_logger "https://github.com/prajith48/airlock/blob/main/src/utils/logger.ts"
click node_errors "https://github.com/prajith48/airlock/blob/main/src/utils/errorHandler.ts"
click node_banner "https://github.com/prajith48/airlock/blob/main/src/utils/banner.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_cli,node_browser toneBlue
class node_runner,node_validation,node_proxy toneAmber
class node_watcher,node_devserver,node_mcpserver toneMint
class node_broker,node_client toneRose
class node_pathcheck,node_logger,node_errors,node_banner,node_developer,node_agent,node_app toneIndigo
```

## Components

### CLI

- [Airlock CLI](https://github.com/prajith48/airlock/blob/main/src/cli.ts): `src/cli.ts`

### Dev Server Guard

- [Guard Runner](https://github.com/prajith48/airlock/blob/main/src/guard/runner.ts): `src/guard/runner.ts`
- [Header Validation](https://github.com/prajith48/airlock/blob/main/src/guard/validation.ts): `src/guard/validation.ts`
- [Reverse Proxy](https://github.com/prajith48/airlock/blob/main/src/guard/proxy.ts): `src/guard/proxy.ts`

### MCP Watch

- [MCP Watcher](https://github.com/prajith48/airlock/blob/main/src/mcpwatch/watcher.ts): `src/mcpwatch/watcher.ts`

### Secret Gate

- [Secret Broker](https://github.com/prajith48/airlock/blob/main/src/secretgate/broker.ts): `src/secretgate/broker.ts`
- [Secret Client](https://github.com/prajith48/airlock/blob/main/src/secretgate/client.ts): `src/secretgate/client.ts`

### Shared Utilities

- [Path Detection](https://github.com/prajith48/airlock/blob/main/src/utils/pathValidation.ts): `src/utils/pathValidation.ts`
- [Structured Logger](https://github.com/prajith48/airlock/blob/main/src/utils/logger.ts): `src/utils/logger.ts`
- [Error Handler](https://github.com/prajith48/airlock/blob/main/src/utils/errorHandler.ts): `src/utils/errorHandler.ts`
- [CLI Output](https://github.com/prajith48/airlock/blob/main/src/utils/banner.ts): `src/utils/banner.ts`

### Other components

- **Developer**
- **Browser**
- **Dev Server**
- **AI Agent**
- **MCP Server**
- **Secrets Consumer**

## Connections

- Developer → Airlock CLI: runs commands (evidence: `README.md`)
- Airlock CLI → Guard Runner: starts guard (evidence: `src/cli.ts`)
- Guard Runner → Header Validation: validates requests (evidence: `src/guard/runner.ts`)
- Guard Runner → Reverse Proxy: starts proxy (evidence: `src/guard/runner.ts`)
- Browser → Reverse Proxy: sends requests (evidence: `README.md`)
- Reverse Proxy → Dev Server: proxies traffic (evidence: `README.md`)
- Airlock CLI → MCP Watcher: starts watcher (evidence: `src/cli.ts`)
- AI Agent → MCP Watcher: uses stdio relay (evidence: `README.md`)
- MCP Watcher → MCP Server: relays stdio (evidence: `README.md`)
- MCP Watcher → Path Detection: checks paths (evidence: `src/mcpwatch/watcher.ts`)
- Airlock CLI → Secret Broker: loads secrets (evidence: `src/cli.ts`)
- Secrets Consumer → Secret Client: requests secrets (evidence: `README.md`)
- Secret Client → Secret Broker: fetches over socket (evidence: `README.md`)
- Airlock CLI → CLI Output: prints status (evidence: `src/cli.ts`)
- Airlock CLI → Error Handler: handles errors (evidence: `src/cli.ts`)
- Reverse Proxy → Error Handler: reports failures (evidence: `src/guard/proxy.ts`)
- Error Handler → Structured Logger: logs events (evidence: `src/utils/errorHandler.ts`)
- Guard Runner → Structured Logger: logs events (evidence: `src/guard/runner.ts`)
- Header Validation → Structured Logger: logs warnings (evidence: `src/guard/validation.ts`)
- MCP Watcher → Structured Logger: logs alerts (evidence: `src/mcpwatch/watcher.ts`)
