Hybrid Deployment Architecture β
This document describes the recommended hybrid deployment architecture for AI Security Gateway, which combines native Go binaries with Dockerized frontend for optimal performance and ease of deployment.
π― Hybrid Architecture Overview β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β User's Machine β
β β
β ββββββββββββββββββββββββββ ββββββββββββββββββββββββββ β
β β Native Go Backend β β Docker Frontend β β
β β (unified-admin) ββββββββ€ (Nginx + Vue.js) β β
β β Port: 8080 β β Port: 80 β β
β β β β β β
β β β’ REST API β β β’ Serves Vue.js app β β
β β β’ WebSocket β β β’ Proxies to backend β β
β β β’ Proxy Management β β β’ Volume-mapped .env β β
β β β’ SQLite Database β β β β
β ββββββββββββββββββββββββββ ββββββββββββββββββββββββββ β
β β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββπ Why This Architecture? β
Native Go Backend β
Advantages:
- β Maximum Performance - No container overhead
- β Direct System Access - Can bind to any port without port mapping
- β Easier Debugging - Direct process access, native logging
- β Lower Resource Usage - ~50MB RAM vs. container runtime overhead
- β Simpler Deployment - Single binary, no Docker needed for core functionality
- β Better for Proxy Mode - Dynamic port allocation works seamlessly
Why Not Docker for Backend?
- MCP/LLM proxies need to bind to dynamic ports (configured by user)
- Docker port mapping is complex for dynamic proxy instances
- Native binaries provide better performance for security scanning
- No need for container isolation for the backend API
- I didnt feel like spending too much time for something Im not gonna use (:
Dockerized Frontend β
Advantages:
- β Consistent Environment - Node.js + Nginx versions locked
- β Easy Updates - Pull new image, restart container
- β No Node.js Installation - Users don't need npm/node on host
- β
Configuration Flexibility - Volume-mapped
.envfor runtime changes - β Portable - Same image works across all platforms
- β Isolation - Frontend dependencies isolated from host
Why Docker for Frontend?
- Vue.js apps benefit from consistent build environment
- Nginx configuration can be templated with environment variables
- Frontend doesn't need host system access
- Users can edit
.envwithout rebuilding images
π¦ Release Package Structure β
Each release package contains:
ai-security-gateway-{platform}/
βββ unified-admin-{platform} # Native Go binary
βββ frontend/
β βββ dist/ # Pre-built Vue.js app
β βββ Dockerfile.frontend # Frontend Docker image definition
β βββ .env # Configuration (volume-mapped)
βββ docker-compose.frontend.yml # Deployment orchestration
βββ configs/
β βββ config.example.yaml # Backend configuration template
βββ policies/
β βββ critical-security.json
β βββ standard-security.json
β βββ mcp-advanced-security.json
β βββ ... (7 policy files total)
βββ .env.example # Environment variables template
βββ LICENSE
βββ README.md # Full documentation
βββ QUICKSTART.md # Getting started guideπ οΈ Building Release Packages β
For Maintainers β
# Build complete release packages for all platforms
make release-packages
# Generate SHA256 checksums
make release-checksums
# Output directory: build/packages/
# Files created:
# - ai-security-gateway-linux-amd64.tar.gz
# - ai-security-gateway-linux-arm64.tar.gz
# - ai-security-gateway-darwin-amd64.tar.gz
# - ai-security-gateway-darwin-arm64.tar.gz
# - ai-security-gateway-windows-amd64.zip
# - SHA256SUMSWhat make release-packages Does β
- Builds Go binaries for all platforms (Linux, macOS, Windows, amd64/arm64)
- Builds Vue.js frontend (
npm run buildβfrontend/dist/) - Creates package structure for each platform
- Copies all necessary files:
- Binary
- Frontend dist
- Docker configuration (Dockerfile, docker-compose)
- Configs and policies
- Documentation
- Generates QUICKSTART.md with platform-specific instructions
- Compresses packages (.tar.gz for Unix, .zip for Windows)
π₯ User Deployment Workflow β
Step 1: Download Release Package β
# Linux AMD64 (not available in public beta)
curl -LO https://github.com/syphon1c/ai-security-gateway/releases/download/v2026.x.x/ai-security-gateway-linux-amd64.tar.gz
tar -xzf ai-security-gateway-linux-amd64.tar.gz
cd ai-security-gateway-linux-amd64
# macOS Apple Silicon (M1/M2/M3) (not available in public beta)
curl -LO https://github.com/syphon1c/ai-security-gateway/releases/download/v2026.x.x/ai-security-gateway-darwin-arm64.tar.gz
tar -xzf ai-security-gateway-darwin-arm64.tar.gz
cd ai-security-gateway-darwin-arm64
# Windows
# Download ai-security-gateway-windows-amd64.zip
# Extract to folderStep 2: Start Native Backend β
# Linux/macOS
chmod +x unified-admin-*
./unified-admin-*
# Windows
.\unified-admin-windows-amd64.exeBackend starts on http://localhost:8080 with embedded web UI.
Step 3: Configure Frontend (Optional) β
Edit frontend/.env to customize:
# Point to native backend (default works for local development)
BACKEND_HOST=host.docker.internal:8080
VITE_API_BASE_URL=http://localhost:8080Important: Changes to .env take effect immediatelyβno rebuild needed!
Step 4: Start Frontend Docker Container β
docker-compose -f docker-compose.frontend.yml up -dAccess web interface at http://localhost
Step 5: Access Application β
- Via Frontend Container: http://localhost (recommended for production)
- Via Backend Directly: http://localhost:8080 (development/testing)
π§ Hybrid Configuration β
Backend Configuration β
Method 1: Environment Variables
export JWT_SECRET=your-secret-key
export DATABASE_PATH=./data/ai-gateway.db
./unified-adminMethod 2: Config File
cp configs/config.example.yaml configs/config.yaml
# Edit configs/config.yaml
./unified-adminHybrid Frontend Configuration β
Edit frontend/.env (volume-mapped, no rebuild required):
# Local development (backend on host)
BACKEND_HOST=host.docker.internal:8080
VITE_API_BASE_URL=http://localhost:8080
# Remote server deployment
BACKEND_HOST=host.docker.internal:8080
VITE_API_BASE_URL=http://server.example.com:8080
# Custom backend port
BACKEND_HOST=host.docker.internal:9090
VITE_API_BASE_URL=http://localhost:9090Apply changes:
docker-compose -f docker-compose.frontend.yml restartπ Deployment Scenarios β
Scenario 1: Local Development (Default) β
# Terminal 1: Start backend
./unified-admin
# Terminal 2: Start frontend
docker-compose -f docker-compose.frontend.yml up -d
# Access: http://localhostConfiguration: Default .env values work out of the box.
Scenario 2: Remote Server Deployment β
# On server (example.com)
./unified-admin
# Edit frontend/.env
BACKEND_HOST=host.docker.internal:8080
VITE_API_BASE_URL=http://example.com:8080
# Start frontend
docker-compose -f docker-compose.frontend.yml up -d
# Access: http://example.comScenario 3: Custom Ports β
# Start backend on port 9090
./unified-admin --addr :9090
# Edit frontend/.env
BACKEND_HOST=host.docker.internal:9090
VITE_API_BASE_URL=http://localhost:9090
# Start frontend
docker-compose -f docker-compose.frontend.yml up -dScenario 4: Backend Only (No Docker) β
# Just run the native binary
./unified-admin
# Access embedded web UI: http://localhost:8080Use case: Quick testing, development, or when Docker isn't available.
π³ Docker Commands Reference β
# Start frontend container
docker-compose -f docker-compose.frontend.yml up -d
# Stop frontend container
docker-compose -f docker-compose.frontend.yml down
# View logs
docker-compose -f docker-compose.frontend.yml logs -f
# Restart after .env changes
docker-compose -f docker-compose.frontend.yml restart
# Rebuild frontend image (after dist changes)
cd frontend
docker build -f Dockerfile.frontend -t ai-security-gateway-frontend:local ..π Resource Usage Comparison β
| Component | Native | Docker | Savings |
|---|---|---|---|
| Backend | ~50MB RAM | ~150MB RAM | 100MB |
| Frontend | N/A (requires Node.js) | ~30MB RAM | Worth it for consistency |
| Total | ~50MB + Node.js | ~180MB | Cleaner for users |
π Security Considerations β
Backend (Native Binary) β
- β No container escape vulnerabilities
- β Direct system authentication
- β Native file permissions
- β οΈ Ensure binary is from trusted source (verify SHA256)
Frontend (Docker) β
- β Isolated from host system
- β Non-root user inside container
- β Read-only volume mounts for config
- β Health checks enabled
Communication β
- Backend and frontend communicate via
host.docker.internal - Frontend uses
extra_hostsfor Docker-to-host connectivity - JWT tokens for API authentication
- HTTPS recommended for production (use reverse proxy like Traefik/Nginx)
π Troubleshooting β
Backend Issues β
Problem: Backend won't start
# Check if port 8080 is in use
lsof -i :8080 # macOS/Linux
netstat -ano | findstr :8080 # Windows
# Start on different port
./unified-admin --addr :9090Problem: Permission denied
chmod +x unified-admin-*Frontend Issues β
Problem: Can't connect to backend
# Edit frontend/.env
BACKEND_HOST=host.docker.internal:8080
VITE_API_BASE_URL=http://localhost:8080
# Restart container
docker-compose -f docker-compose.frontend.yml restartProblem: Docker container fails to start
# Check if port 80 is available
sudo lsof -i :80 # macOS/Linux
# View logs
docker-compose -f docker-compose.frontend.yml logs
# Try different port (edit docker-compose.frontend.yml)
ports:
- "8888:80"Network Issues β
Problem: CORS errors in browser console
# Backend must allow frontend origin
# Edit configs/config.yaml or set environment variable:
export CORS_ALLOWED_ORIGINS="http://localhost,http://localhost:80"
./unified-adminπ Hybrid Deployment Resources β
- Architecture Overview
- API Documentation
- Configuration Guide
- Docker Deployment (Full Stack)
- Security Audit Guide
π― Recommended Setup for Production β
# 1. Use systemd (Linux) or launchd (macOS) for backend
sudo systemctl enable ai-security-gateway
# 2. Use Docker for frontend with restart policy
docker-compose -f docker-compose.frontend.yml up -d
# 3. Use reverse proxy for HTTPS
# Example with Nginx:
server {
listen 443 ssl;
server_name gateway.example.com;
location / {
proxy_pass http://localhost:80; # Frontend container
}
}
# 4. Configure firewall
sudo ufw allow 80/tcp # Frontend
sudo ufw allow 443/tcp # HTTPS
# Do NOT expose 8080 (backend) to external trafficπ‘ Key Advantages of This Approach β
Best of Both Worlds
- Native performance for backend
- Containerized consistency for frontend
User-Friendly
- No Docker required for core functionality
- Optional Docker for enhanced frontend experience
Easy Configuration
- Volume-mapped
.envfor instant changes - No image rebuilds needed
- Volume-mapped
Flexible Deployment
- Works in dev, staging, production
- Scales to enterprise needs
Lower Barrier to Entry
- Users without Docker can still use the app
- Docker users get enhanced experience
π Migration from Full Docker Setup β
If you were previously using the full Docker setup (backend + frontend), migrate to hybrid:
# 1. Stop old containers
docker-compose down
# 2. Extract data from Docker volume
docker cp ai-security-gateway-backend:/app/data ./data
# 3. Start native backend
./unified-admin
# 4. Start new frontend container
docker-compose -f docker-compose.frontend.yml up -dYour data and configuration are preserved.