The AI-Native Operating System for Modern CA Firms.
Lexvail is an enterprise-grade, multi-tenant SaaS platform for Chartered Accountant firms in India. It combines AI-powered compliance monitoring, proactive risk intelligence, and WhatsApp-based client communication into a single practice operating system β shifting CA firms from reactive record-keeping to proactive risk management.
- Features
- Tech Stack
- Architecture
- Getting Started
- Environment Variables
- Available Scripts
- API Reference
- Security
- Deployment
- Contributing
A centralized command center providing a bird's-eye view of firm-wide health, average trust scores across all clients, and critical system logs.
A real-time volatility feed with trend sparklines that tracks clients whose Trust Scores dropped. Identifies filing misses and GSTIN anomalies before they trigger departmental notices.
A visual, high-fidelity gauge for individual clients powered by Gemini AI. Explains why a score is low (e.g., "Missing December GSTR-1") and provides an immediate mitigation plan.
Monitors clients on "Soft-Lock" protocol due to missing critical documents (UDYAM certificates, GST certificates, Board Resolutions) and tracks resolution progress dynamically.
A specialized radar for vendor payment compliance. Flags invoices nearing the 45-day threshold, calculates potential tax disallowance penalties, and generates WhatsApp "Nudge" alerts for clients.
A cryptographically verifiable, non-deletable event stream of every action taken by AI agents and staff members β ensuring complete transparency and audit readiness.
Advanced management of all client GSTIN IDs, trust indices, and active filing operations with interactive status tracking.
An intelligent WhatsApp assistant that operates in two modes:
- Staff (Vex) Mode: Intent-aware command routing β query client status, trigger MSME scans, draft notices.
- Guard Mode: Client-facing compliance checks, VIP bypass, regional language auto-detection, and document upload verification.
Upload tax notices (GST, Income Tax), generate AI-powered draft responses with legal case citations via Gemini, and manage an approval workflow (Draft β Approved β Sent).
Real-time sync with Tally accounting software for bank statement reconciliation, invoice tracking, and transaction synchronisation.
Upload documents to Supabase Storage, extract data with Gemini Vision (GSTIN, ARN, filing status), verify authenticity, and manage document categorization.
A dedicated portal for clients to upload documents, view compliance status, and communicate securely β with role-appropriate data isolation.
| Layer | Technology |
|---|---|
| Framework | Next.js 16 (App Router) + TypeScript |
| UI / Styling | Tailwind CSS + Framer Motion |
| Icons | Lucide React |
| Backend / DB | Supabase (Auth + PostgreSQL + Storage) |
| AI Engine | Google Gemini 1.5 Flash (intent analysis + vision) |
| Messaging | Twilio WhatsApp API |
| Rate Limiting | Upstash Redis |
| Validation | Zod |
| PDF Export | jsPDF + jsPDF-AutoTable |
| HTTP Client | Axios |
| Google APIs | Google Drive, Google Calendar |
| Testing | Vitest + React Testing Library |
| Linting | ESLint + Prettier |
| Deployment | Vercel (with cron jobs) |
WhatsApp Message β Twilio β /api/webhook/whatsapp
β
βΌ
Phone Lookup (normalisation + case fallback)
β
ββ Staff phone β Vex Command Mode (intent-aware routing)
β
ββ Client phone β Guard Mode
β
ββ Kill-switch check (bot_active = false β forward to CA)
ββ VIP bypass (is_vip = true β warm response + CA alert)
ββ Language auto-detect β regional translation
ββ Document uploads β AI verification β saved as DRAFT
Security layers:
- Row-Level Security (RLS) enforced at the database layer β zero cross-firm data leakage.
supabaseAdminused only in server-side webhook/cron routes;supabase(RLS-enforced) used for all client-facing queries.- Twilio webhook always returns HTTP 200 with empty TwiML to prevent infinite retry storms.
βββ app/ # Next.js App Router (pages + API routes)
β βββ api/ # Backend routes (clients, notices, cron, webhook, vex β¦)
β βββ dashboard/ # Main CA dashboard
β βββ portal/ # Client self-service portal
β βββ page.tsx # Auth / login
βββ components/
β βββ dashboard/ # Dashboard tabs & widgets
β βββ ui/ # Shared UI primitives (Button, Modal, Input β¦)
βββ lib/
β βββ services/ # Core business logic (database, gemini, twilio, trust β¦)
β βββ security/ # Zod schemas, prompt-prison, GSTIN validator
β βββ types/ # Global TypeScript types
β βββ constants/ # App-wide constants & intent definitions
βββ supabase/ # SQL schema + RLS policies
βββ tests/ # Vitest unit tests + webhook integration tests
- Node.js 18+
- A Supabase project
- A Google AI Studio API key (Gemini)
- A Twilio account with a WhatsApp-enabled number (optional for local dev)
# 1. Clone the repository
git clone https://github.com/ch1n-may/ca-app.git
cd ca-app
# 2. Install dependencies
npm install
# 3. Configure environment variables
cp .env.example .env.local
# Edit .env.local β see Environment Variables section below
# 4. Start the development server (Turbopack)
npm run devVisit http://localhost:3000.
| Variable | Required | Description |
|---|---|---|
NEXT_PUBLIC_SUPABASE_URL |
β | Your Supabase project URL |
NEXT_PUBLIC_SUPABASE_ANON_KEY |
β | Supabase anonymous (public) key |
SUPABASE_SERVICE_ROLE_KEY |
β | Supabase service role key (server only) |
GEMINI_API_KEY |
β | Google Gemini AI API key |
TWILIO_ACCOUNT_SID |
β | Twilio account SID |
TWILIO_AUTH_TOKEN |
β | Twilio auth token |
TWILIO_WHATSAPP_FROM |
β | Twilio WhatsApp sender number (e.g. whatsapp:+14155238886) |
NEXT_PUBLIC_BASE_URL |
β | Public base URL (e.g. https://yourapp.vercel.app) |
CRON_SECRET |
β | Secret token for authenticating cron job requests |
UPSTASH_REDIS_REST_URL |
β¬ | Upstash Redis URL (rate limiting) |
UPSTASH_REDIS_REST_TOKEN |
β¬ | Upstash Redis token (rate limiting) |
GOOGLE_CLIENT_ID |
β¬ | Google OAuth client ID (Drive / Calendar) |
GOOGLE_CLIENT_SECRET |
β¬ | Google OAuth client secret |
| Script | Description |
|---|---|
npm run dev |
Start development server with Turbopack |
npm run build |
Build for production |
npm start |
Start production server |
npm run lint |
Run ESLint |
npm run type-check |
TypeScript type validation (tsc --noEmit) |
npm test |
Run Vitest unit tests |
npm run test:ui |
Run Vitest with interactive UI |
npm run test:coverage |
Run tests with coverage report |
npm run test:integration |
Run webhook integration simulation |
npm run format |
Format all files with Prettier |
npm run format:check |
Check formatting without writing |
| Method | Endpoint | Description |
|---|---|---|
GET/POST |
/api/clients |
List all clients / create a client |
GET/PUT/DELETE |
/api/clients/[id] |
Get, update, or delete a client |
POST |
/api/clients/bulk |
Batch import clients |
POST |
/api/clients/broadcast |
Send broadcast WhatsApp message |
POST |
/api/clients/sync-deadlines |
Sync filing deadlines |
| Method | Endpoint | Description |
|---|---|---|
GET |
/api/notices |
List tax notices |
GET/POST |
/api/notices/drafts |
Manage AI-generated draft responses |
POST |
/api/notices/alerts/msme |
Send MSME payment alerts |
| Method | Endpoint | Description |
|---|---|---|
POST |
/api/documents/verify |
Verify uploaded document via Gemini Vision |
POST |
/api/documents/sign |
Digitally sign a document |
| Method | Endpoint | Description |
|---|---|---|
POST |
/api/portal/upload |
Client document upload |
POST |
/api/portal/verify |
Verify portal submission |
POST |
/api/portal/dispatch |
Dispatch verified documents |
| Method | Endpoint | Description |
|---|---|---|
POST |
/api/webhook/whatsapp |
Twilio WhatsApp webhook (Vex/Guard bot) |
GET/POST |
/api/tally |
Tally ERP sync |
POST |
/api/vex |
VEX AI agent direct query |
| Endpoint | Schedule | Description |
|---|---|---|
/api/cron/msme-radar |
Daily 3:30 AM UTC | Scan for MSME payment violations |
/api/cron/risk-report |
Weekly | Generate firm risk summary |
/api/cron/newsletter |
Monthly | Client compliance newsletter |
/api/cron/cleanup-portal |
Weekly | Remove stale portal sessions |
- Row-Level Security (RLS): Deep isolation at the database layer β clients can only query their own records via
auth.uid()checks. - PII Masking: Automatic redaction of PAN, GSTIN, and CIN in immutable forensic logs.
- Forensic Audit Ledger: Cryptographically tracked, non-deletable action stream.
- Content Security Policy (CSP): Strict headers preventing XSS, clickjacking, and data injection attacks.
- HSTS: 1-year preload with
includeSubDomains. - Rate Limiting: Upstash-based rate limiting on all public API routes.
- GSTIN Checksum Validation: Every tax ID is validated via the 15-character checksum algorithm before processing.
- No Production Source Maps: Source code is not exposed in production builds.
- Notice DRAFT Gate: AI-generated notice responses are always saved as
DRAFTβ a CA must manually approve before any reply is sent to the tax department.
Lexvail is optimised for Vercel.
# Deploy to production
vercel --prodCron jobs are configured in vercel.json and run automatically on the defined schedules. Ensure all environment variables listed above are configured in your Vercel project settings.
For a full step-by-step deployment walkthrough, see LEXVAIL_SETUP.md.
- Fork the repository and create a feature branch (
git checkout -b feature/my-feature). - Make your changes and ensure all tests pass (
npm test). - Run the type checker (
npm run type-check) and linter (npm run lint). - Open a pull request with a clear description of your changes.
Version 2.1.0 Β· Built for Indian CA Excellence Β· Lexvail Intelligence