# @yuuki-co/ai-portal

> Multi-user AI sharing portal & CLI — Claude Code, Cursor, and IDE gateway

Latest version **1.0.1** (published 2026-09-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install @yuuki-co/ai-portal
pnpm add @yuuki-co/ai-portal
yarn add @yuuki-co/ai-portal
bun add @yuuki-co/ai-portal
```

Provides the command `ai-portal`.

## Health

**Score 60/100 (C)** — status: active.

Positive: esm support; no vulnerabilities; recently updated; high maintenance score.

Warnings: low downloads; no types.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2026-09-24 |
| First published | 2026-09-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Node | >=20.0.0 |
| Dependencies | 23 |
| Unpacked size | 41.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | aditya253 |
| Keywords | ai-portal, claude-code, cursor, gateway, anthropic, azure-foundry, openrouter |

## Links

- npm: https://www.npmjs.com/package/@yuuki-co/ai-portal
- Repository: https://github.com/Yuuki-Co/ai-portal
- Homepage: https://github.com/Yuuki-Co/ai-portal#readme
- Issues: https://github.com/Yuuki-Co/ai-portal/issues
- npm.io page: https://npm.io/package/@yuuki-co/ai-portal

## Dependencies (23)

- [pg](https://npm.io/package/pg.md) ^8.23.0
- [zod](https://npm.io/package/zod.md) ^3.24.4
- [uuid](https://npm.io/package/uuid.md) ^11.1.0
- [bullmq](https://npm.io/package/bullmq.md) ^5.51.0
- [helmet](https://npm.io/package/helmet.md) ^8.2.0
- [marked](https://npm.io/package/marked.md) ^15.0.12
- [openai](https://npm.io/package/openai.md) ^4.96.0
- [express](https://npm.io/package/express.md) ^4.21.2
- [ioredis](https://npm.io/package/ioredis.md) ^5.6.1
- [bcryptjs](https://npm.io/package/bcryptjs.md) ^2.4.3
- [playwright](https://npm.io/package/playwright.md) 1.61.1
- [highlight.js](https://npm.io/package/highlight.js.md) ^11.11.1
- [connect-redis](https://npm.io/package/connect-redis.md) ^8.0.2
- [better-sqlite3](https://npm.io/package/better-sqlite3.md) ^11.8.1
- [@bull-board/api](https://npm.io/package/@bull-board/api.md) ^6.7.0
- [express-session](https://npm.io/package/express-session.md) ^1.18.1
- [marked-highlight](https://npm.io/package/marked-highlight.md) ^2.2.4
- [playwright-extra](https://npm.io/package/playwright-extra.md) ^4.3.6
- [@anthropic-ai/sdk](https://npm.io/package/@anthropic-ai/sdk.md) ^0.39.0
- [@bull-board/express](https://npm.io/package/@bull-board/express.md) ^6.7.0
- [@google/generative-ai](https://npm.io/package/@google/generative-ai.md) ^0.21.0
- [@modelcontextprotocol/sdk](https://npm.io/package/@modelcontextprotocol/sdk.md) ^1.30.0
- [puppeteer-extra-plugin-stealth](https://npm.io/package/puppeteer-extra-plugin-stealth.md) ^2.11.2

## Alternatives

- [express-promise-router](https://npm.io/package/express-promise-router.md) — 736.1K weekly downloads
- [next-usequerystate](https://npm.io/package/next-usequerystate.md) — 29.8K weekly downloads
- [@bitkyc08/opencodex](https://npm.io/package/@bitkyc08/opencodex.md) — 4.6K weekly downloads
- [lynkr](https://npm.io/package/lynkr.md) — 575 weekly downloads
- [baremetal.js](https://npm.io/package/baremetal.js.md) — 42 weekly downloads

## Recent versions

- 1.0.1 (latest) — 2026-09-24
- 1.0.0 — 2026-09-24

## README

# AI Portal

A self-hosted, multi-user portal that gives a team shared access to AI subscriptions — Claude, Gemini, OpenAI, and others — through one chat UI and an admin console. Supports both direct API providers and browser-automated providers (for services without a usable API), per-user access control, multi-tenant orgs, usage tracking, and a job queue for concurrent requests.

## Architecture

Two long-running processes, one shared SQLite DB, Redis as the connective tissue:

```
                         ┌────────────────────────┐
    Browser  ───────────▶│   server/index.js      │◀── serves dist/ or pages/ (Vite dev/prod UI)
                          │   Express API server    │
                          │                         │
                          │  requireLogin/Admin ──┐ │
                          │  routes/*.js  ◀────────┘ │
                          └───────┬─────────┬───────┘
                                  │         │
                     inline job   │         │  enqueue (API providers)
                  (browser provs) │         ▼
                                  │   ┌─────────────┐      ┌──────────────┐
                                  │   │    Redis    │◀────▶│ queue/worker │
                                  │   │ (sessions + │      │    .js       │
                                  │   │  BullMQ)    │      └──────┬───────┘
                                  │   └─────────────┘             │
                                  ▼                                ▼
                          ┌────────────────────────────────────────────┐
                          │         providers/<name>/*Provider.js       │
                          │  API providers (Anthropic/OpenAI/Gemini/…)  │
                          │  Browser providers (Playwright + Chromium)  │
                          └───────────────────┬──────────────────────────┘
                                               ▼
                                     ┌───────────────────┐
                                     │  data/portal.db    │  (SQLite: conversations,
                                     │  (better-sqlite3)  │   messages, jobs, usage_log, published_shares)
                                     └───────────────────┘
```

- **API server** (`server/index.js`) — auth, UI serving (dev/production), job submission, SSE streaming; runs browser-provider jobs inline.
- **Worker** (`server/queue/worker.js`) — separate process; pulls API-provider jobs off a per-user BullMQ queue in Redis.
- **Vite Frontend** — built from `pages/` and `src/` into the `dist/` directory. Serve `dist/` in production; Vite dev server handles HMR on port 5110 (governed port assignment for Anand's local development).
- **Graceful degradation** — if Redis is down, API jobs fall back to inline execution in the API process. No Redis required to run it locally, just to scale it.

For the full module-by-module map (every file in `server/`, the job data-flow, the role hierarchy, browser-automation internals, tiered sharing) see **[CONTEXT.md](docs/CONTEXT.md)** — that document is the detailed architecture reference this README summarizes.

## Quick start (local dev)

Requires Node ≥ 20 and, ideally, a local Redis (optional — see above).

```bash
cp .env.example .env              # see "Environment" below
npm install
node scripts/add-user.js admin password admin

# Start API server, worker, and Vite dev server:
npm run dev:full
# → http://localhost:5110 (Vite frontend with API proxy to 3040)
```

Other useful scripts (from `package.json`):

| Command | What it does |
|---|---|
| `npm run dev:full` | Launches server, worker, and Vite frontend watcher concurrently (port 5110) |
| `npm run build` | Compiles TypeScript and runs Vite production build (`tsc && vite build`) |
| `npm run dev` | API server only (port 3040), auto-restart on change |
| `npm run dev:worker` | Worker only, auto-restart on change |
| `npm run start:all` | Production start for server and worker processes (requires built frontend) |
| `npm run add-user` | CLI: create a user (`node scripts/add-user.js <username> <password> [role]`) |
| `npm run add-subscription` | CLI: register a provider subscription |
| `npm run migrate` | Apply pending SQLite schema migrations |
| `npm run validate:skills` | Validate web-module skill definitions |

## Environment setup

Copy `.env.example` to `.env` and fill in what you need. Everything not listed below is optional and provider-specific.

| Variable | Required? | Notes |
|---|---|---|
| `SESSION_SECRET` | **Yes** | `openssl rand -base64 32`. The app has an insecure random fallback for convenience in dev — **never rely on it in production** (see [REMEDIATION.md](docs/REMEDIATION.md) S7). |
| `REDIS_URL` | Recommended | Default `redis://localhost:6380`. Without it: sessions and queues degrade to in-process/inline behavior — fine for a single-instance dev box, not for production. |
| `PORT` | No | Default `3040`. |
| `*_API_KEY` (`ANTHROPIC_API_KEY`, `OPENAI_API_KEY`, `GEMINI_API_KEY`, …) | Only for providers you use | See `.env.example` for the full list. Per-subscription keys (via the admin console) take priority over these env fallbacks. |
| `METRICS_TOKEN` | No | Bearer token to expose `/metrics` to something other than localhost (Prometheus scraping). |
| `NODE_ENV=production` | Production only | Also gates the session cookie's `secure` flag — see [REMEDIATION.md](docs/REMEDIATION.md) S7 before deploying. |

For provider-specific browser-automation setup (Chromium sessions, Xvfb on a headless VPS) and the full production deployment walkthrough, see **[DEPLOY.md](docs/DEPLOY.md)**.

## Project layout

```
server/
  index.js        Express entry point — mounts every route in routes/
  auth/           Session guards, role/permission checks, org scoping
  db/             SQLite connection + schema.sql
  providers/      One folder per AI provider (API-based and browser-based)
  queue/          BullMQ queue + worker + per-user queue logic
  router/         Query classification / smart model routing
  routes/         ~20 Express routers — one per API surface
  web-module/     Browser-automation engine, SSRF guard, site adapters
pages/            Source HTML templates for the Vite pages
src/              Frontend TypeScript source code (chat UI, admin panels, shared)
dist/             Production bundled frontend (output of `npm run build`)
public/           Static assets (robots.txt, images, global CSS fallback)
scripts/          CLI utilities (add-user, add-subscription, migrate, …)
data/             Runtime state — gitignored (SQLite DB, session data, JSON configs)
docs/adr/         Architecture Decision Records — the "why" behind key choices
```

See [CONTEXT.md](docs/CONTEXT.md) for a file-by-file breakdown of every path above.

## Further reading

| Doc | What's in it |
|---|---|
| [CONTEXT.md](docs/CONTEXT.md) | Full architecture reference — every module, the job data-flow, role hierarchy, browser-automation internals |
| [DEPLOY.md](docs/DEPLOY.md) | Production VPS/Docker deployment walkthrough |
| [USER_GUIDE.md](docs/USER_GUIDE.md) | End-user and administrator guide to the product itself |
| [ROADMAP.md](docs/ROADMAP.md) | Planned work, phased |
| [docs/adr/](docs/adr) | Why the system is built the way it is — dual persistence, SQLite, browser automation, org/role model |
| [REMEDIATION.md](docs/REMEDIATION.md) | Tracked findings from a technical due-diligence review — known gaps and their fixes, ranked by priority |

## Status

Under active development. Several subsystems (multi-tenant orgs, per-user queues, additional providers, smart routing, groups) are implemented but not yet fully hardened for production multi-tenant use — see [REMEDIATION.md](docs/REMEDIATION.md) before deploying this beyond a trusted, single-team setting.

---
_Source: https://npm.io/package/@yuuki-co/ai-portal · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
