Nano Banana Pro
Agent skill for nano-banana-pro
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Sign in to like and favorite skills
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
These instructions are for AI assistants working in this project.
Always open
@/openspec/AGENTS.md when the request:
Use
@/openspec/AGENTS.md to learn:
Keep this managed block so 'openspec update' can refresh the instructions.
AutoRouter is an enterprise AI API Gateway providing API Key distribution, multi-upstream routing, and request management. It's a Next.js fullstack application with API Routes for the backend.
# Install dependencies pnpm install # Run development server pnpm dev # Build pnpm build # Database commands (Drizzle ORM) pnpm db:generate # Generate migrations from schema changes pnpm db:migrate # Apply migrations pnpm db:push # Push schema directly (development) pnpm db:studio # Open Drizzle Studio # Linting & formatting pnpm lint # ESLint pnpm format # Prettier format pnpm format:check # Check formatting pnpm exec tsc --noEmit # Type checking # Testing pnpm test # Run tests (watch mode) pnpm test:run # Run tests once pnpm test:run --coverage # Run with coverage
src/ ├── app/ │ ├── api/ # Next.js API Routes (backend) │ │ ├── admin/ # Admin API endpoints │ │ │ ├── keys/ # API key management │ │ │ ├── upstreams/ # Upstream management │ │ │ ├── stats/ # Statistics endpoints │ │ │ └── logs/ # Request logs │ │ ├── proxy/v1/ # AI proxy endpoint │ │ └── health/ # Health check │ ├── [locale]/ # Internationalized routes (next-intl) │ │ ├── (auth)/ # Login page (route group) │ │ └── (dashboard)/ # Protected dashboard pages │ └── layout.tsx # Root layout with providers ├── components/ # React components (shadcn/ui based) ├── hooks/ # Custom React hooks (TanStack Query) ├── lib/ │ ├── db/ # Database (Drizzle ORM) │ │ ├── schema.ts # Table definitions │ │ └── index.ts # Database client │ ├── services/ # Business logic │ │ ├── key-manager.ts # API key CRUD │ │ ├── upstream-service.ts # Upstream service (re-exports from focused modules) │ │ ├── upstream-crud.ts # Upstream database CRUD operations │ │ ├── upstream-connection-tester.ts # Upstream connection testing │ │ ├── upstream-ssrf-validator.ts # SSRF protection (IP/URL/DNS validation) │ │ ├── proxy-client.ts # HTTP proxy with SSE support │ │ ├── request-logger.ts # Request logging │ │ └── stats-service.ts # Statistics aggregation │ └── utils/ # Utility functions │ ├── auth.ts # Authentication (bcrypt) │ ├── encryption.ts # Fernet encryption │ └── config.ts # Environment configuration ├── i18n/ # next-intl configuration ├── messages/ # Translation JSON files (en, zh) ├── providers/ # React context providers └── types/ # TypeScript type definitions
Upstream Management: Upstreams (AI providers like OpenAI, Anthropic) stored in PostgreSQL database. Runtime selection via
X-Upstream-Name header.
Security Model:
ADMIN_TOKEN env var)ENCRYPTION_KEY env var)Proxy Flow:
/api/proxy/v1/* receives requests → validates API key → selects upstream → forwards via proxy-client → logs request → returns SSE stream or response
Database: PostgreSQL with Drizzle ORM. Schema defined in
src/lib/db/schema.ts.
# Required DATABASE_URL=postgresql://user:password@localhost:5432/autorouter ENCRYPTION_KEY=<base64-32-bytes> # Generate: node -e "console.log(require('crypto').randomBytes(32).toString('base64'))" ADMIN_TOKEN=<admin-token> # Admin API authentication # Optional ALLOW_KEY_REVEAL=false # Allow revealing API keys LOG_RETENTION_DAYS=90 # Request log retention CORS_ORIGINS=http://localhost:3000
# Build and run with docker-compose docker-compose up -d # Or build manually docker build -t autorouter . docker run -p 3000:3000 \ -e DATABASE_URL=postgresql://... \ -e ENCRYPTION_KEY=... \ -e ADMIN_TOKEN=... \ autorouter
src/app/api/admin/{endpoint}/route.tssrc/lib/services/src/types/api.ts if neededtests/src/app/[locale]/(dashboard)/src/messages/{en,zh}.jsonsrc/components/src/hooks/