Alkabrain / replit.md
shrey77777's picture
Upload ALKABRAIN AI companion
0b6a541 verified

ALKABRAIN

A warm, Claude.ai-style AI companion that auto-routes every message to the right open-source HF model. Multi-agent collaboration on code, daily quotas with reset window, Razorpay subscription billing, and self-deploy to Hugging Face Spaces.

Stack

  • Monorepo: pnpm workspaces Β· TypeScript 5.9
  • Frontend: React + Vite (artifacts/ai-router)
  • API: Express 5 (artifacts/api-server) β€” esbuild bundle
  • Database: PostgreSQL + Drizzle ORM (lib/db)
  • API codegen: Orval from OpenAPI (lib/api-spec β†’ lib/api-client-react, lib/api-zod)
  • Auth: Replit Auth (OIDC + PKCE), shared web hook in lib/replit-auth-web
  • Billing: Razorpay payment links + webhook (HMAC verified)
  • Models: Hugging Face Router (OpenAI-compatible) across 22 models

Tiers

Tier Price Daily messages Multi-agent Notes
Free β‚Ή0 30 no General routing
Starter β‚Ή999/mo 500 yes All models, Coder + Reviewer on code
Pro β‚Ή2499/mo 5000 yes Priority routing + R1 deep review

Payment links: https://rzp.io/rzp/vXngZyC4 (Starter), https://rzp.io/rzp/UudyBfFv (Pro). Razorpay webhook upgrades the user automatically by matching their email.

Multi-agent

When the router classifies an intent as code and the user has Starter or Pro, the chat endpoint runs:

  1. Coder agent β€” DeepSeek V3 (fallback Qwen 2.5 Coder 32B)
  2. Reviewer agent β€” DeepSeek R1 Distill Llama 70B

The reply is the coder output plus a structured review section.

Persona

artifacts/api-server/src/lib/persona.ts β€” warm, friendly, matches the user's language (English, Hindi, Hinglish). Never names internal models unless asked.

Required env

  • DATABASE_URL β€” auto-provisioned Postgres
  • HF_TOKEN β€” Hugging Face token (write access for self-deploy)
  • SESSION_SECRET β€” session secret for cookies
  • RAZORPAY_WEBHOOK_SECRET β€” verifies the Razorpay webhook signature
  • REPL_ID, ISSUER_URL β€” set by Replit for auth

Key commands

  • pnpm --filter @workspace/db run push β€” apply schema changes
  • pnpm --filter @workspace/api-spec run codegen β€” regenerate hooks + zod
  • pnpm --filter @workspace/ai-router run dev β€” frontend
  • pnpm --filter @workspace/api-server run dev β€” backend

Razorpay webhook setup

In the Razorpay dashboard, add a webhook:

  • URL: https://<your-replit-domain>/api/webhooks/razorpay
  • Events: payment.captured
  • Secret: same value as RAZORPAY_WEBHOOK_SECRET

The webhook router is mounted before express.json() so the raw body is preserved for HMAC verification.

Self-deploy to HF Space

The Deploy tab pushes the bundled router to shrey77777/xyzzz via the existing deploy job (uses HF_TOKEN).