Libraries & Services

14 shared libraries in src/lib/ + 10 business logic services in src/services/ + 16 validation schemas in src/schemas/.

Libraries (src/lib/)

FilePurposeKey Exports
crypto.tsAES-256-GCM field encryption with HKDF key derivationencrypt(), decrypt(), deriveKey()
rbac.tsRBAC engine: 15 roles, 67 permissions, KV-cachedrequirePermission(), assignRole(), createCustomRole(), getUserPermissions()
sessionManager.tshttpOnly refresh cookie, token rotation, device fingerprintingcreateSession(), rotateRefreshToken(), revokeSession()
mfa.tsTOTP enrollment, verification, backup codes, lockoutgenerateTOTP(), verifyTOTP(), generateBackupCodes()
accounting.tsDouble-entry engine, 100+ COA templates, GST/TDS computationcreateJournalEntry(), computeGST(), computeTDS(), trialBalance()
mediaUpload.tsFeed media upload to R2 with quota trackinguploadMedia(), checkQuota()
whatsapp.tsMeta Cloud API v22.0 integrationsendTemplateMessage(), sendTextMessage(), sendBulk(), checkDelivery()
gstReturns.tsGSTR-1 + GSTR-3B JSON generationgenerateGSTR1(), generateGSTR3B()
tallyExport.tsTally 9/Prime XML + CSV exportexportTallyXML(), exportCSV()
shareInvoice.tsInvoice sharing via WhatsApp/email/UPIshareViaWhatsApp(), shareViaEmail(), generateUPILink()
receiptPdf.tsHTML receipt generation with INR amount in wordsgenerateReceipt(), amountInWords()
upi-qr.tsUPI deep link and QR code generationgenerateUPIDeepLink(), generateUPIQR()
dpdp.tsDPDP Act compliance: consent management, data subject rightsrecordConsent(), handleDataRequest(), breachNotification()
razorpay.tsRazorpay payment gateway integrationcreateOrder(), verifyPayment(), initiateRefund()

Services (src/services/)

FilePurposeKey Methods
billingEngine.tsMonthly maintenance billing automationGenerate invoices, calculate penalties, late fee escalation
taxEngine.tsGST/TDS computation and complianceGST calculation, TDS deduction, return preparation
bankReconciliation.tsBank statement CSV ingestion + fuzzy matchingParse CSV, match entries (Levenshtein), flag unmatched
bookingEngine.tsFacility slot booking with dynamic pricingCalendar lock, peak pricing, deposit escrow, cancellation refunds
electionEngine.tsAnonymous elections with Pedersen CommitmentCast ballot, verify without revealing, count votes
feedEngine.tsCommunity feed with H3 Res 8 hyperlocal radiusCreate post, feed ranking, media compression pipeline
merchantService.tsLocal merchant marketplace and POSRegister merchant, list deals, book home service
civicEscalation.tsCivic complaint escalation to municipal authoritiesFile complaint, SLA monitoring, auto-escalation
authService.tsAuthentication business logicRegister, login, MFA, session lifecycle
aiOrchestrator.tsAI agent dispatch and orchestrationRoute 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.