How shivanshsaxena03/noxwhatbot works
Purpose and Runtime Topology
Jarvis is a self-hosted personal WhatsApp assistant. It combines a Node.js backend worker, WhatsApp Web connectivity, AI intent/response handling, PostgreSQL persistence, scheduled reminders, and a Next.js dashboard. Development runs the dashboard on port 3000 and worker on port 3001; production is containerized and fronted by Nginx. Key deployment files: docker-compose.yml, Dockerfile, nginx.conf, pm2.config.js.
Entry Points and Package Boundaries
The worker process is the backend control-plane entry point: packages/workers/src/server.ts, exported through packages/workers/src/index.ts. The dashboard uses Next.js App Router, rooted at apps/web/src/app/layout.tsx and apps/web/src/app/page.tsx. Shared domain contracts/constants span packages through packages/shared/src/types.ts and packages/shared/src/constants.ts.
WhatsApp Connection and Message Gate
The WhatsApp adapter is built around Baileys: packages/whatsapp/src/client.ts, packages/whatsapp/src/messageHandler.ts, and packages/whatsapp/src/qrHandler.ts. It owns session connection, QR delivery, and incoming-message intake. The critical control boundary is chat authorization: disabled chats receive no storage, processing, or replies; read-only chats are persisted but never answered; AI-enabled chats enter assistant workflows. The dashboard connection page is apps/web/src/app/connection/page.tsx.
Assistant Processing Pipeline
For AI-enabled messages, the worker routes content through the AI package: packages/ai/src/intentClassifier.ts and packages/ai/src/llmClient.ts. This is the external-service boundary to OpenRouter, configured by API key/model environment variables. Classified intents drive reminder, memory, vault, and conversational reply behavior before outbound WhatsApp sends. The central package surface is packages/ai/src/index.ts.
Persistence, Memory, and Audit State
Prisma defines the authoritative PostgreSQL data model in packages/database/prisma/schema.prisma; database access is exposed from packages/database/src/index.ts. Neon PostgreSQL is the intended managed deployment target. This layer persists authorization modes, message/history state, reminders, durable memory facts, encrypted vault records, and system/audit information. Dashboard views consume backend APIs through apps/web/src/lib/api.ts, including memory and logs pages at apps/web/src/app/memory/page.tsx and apps/web/src/app/logs/page.tsx.
Reminder Lifecycle
Natural-language reminder handling is separated into parsing and execution: packages/reminders/src/parser.ts converts message text into reminder semantics, while packages/reminders/src/scheduler.ts runs scheduled/recurring work via Node-cron. Due reminders are fetched from persistence and emitted only back to their originating authorized WhatsApp chat. Operations are exposed in apps/web/src/app/reminders/page.tsx.
Security and Dashboard Control Plane
Security primitives live in packages/security/src/crypto.ts and packages/security/src/jwt.ts; vault secrets are encrypted with AES-256-GCM using VAULT_MASTER_KEY. The vault UI is apps/web/src/app/vault/page.tsx. Dashboard-wide access/session enforcement is represented by apps/web/src/components/AuthGuard.tsx, while operators manage chat permissions at apps/web/src/app/chats/page.tsx. The web app is a management surface; the worker remains responsible for WhatsApp events, automation, and side effects.
Main entry points: index.ts Database Access · server.ts Worker Server · intentClassifier.ts Intent Classifier · client.ts Baileys WhatsApp Client
Components 18
Backend Worker
WhatsApp event and automation control plane.
- Worker Server · Backend API and workflow control plane.
packages/workers/src/server.ts - Baileys WhatsApp Client · Owns session connection and inbound/outbound transport.
packages/whatsapp/src/client.ts - Message Authorization Gate · Disabled chats stop; read-only chats persist without replies.
packages/whatsapp/src/messageHandler.ts - QR Handler
packages/whatsapp/src/qrHandler.ts - Reminder Scheduler · Runs due and recurring reminder work.
packages/reminders/src/scheduler.ts
Dashboard
Next.js management surface.
- Next.js Dashboard · Operator management UI.
apps/web/src/app/layout.tsx - Dashboard Auth Guard
apps/web/src/components/AuthGuard.tsx - Dashboard API Client
apps/web/src/lib/api.ts - Connection UI · Displays WhatsApp connection and QR state.
apps/web/src/app/connection/page.tsx - Operations Views · Chats, reminders, memory, vault, and logs management.
apps/web/src/app/chats/page.tsx
Domain Services
- Intent Classifier · Classifies AI-enabled message intent.
packages/ai/src/intentClassifier.ts - OpenRouter · Model inference boundary.
packages/ai/src/llmClient.ts - Reminder Parser · Converts message text into reminder semantics.
packages/reminders/src/parser.ts - Vault Crypto · AES-256-GCM encryption for vault records.
packages/security/src/crypto.ts - Database Access · Authoritative state for chats, history, reminders, memory, vault, and audit data.
packages/database/src/index.ts - Shared Contracts · Shared types and constants across packages.
packages/shared/src/types.ts
Other components
- Nginx · Fronts the production containers.
nginx.conf - Neon PostgreSQL
packages/database/prisma/schema.prisma
Connections 23
- Nginx → Next.js Dashboard: serves
- Nginx → Worker Server: proxies API
- Next.js Dashboard → Dashboard Auth Guard: enforces access
- Dashboard Auth Guard → Dashboard API Client: authorizes
- Connection UI → Dashboard API Client: connection state
- Operations Views → Dashboard API Client: management operations
- Dashboard API Client → Worker Server: backend requests
- Worker Server → Baileys WhatsApp Client: controls
- Baileys WhatsApp Client → QR Handler: connection QR
- Baileys WhatsApp Client → Message Authorization Gate: incoming messages
- Message Authorization Gate → Database Access: authorization and history
- Message Authorization Gate → Intent Classifier: AI-enabled chats
- Intent Classifier → OpenRouter: inference
- Intent Classifier → Reminder Parser: reminder intent
- Reminder Parser → Database Access: stores reminder
- Intent Classifier → Database Access: memory, vault, audit
- Database Access → Vault Crypto: encrypts vault records
- Database Access → Neon PostgreSQL: persists via Prisma
- Reminder Scheduler → Database Access: fetches due reminders
- Reminder Scheduler → Baileys WhatsApp Client: sends to authorized origin chat
- Worker Server → Reminder Scheduler: runs automation
- Shared Contracts → Worker Server: shared types
- Shared Contracts → Next.js Dashboard: shared types