System Architecture
The complete AgentShield system. Processes, libraries, data stores, how they communicate, and why the boundaries are drawn where they are.
AgentShield is one repository that builds five long-running processes and three libraries. The split follows a single rule from ADR 0001: the enforcement path and the management path change for different reasons and must fail independently.
Components
| Component | Path | Kind | Default address |
|---|---|---|---|
| Runtime gateway | runtime/gateway/cmd/gateway | Go process | 127.0.0.1:8081 |
| Event relay | runtime/gateway/cmd/event-relay | Go process | 127.0.0.1:8083 |
| Control plane | apps/control-plane | NestJS process | 127.0.0.1:8080 |
| Dashboard | apps/dashboard | Next.js process | 127.0.0.1:3000 |
| Intelligence engine | apps/intelligence-engine | Python process | 127.0.0.1:8082 |
| Policy engine | runtime/policy-engine | Go library, linked into the gateway | — |
| Identity | runtime/identity | Go library, linked into the gateway | — |
| SDKs and integrations | sdk/, integrations/ | Libraries in the agent process | — |
| Data store | Role |
|---|---|
| PostgreSQL 16 | Transactional source of truth: identities, policies, decisions, executions, events, audit chain |
| Redis 7 | Nonce reservations, budget counters, circuit state |
| NATS JetStream | Stream of committed security events |
| MinIO (S3 API) | Evidence bundles in a private bucket |
Communication
| From | To | Protocol | Authentication |
|---|---|---|---|
| SDK | Gateway | HTTP JSON | Ed25519 request signature |
| Gateway | PostgreSQL, Redis | Native | Connection credentials |
| Gateway | Intelligence engine | HTTP JSON | Shared bearer token (required in production) |
| Gateway | External APIs | HTTPS via http.request | Credentials injected from gateway environment |
| Browser | Dashboard | HTTP | HttpOnly, SameSite=Strict session cookie |
| Dashboard | Control plane | HTTP JSON | Bearer session, added server-side |
| Control plane | PostgreSQL, MinIO, SMTP | Native, S3, SMTP | Connection credentials |
| Event relay | PostgreSQL, NATS, MinIO | Native, NATS, S3 | Connection credentials |
| Prometheus | Every service | HTTP /metrics on a separate port | None; network-restricted |
The dashboard never talks to the gateway, and the gateway never talks to the control plane. They share only the database, with disjoint write responsibilities.
Request paths
Agent process
The SDK serializes and signs the request
The client builds the authorize body, serializes it once, and signs those exact bytes. The private seed never leaves the agent process.
sdk/python/agentshield_sdk/client.py
- Signing input: <unix-seconds>.<nonce>.<hex sha256(body)>
- Nonce: 16–128 characters of [A-Za-z0-9_-]
- Headers: X-AgentShield-Agent-Id, -Timestamp, -Nonce, -Signature
Why these boundaries
A network failure between the gateway and a policy service would have to be treated as a deny, adding a failure mode to every call. Linking the evaluator into the gateway removes that hop, keeps decisions in microseconds, and means a policy error can only ever be a gateway error, which fails closed. See Policy engine.
The gateway's availability and dependency set must stay smaller than the control plane's. User management, invitations, mail, and evidence reads change often and pull in more dependencies. None of that should be able to break or slow authorization.
Content analysis needs the live result before it is returned to the agent, so the warning can travel with the content. The call has a short timeout and fails open for analysis only. Authorization still fails closed.
Publishing after commit loses an event when the process dies between commit and publish. Publishing before commit announces changes that may roll back. A trigger-fed outbox makes the event part of the same transaction as the change. See Event processing.
Decisions, approvals, executions, and audit links must commit together. Composite foreign keys, triggers, row level security, and JSON constraints in PostgreSQL enforce invariants that application code alone could bypass.
Architectural invariants
These hold across every component and are enforced in code and tests:
- Missing policy is deny. An error is never an allow.
- A recorded decision exists before any adapter runs.
- Each execution reaches its adapter at most once.
- Security events and their audit links commit in the same transaction as the change they describe.
- Model scores and content findings never change an authorization outcome.
- Raw tool arguments are never persisted; only redacted copies and hashes.
- Agent credentials are refused on management routes; human sessions are refused on enforcement routes.
Architectural direction
The decision contract is the extension point for the enforcement path. Adapters are registered by tool name behind a small interface, so new tool types plug in without changing authorization. The /v1/analyze contract allows additional analyzers, including model-based classifiers, to sit behind the same advisory interface. The event stream is the integration point for downstream consumers such as SIEM forwarding or analytical storage, which subscribe without touching the hot path.
Explore each component
Gateway
Control plane
Policy engine
Tool execution
Intelligence engine
Event processing
Data storage
Observability
Deployment
Was this page helpful?