$ show ThinkWatchProject/ThinkWatch
ThinkWatch is a Rust workspace implementing an AI gateway platform that fronts multiple model providers and MCP (Model Context Protocol) servers. It exposes OpenAI-compatible chat/completion endpoints, streaming, MCP tool-call routing, content filtering, and provider failover. The backend is split into crates: `common` (shared lifecycle/limits/access), `auth` (PoW login, API keys), `gateway` (model routing), `mcp-gateway` (MCP server proxying), `server` (REST admin/audit/trace endpoints), and `test-support` (integration test client). A React/TypeScript frontend in `web/` provides an admin console, setup wizard, limits panels, and MCP server management. Data flows: requests enter the gateway, pass through `check_limits`, `check_budget`, `check_access`, then `run_post_invoke`; `trace_id` is propagated across gateway, MCP, audit, and app logs stored in ClickHouse; Postgres holds users, API keys, budgets, and MCP server configs; Redis/Lua scripts enforce rate limits.
The LLM identified 4 files worth highlighting for reuse:
Surface-agnostic request lifecycle for AI gateways: check_limits, check_budget, check_access, run_post_invoke. Reusable because it decouples policy enforcement from transport (HTTP/MCP/streaming) and can be extracted into any gateway service.
HTTP test client that automatically solves PoW challenges for /api/auth/login, so existing login call sites in tests need no changes. Demonstrates a reusable pattern for testing PoW-protected APIs.
Joins gateway_logs, mcp_logs, audit_logs, and app_logs by trace_id into a chronological event list. Reusable trace-correlation query pattern for multi-service log analysis.
API key rotation with lineage tracking, allowing old and new keys to coexist during transition. Reusable security pattern for key lifecycle management.