How devarajan8/aegis-proxy works
Purpose and Public Entry Point
Aegis Proxy is a containerized privacy gateway intended to sit between a client and an OpenAI/Groq-compatible LLM endpoint. Its public API is served by the Go gateway: health at GET /healthz and chat at POST /v1/chat/completions. Main entry point: services/gateway/main.go.
Gateway Service
The Go gateway is the only host-exposed service (port 8080). It accepts client chat-completion requests and is the intended orchestration boundary for PII sanitization, LLM forwarding, and response restoration. Its module and container build are defined in services/gateway/go.mod and services/gateway/Dockerfile; runtime behavior begins in services/gateway/main.go.
PII Processing Service
The Python/FastAPI PII engine is an internal service intended to detect sensitive values and replace them with tokens before prompts leave the private network, then reverse tokens in returned model text. Its service implementation and dependency boundary are services/pii-engine/app.py and services/pii-engine/requirements.txt; image construction is services/pii-engine/Dockerfile.
Token Vault Boundary
Redis is the intended in-memory vault for token-to-original-value mappings. The PII engine should own interaction with this store so the gateway and external LLM do not require direct access to raw mappings. Redis persistence is deliberately ephemeral: mappings are discarded when the stack restarts. Service wiring, including the Redis URL and internal topology, is centralized in docker-compose.yml.
Primary Request/Response Flow
1. A client sends a chat request to the gateway on port 8080.
2. The gateway sends prompt content to the internal PII engine.
3. The PII engine identifies/tokenizes PII and stores mappings in Redis.
4. The gateway forwards only tokenized content to the configured external LLM endpoint.
5. The returned LLM response is passed back through the PII engine for detokenization.
6. The gateway returns natural-language content to the client.
The external LLM boundary is controlled by LLM_ENDPOINT and GROQ_API_KEY; the target defaults to Groq’s chat-completions API.
Deployment and Network Topology
docker-compose.yml defines the three-service stack: gateway, PII engine, and Redis vault. Services communicate over the private Docker bridge network aegis-net; only gateway port 8080 is published to the host. Docker image boundaries are represented by services/gateway/Dockerfile and services/pii-engine/Dockerfile.
Current Maturity and Extension Points
The repository is explicitly Phase 1/skeleton-oriented. The intended architectural stages—actual NER-based PII recognition, complete proxy/detokenization behavior, streaming, authentication, rate limiting, and audit logging—are not guaranteed implemented merely by the current layout. The principal implementation anchors for those future stages are services/gateway/main.go and services/pii-engine/app.py.
Main entry points: main.go Go gateway · app.py PII engine · docker-compose.yml Compose topology · Dockerfile Gateway image
Components 11
Docker stack
Private aegis-net deployment.
- Go gateway · Only service published on port 8080.
services/gateway/main.go - Gateway image
services/gateway/Dockerfile - PII engine · Owns tokenization and detokenization.
services/pii-engine/app.py - PII engine image
services/pii-engine/Dockerfile - PII dependencies
services/pii-engine/requirements.txt - Redis token vault · Mappings are discarded when the stack restarts.
- Compose topology · Defines services, Redis URL, and aegis-net.
docker-compose.yml - aegis-net · Internal service communication boundary.
External boundary
- Client
- LLM credentials · LLM_ENDPOINT and GROQ_API_KEY select and authorize the upstream.
- OpenAI/Groq-compatible LLM · Receives tokenized prompts only.
Connections 17
- Client → Go gateway: POST /v1/chat/completions
- Client → Go gateway: GET /healthz
- Gateway image → Go gateway: builds
- PII engine image → PII engine: builds
- PII dependencies → PII engine: provides dependencies
- Go gateway → PII engine: tokenize prompt
- PII engine → Redis token vault: store and resolve mappings
- PII engine → Go gateway: detokenized response
- Go gateway → OpenAI/Groq-compatible LLM: forward tokenized chat
- OpenAI/Groq-compatible LLM → Go gateway: model response
- LLM credentials → Go gateway: configures upstream
- Compose topology → Go gateway: runs; publishes 8080
- Compose topology → PII engine: runs internally
- Compose topology → Redis token vault: runs ephemeral vault
- Go gateway → aegis-net: internal access
- PII engine → aegis-net: internal access
- Redis token vault → aegis-net: internal access