You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
User
│
▼
Nginx edge (Docker, port 80/443)
├─ routes / -> frontend (Vite build in Docker)
├─ routes /api -> backend (Node/Express in Docker)
└─ (optional TLS termination)
Backend (Docker, Node/Express)
├─ Postgres (Docker) for data
├─ AIRS security scanning (prompt/response)
├─ Optional local LLM: Ollama (Docker, profile with-ollama)
└─ SaaS LLMs:
- Google Vertex AI
- AWS Bedrock (IAM on instance)
- Azure OpenAI
- Anthropic
Docker network: shop-network (edge, frontend, backend, postgres, optional ollama)
Persistent volumes: postgres-data (db), ollama-data (models)
Screenshot chatbot of the website
Chatbot Flow & Security
Model availability & reachability: server/modelChecker.js builds the list of models, pings providers (Vertex/Anthropic/Azure/Ollama/Bedrock) and only enables reachable ones. The frontend calls /api/models/available and shows the refreshed list.
Manual refresh: the chatbot header has a “Refresh” button to re-run /api/models/available when credentials change or a new model is deployed.
AIRS toggle: UI toggle enables runtime scans for prompts and responses. Backend AIRS scan endpoint: /api/airs/scan.
LLM routing: /api/llm/chat accepts {prompt, provider, model, scanResponse} and dispatches to Vertex, Anthropic, Azure OpenAI, Ollama, or Bedrock. Mock/fallback exists for demos.
System prompt: backend reads server/SYSTEM_PROMPT.txt and prepends it inside each provider call.
Prompt sanitization/tests: src/components/Chatbot.tsx includes simple injection heuristics in simulateMockScan; adjust patterns there if you need stronger local checks.
Indices on emails, cart relations, product category.
Seed products are inserted; add more via SQL inserts or your admin flow.
Terraform on AWS
One small EC2 hosts the entire Docker Compose stack (edge, frontend, backend, postgres, optional ollama). Bedrock is consumed as a managed service; no Bedrock infra is created.
IAM role grants SSM read (for env) and Bedrock InvokeModel.
SSM parameters are created by Terraform for secrets/URLs; values are provided interactively at apply.
Cost rationale: single VM (t4g/t3 nano + EBS) is the cheapest footprint. EKS/ECS/RDS would add fixed monthly costs and operational overhead; not used for this demo.
User data installs Docker/compose, clones the repo, fetches SSM params, writes .env*, then runs docker-compose up -d.
Full deployment steps: see aws/README.md.
API Map
GET /api/models/available — model list + reachability + rate limit info.
POST /api/llm/chat — send prompt to selected provider; optional AIRS scan on response.
POST /api/airs/scan — scan a prompt/response with AIRS.
Auth: /api/auth/register, /api/auth/login.
Products: /api/products (and related) served by backend + Postgres.
Updating prompt-injection rules
Frontend mock scan: edit patterns in simulateMockScan in src/components/Chatbot.tsx.
Backend AIRS: adjust profile/token/URL in .env/.env.backend or SSM values; the AIRS toggle controls enforcement at runtime.