Cortex watches an Indian SME's receivables, payables, cash and statutory clocks, and tells the owner what is about to cost them money — before it does. It sits on top of Tally, Vyapar or Busy rather than replacing them: you upload the export, Cortex reads it.
The positioning is early warning, not "AI COO". See
src/lib/config.tsfor the plans andscripts/test-positioning.mjs, which fails the build if marketing copy drifts back.
Built with Next.js 16 (App Router) · TypeScript · Tailwind · Supabase (Postgres + Auth + RLS) · Google Gemini. Deploys to Vercel + Supabase.
130 module pages, 438 agent definitions and 28 calculators. Rather than list them here — where the list goes stale the moment someone adds a page — the sources of truth are:
| Question | Where the answer actually lives |
|---|---|
| What modules exist? | src/lib/nav.ts (127 nav entries; NAV.filter(n => n.calc) are the calculators) |
| What agents exist? | src/lib/agents/catalog.ts — agentCount() |
| What do the plans include? | src/lib/config.ts — PLANS[].features, pinned by scripts/test-positioning.mjs and scripts/test-legal.mjs |
| Which integrations really sync? | src/lib/sync/index.ts — CONNECTORS. Four: Shopify, Razorpay, Stripe, Google Sheets. The 62-entry catalogue in src/lib/integrations.ts is a credential vault, not 62 syncs. |
| What is genuinely wired vs aspirational? | SETUP.md, which is the honest document |
The load-bearing parts, the ones worth understanding first: the MSME 43B(h)
exposure engine (src/lib/msme.ts + cortex_msme_exposure), the collections
engine (src/lib/collections/), the metrics aggregation layer
(src/lib/metrics.ts), credit metering (src/lib/credits.ts) and the tenancy
model (supabase/migrations/2026_tenancy.sql).
Dark + light mode, fully responsive (desktop sidebar + mobile bottom nav), animated.
npm install
cp .env.example .env.local # fill in values (see below)
npm run dev # http://localhost:3000
The app runs in demo mode out of the box — every screen is alive with realistic data even before you connect Supabase or an AI key. Visit /dashboard directly to explore. As soon as you add credentials, it switches to live data and live AI reasoning automatically.
- Create a project at supabase.com.
- Open SQL Editor and run these three files in order:
supabase/schema.sql— the base tablessupabase/rls.sql— Row-Level Security (multi-tenant isolation) + auto-create org on signupsupabase/seed.sql— demo data + a reusableseed_demo_data(org_id)function
- In Authentication -> Providers, enable Email (magic link) and optionally Google.
- For Google: add your OAuth client ID/secret; set redirect URL to
https://YOUR-DOMAIN/auth/callback.
- For Google: add your OAuth client ID/secret; set redirect URL to
- From Project Settings -> API, copy the
URL,anonkey, andservice_rolekey.
- Push this folder to a Git repo and Import it in vercel.com (framework auto-detected as Next.js).
- Add the environment variables below in Project -> Settings -> Environment Variables.
- Deploy. Vercel runs
npm install && next buildautomatically. - In Supabase Authentication -> URL Configuration, set the Site URL and add
https://YOUR-VERCEL-DOMAIN/auth/callbackto the redirect allow-list.
# Supabase
NEXT_PUBLIC_SUPABASE_URL=https://YOUR-PROJECT.supabase.co
NEXT_PUBLIC_SUPABASE_ANON_KEY=your-anon-key
SUPABASE_SERVICE_ROLE_KEY=your-service-role-key # server-only
# AI — set at least one. AI_PROVIDER picks which is used.
ANTHROPIC_API_KEY=sk-ant-...
OPENAI_API_KEY=sk-...
AI_PROVIDER=anthropic # "anthropic" | "openai"
NEXT_PUBLIC_APP_URL=https://YOUR-VERCEL-DOMAIN
That's it — you're live.
- Sign up -> a Postgres trigger (
handle_new_user) auto-creates a profile, a demo organization, and an owner membership. - Every table is org-scoped via RLS using
user_org_ids(), so tenants never see each other's data. - Server components (
src/lib/data.ts) fetch the signed-in user's org data; if Supabase isn't configured or the org has no rows, they fall back to the bundled demo dataset so the UI is never empty. - AI CEO chat (
/api/chat) builds a live business snapshot from your metrics + insights and sends it to Claude/OpenAI with a McKinsey-grade COO system prompt (src/lib/ai/cortex.ts). With no key set it returns smart canned answers so the feature still demos.
After a user signs up, run in the Supabase SQL editor (or wire a button):
select seed_demo_data('<their-org-id>');
mnb-cortex/
|- supabase/
| |- schema.sql # all tables
| |- rls.sql # row-level security + signup trigger
| |- seed.sql # demo data + seed_demo_data() function
|- src/
| |- app/
| | |- page.tsx # landing
| | |- login/ # magic-link + Google
| | |- auth/callback/route.ts # OAuth/OTP exchange
| | |- api/chat/route.ts # AI COO endpoint
| | |- (app)/ # authenticated shell + 130 module pages
| |- components/ # sidebar, topbar, KPI cards, charts, UI primitives
| |- lib/ # supabase clients, data layer, AI layer, demo data
| |- types/
|- .env.example
|- vercel.json
Kept here deliberately, and kept honest — this list is read by people deciding whether to trust the rest of the repo, so an out-of-date one is worse than none.
- Sync connectors — four are live: Shopify, Razorpay, Stripe, Google
Sheets (
src/lib/sync/index.tsCONNECTORS). The other 59 catalogue entries store credentials and sync nothing; the integrations UI now badges themVaultand says so before you connect, rather than after you have handed over an OAuth token. File import covers Tally, Vyapar and Busy exports, andscripts/tally-bridge.mjspushes from a Tally PC into/api/v1/ingest(needs theapicapability — Watch Pro and above). - White-label — the app chrome is branded:
logo_urland the accent colour are read by(app)/layout.tsxand the sidebar. Outbound email is not —renderBrandedEmail()takes no org parameter, so all ten call sites send Cortex-branded mail. The plan bullets say "in your workspace" for this reason. (This entry used to say logo_url was "read by nothing", which stopped being true and is exactly the rot this list is supposed to avoid.) - Enterprise SSO — no SAML/OIDC. Supabase Google sign-in only. Sell on
request, per
SETUP.md. - RAG / vector search —
pgvectoris not enabled; Cortex Memory is keyword-recalled (textSearch+ilike), not embedded. So a question phrased differently from the stored memory will not retrieve it. - Autopilot coverage at scale — the nightly sweep analyses
ANALYSIS_CAP = 20workspaces, rotated. Below twenty paying workspaces that is genuinely daily; above it, each workspace is analysed everyceil(N/20)nights. The cron returnsnights_for_full_cycleand nothing currently acts on it.
Practice credit pooling— built. A firm's allowance is now spendable inside client workspaces it has claimed:src/lib/credit-pool.tsdecides the payer,cortex_practice_claim()in2026_zzzd_practice_pool.sqlproves owner/admin rank in the firm and membership of the client before writing the link, and the firm's plan and status are re-checked on every charge. Opt-in per client from the Practice console.
Private. (c) MNB Cortex.