
Guardrail Gateway
What happens between a user's prompt and the model's answer—and what gets logged after.
Full-stack LLM safety gateway (FastAPI + React) that scans prompts and responses, routes to multiple providers, redacts blocked output, and persists audit trails in SQLite. The core engineering is the API gateway, rule engine, and logging layer.
1,667
Guardrail rules
305
Test cases
755
Input rules
912
Output rules
4
Providers
Architecture
Browser hits Vercel; /api/* reverse-proxies to Render. The gateway runs input rules + ML injection detection, calls the configured provider, scans output, redacts on block, and writes structured logs to SQLite.
Prompt flow
- 01POST /gateway/chat with user prompt
- 02Phrase + regex rules on input (allow / warn / block)
- 03ML injection classifier scores adversarial patterns
- 04Block stops request; warn/allow proceeds to provider
Response flow
- 01Provider returns model text (OpenAI, Gemini, Grok, or Mock)
- 02Output rule engine scans response content
- 03Block redacts response_text before client delivery
- 04Full request metadata + rule hits stored in SQLite
Challenges solved
- Designing a rule engine that handles 1,667 rules without latency spikes on every request
- Balancing ML classifier accuracy with deterministic phrase/regex fallbacks
- Unifying four provider APIs behind one adapter interface with consistent error handling
- Shipping audit logs useful for debugging without leaking sensitive prompt content
Engineering decisions
- SQLite for zero-ops persistence on Render free tier—structured enough for filters and stats
- Vercel reverse proxy so the frontend never exposes the Render API origin directly
- Mock provider as default for demos—predictable output without API keys
- 305 pytest cases including adversarial regression strings to prevent rule-engine drift
Lessons learned
- Safety infrastructure is mostly plumbing: scan, route, log, redact—get the audit trail right first
- Provider abstraction pays off when you need to swap models without touching gateway logic
- Regression tests for blocked phrases matter more than UI polish for a gateway product
Screenshots




Frontend: Vercel · API: Render · CI: GitHub Actions




