Mini API Gateway + Developer Portal + AI Insights Engine
A production-ready Full Stack SaaS (monorepo) built with 100% free-tier friendly services: Vercel (web), Render (api), Neon (Postgres), Upstash (Redis), and Gemini (AI).
Why this exists
Teams publishing internal/external APIs usually need governance, API keys, rate limits, observability, usage analytics, and increasingly AI-assisted docs + RCA β without adopting a heavy/expensive enterprise gateway on day 1.
- API Catalog: CRUD for APIs (name, version, baseUrl, env, status, owner team)
- API Keys: create once (secret shown only once), revoke, per-key limits
- Rate Limiting: per minute + per month (Redis-backed),
X-API-Keyrequired - Request Logs: structured request logging + latency measurement
- Usage Dashboard: 7-day usage, errors by code, latency, top APIs, per-key consumption
- RBAC:
ADMIN,DEVELOPER,VIEWER(JWT auth) - AI Module (Gemini):
- Generate Markdown docs from OpenAPI + context
- RCA / insights over spikes and error patterns within a time range
A quick visual walkthrough so non-technical users can understand the product in ~1 minute.
These screenshots are illustrative demo UI images for documentation.
For βrealβ screenshots of your running environment, run the app locally and replace the PNGs indocs/screenshots/.
- Next.js 14 (App Router), TypeScript
- TailwindCSS
- Recharts
- NestJS, TypeScript
- Prisma ORM + Swagger/OpenAPI
- JWT Authentication
- Redis rate limiting (Upstash in prod)
- PostgreSQL: Neon
- Redis: Upstash
- Google Gemini (API key via environment)
- GitHub Actions (lint + tests + build)
api-gateway-developer-portal
ββ apps/
β ββ api/ # NestJS API (gateway + admin APIs + AI)
β ββ web/ # Next.js Developer Portal
ββ docker-compose.yml # Local Postgres + Redis
ββ .github/workflows/ci.yml
ββ README.md
apps/api/src
ββ modules/
β ββ auth/ # JWT + RBAC
β ββ apis/ # API catalog CRUD
β ββ api-keys/ # key issuance + revoke + limits
β ββ proxy/ # gateway proxy (X-API-Key required)
β ββ metrics/ # dashboard aggregates
β ββ ai/ # Gemini: docs + RCA insights
ββ common/
β ββ prisma/ # PrismaService, module
β ββ guards/ # JwtAuthGuard, RolesGuard
β ββ interceptors/ # RequestLoggingInterceptor
β ββ filters/ # Global exception filter
β ββ logger/ # structured logger (pino)
ββ prisma/
ββ schema.prisma
ββ seed.ts
ββββββββββββββββββββββββββββββββ
β Next.js Portal β
β - RBAC UI / Dashboard β
β - API Catalog / Keys β
β - AI Docs / RCA Buttons β
βββββββββββββββββ¬βββββββββββββββ
β JWT (admin APIs)
βΌ
ββββββββββββββββββββββββββββββββ
β NestJS API β
β /auth /apis /api-keys β
β /metrics /ai β
β /proxy/:apiId/* β
βββββββββ¬ββββββββββββ¬βββββββββββ
β β
β ββββββββββββββββΊ Gemini (AI)
β
βββββββββββΌβββββββββββ
β Postgres (Neon) β
β users, apis, keys β
β logs, violations β
β ai docs/insights β
βββββββββββ¬βββββββββββ
β
βββββββββββΌβββββββββββ
β Redis (Upstash) β
β rate limit counters β
ββββββββββββββββββββββ
Core tables:
users(ADMIN/DEVELOPER/VIEWER)apis(catalog)api_keys(hashed secrets + limits + revokedAt)request_logs(observability)rate_limit_violations(audit)ai_generated_docs(Markdown docs)ai_insights(RCA output + severity)
API keys are stored hashed (bcrypt) + a prefix to locate candidates quickly.
- Node 20+
- pnpm 9+
- Docker (for local Postgres + Redis)
docker compose up -dCopy .env.example and optionally create per-app env files:
cp .env.example apps/api/.env
cp .env.example apps/web/.env.localpnpm installpnpm --filter @portal/api prisma:migrate:dev
pnpm --filter @portal/api prisma:seedpnpm dev- Web: http://localhost:3000
- API (Swagger): http://localhost:3001/v1/docs
Default seeded admin:
- Email:
admin@local.dev - Password:
admin12345
Portal β APIs β Create
Portal β API Keys β Create
The secret is shown only once. Store it safely.
Use the proxy route:
curl -H "X-API-Key: <YOUR_KEY>" http://localhost:3001/v1/proxy/<apiId>/healthBackend:
POST /v1/ai/apis/:apiId/docs
Frontend:
- Button: Generate Docs with AI
Docs are stored in ai_generated_docs.
Backend:
POST /v1/ai/metrics/insights
Frontend:
- Button: Generate RCA
Insights are stored in ai_insights and include a severity classification.
- Create a new Web Service on Render.
- Root directory:
apps/api - Build command:
pnpm install --filter @portal/api... && pnpm --filter @portal/api build
- Start command:
pnpm --filter @portal/api start:prod
- Set env vars on Render:
DATABASE_URL(Neon)REDIS_URL(Upstash)JWT_SECRETGEMINI_API_KEYADMIN_EMAIL,ADMIN_PASSWORD,ADMIN_NAME
Run Prisma migrate on deploy using Render βPre-deploy Commandβ:
pnpm --filter @portal/api prisma:migrate && pnpm --filter @portal/api prisma:seed
- Import GitHub repo on Vercel.
- Root directory:
apps/web - Env var:
NEXT_PUBLIC_API_BASE_URL=https://<your-render-service>/v1
Implemented:
- DTO validation (global
ValidationPipe) - Global exception filter
- Structured logging
- Unit tests (auth, rate limit, AI with mocks)
- GitHub Actions CI (lint + tests + build)
- Per-route policies (allowlist/denylist)
- Usage plans (Free/Pro/Enterprise) + billing integration
- Webhooks + audit trail export (SIEM)
- OpenTelemetry tracing (OTLP) + trace correlation in UI
- API versioning strategies (semver enforcement)
- Multi-tenant orgs + SSO (OIDC/SAML)
MIT
See CONTRIBUTING.md for semantic commits (Conventional Commits).







