How xecipher/gemprism works
GemPrism is a Gemini API gateway that authenticates a gateway token, resolves model aliases and limits, selects a healthy least-loaded API key, forwards requests, retries eligible failures, and records usage. Users sign in and manage keys and monitor health and per-model usage through the dashboard. The proxy excerpt is partial, so the routing and persistence stages follow the documented flow; unshown dashboard behavior is represented only where the supplied excerpt supports it.
Main entry points: supabaseAdmin.ts Admin client · route.ts Edge proxy handler · supabase.ts Supabase client · page.tsx Key and usage dashboard
Components 14
Gateway routing
- Edge proxy handler
src/app/api/proxy/[...path]/route.ts - Model aliases and limits
src/lib/modelLimits.ts - Key selection and retries
src/app/api/proxy/[...path]/route.ts
Accounts and dashboard
- Sign in and signup
src/app/login/page.tsx - Key and usage dashboard
src/app/dashboard/page.tsx - Admin stats endpoint
src/app/api/admin/stats/route.ts - Product landing page
src/app/page.tsx
Configuration and state
- Supabase client
src/lib/supabase.ts - Admin client
src/lib/supabaseAdmin.ts - Gateway and usage tables
- Keepalive endpoint
src/app/api/keepalive/route.ts
Other components
- SDK client app
- Gemini API
- Supabase Auth
Connections 20
- SDK client app → Edge proxy handler: sends request
- Edge proxy handler → Admin client: resolves token
- Admin client → Gateway and usage tables: reads token
- Edge proxy handler → Model aliases and limits: normalizes model
- Edge proxy handler → Admin client: loads keys and usage
- Admin client → Gateway and usage tables: reads pool state
- Edge proxy handler → Key selection and retries: routes and retries
- Key selection and retries → Gemini API: forwards request
- Key selection and retries → Admin client: updates key state
- Key selection and retries → Admin client: records usage
- Admin client → Gateway and usage tables: writes state
- Sign in and signup → Supabase client: authenticates
- Supabase client → Supabase Auth: signs in users
- Key and usage dashboard → Supabase client: manages keys
- Key and usage dashboard → Admin stats endpoint: fetches telemetry
- Admin stats endpoint → Admin client: loads dashboard data
- Admin client → Gateway and usage tables: reads and creates token
- Keepalive endpoint → Supabase client: checks activity
- Supabase client → Gateway and usage tables: queries key table
- Product landing page → SDK client app: shows integration