Libraries & Services
14 shared libraries in src/lib/ + 10 business logic services in src/services/ + 16 validation schemas in src/schemas/.
Libraries (src/lib/)
| File | Purpose | Key Exports |
|---|---|---|
crypto.ts | AES-256-GCM field encryption with HKDF key derivation | encrypt(), decrypt(), deriveKey() |
rbac.ts | RBAC engine: 15 roles, 67 permissions, KV-cached | requirePermission(), assignRole(), createCustomRole(), getUserPermissions() |
sessionManager.ts | httpOnly refresh cookie, token rotation, device fingerprinting | createSession(), rotateRefreshToken(), revokeSession() |
mfa.ts | TOTP enrollment, verification, backup codes, lockout | generateTOTP(), verifyTOTP(), generateBackupCodes() |
accounting.ts | Double-entry engine, 100+ COA templates, GST/TDS computation | createJournalEntry(), computeGST(), computeTDS(), trialBalance() |
mediaUpload.ts | Feed media upload to R2 with quota tracking | uploadMedia(), checkQuota() |
whatsapp.ts | Meta Cloud API v22.0 integration | sendTemplateMessage(), sendTextMessage(), sendBulk(), checkDelivery() |
gstReturns.ts | GSTR-1 + GSTR-3B JSON generation | generateGSTR1(), generateGSTR3B() |
tallyExport.ts | Tally 9/Prime XML + CSV export | exportTallyXML(), exportCSV() |
shareInvoice.ts | Invoice sharing via WhatsApp/email/UPI | shareViaWhatsApp(), shareViaEmail(), generateUPILink() |
receiptPdf.ts | HTML receipt generation with INR amount in words | generateReceipt(), amountInWords() |
upi-qr.ts | UPI deep link and QR code generation | generateUPIDeepLink(), generateUPIQR() |
dpdp.ts | DPDP Act compliance: consent management, data subject rights | recordConsent(), handleDataRequest(), breachNotification() |
razorpay.ts | Razorpay payment gateway integration | createOrder(), verifyPayment(), initiateRefund() |
Services (src/services/)
| File | Purpose | Key Methods |
|---|---|---|
billingEngine.ts | Monthly maintenance billing automation | Generate invoices, calculate penalties, late fee escalation |
taxEngine.ts | GST/TDS computation and compliance | GST calculation, TDS deduction, return preparation |
bankReconciliation.ts | Bank statement CSV ingestion + fuzzy matching | Parse CSV, match entries (Levenshtein), flag unmatched |
bookingEngine.ts | Facility slot booking with dynamic pricing | Calendar lock, peak pricing, deposit escrow, cancellation refunds |
electionEngine.ts | Anonymous elections with Pedersen Commitment | Cast ballot, verify without revealing, count votes |
feedEngine.ts | Community feed with H3 Res 8 hyperlocal radius | Create post, feed ranking, media compression pipeline |
merchantService.ts | Local merchant marketplace and POS | Register merchant, list deals, book home service |
civicEscalation.ts | Civic complaint escalation to municipal authorities | File complaint, SLA monitoring, auto-escalation |
authService.ts | Authentication business logic | Register, login, MFA, session lifecycle |
aiOrchestrator.ts | AI agent dispatch and orchestration | Route to specialist agent, tool execution, RAG retrieval |
Schemas (src/schemas/)
16 Zod validation schema files covering all domains. Each schema validates request bodies, query parameters, and response shapes. Used at the route handler level for input validation.