How usualdork/aiwhisper works
Purpose and Entry Points
AIWhisper is a Next.js WhatsApp automation console for configuring AI agents, connecting a WhatsApp Web account, monitoring inbox activity, and generating Gemini-based replies. The browser application begins at src/app/page.tsx, with authenticated/console-style pages grouped under src/app/(app)/layout.tsx. HTTP integration boundaries are Next.js route handlers under src/app/api.
Management Console
The app router serves dashboard, inbox, agents, knowledge-base, activity, and settings views. Feature-level client components encapsulate the operational UI:
• Agent design/listing: src/app/(app)/agents/page.tsx, src/components/agent-designer.tsx, src/components/agent-list.tsx
• Inbox and conversation handling: src/app/(app)/inbox/page.tsx, src/components/inbox-layout.tsx
• Knowledge and WhatsApp QR UX: src/app/(app)/knowledge-base/page.tsx, src/components/knowledge-base-manager.tsx, src/components/qr-login.tsx
API and Application Boundary
Route handlers expose REST-style endpoints consumed by the UI and external callers. They partition the domain into agents, inbox/messages, knowledge ingestion, activity logs, dashboard statistics, and WhatsApp lifecycle:
• src/app/api/agents/route.ts, src/app/api/inbox/messages/[chatId]/route.ts
• src/app/api/knowledge/parse/route.ts, src/app/api/dashboard/stats/route.ts
• src/app/api/whatsapp/init/route.ts, src/app/api/whatsapp/send/route.ts, src/app/api/whatsapp/status/route.ts
AI Response Pipeline
Genkit hosts the AI runtime and defines an intelligent-response-selection flow, backed by Google Gemini credentials supplied through environment configuration. The intended flow is inbound WhatsApp message/context → response-selection flow → generated reply → WhatsApp send operation.
• src/ai/genkit.ts
• src/ai/flows/intelligent-response-selection.ts
• src/lib/ai.ts
src/ai/dev.ts is the separate Genkit development entry point, run alongside Next.js via genkit:dev.
WhatsApp Integration
Baileys provides the persistent WhatsApp Web/WebSocket connection, QR authentication, outbound messaging, status inspection, and logout. The client adapter isolates this stateful external integration from HTTP endpoints.
• src/lib/whatsapp-client.ts
• src/app/api/whatsapp/init/route.ts
• src/app/api/whatsapp/logout/route.ts
This is a material runtime boundary: the Next.js server/API layer invokes a Node-compatible, connection-owning WhatsApp client rather than directly exposing Baileys to the browser.
Persistence and Operational Data
The repository currently contains JSON datasets for agents, conversations, messages, knowledge, logs, and aggregate stats. The database abstraction and server actions are the likely access boundary between routes/UI and persisted state.
• src/lib/db.ts, src/lib/actions.ts
• src/data/agents.json, src/data/conversations.json, src/data/messages.json
• src/data/knowledge.json, src/data/logs.json, src/data/stats.json
Runtime and Dependencies
Primary runtime is Node.js 18+ with Next.js 15 and React. Tailwind/Radix-based UI is rendered by the App Router; Recharts supports analytics views. External services are Google Gemini and WhatsApp Web through Baileys. WhatsApp session state is file-based per the project design, while business/analytics data is represented locally in JSON.
Main entry points: route.ts Domain route handlers · layout.tsx Console layout · whatsapp-client.ts WhatsApp client adapter · knowledge-base-manager.tsx Knowledge and QR UI
Components 18
Management Console
- App entry · Browser application entry point.
src/app/page.tsx - Console layout · Shared authenticated console shell.
src/app/(app)/layout.tsx - Agent management · Agent listing and design interface.
src/components/agent-designer.tsx - Inbox workspace · Conversation monitoring and handling UI.
src/components/inbox-layout.tsx - Knowledge and QR UI · Knowledge management and WhatsApp login UX.
src/components/knowledge-base-manager.tsx
Next.js API
- Domain route handlers · Agents, inbox, knowledge, activity, and dashboard endpoints.
src/app/api/agents/route.ts - WhatsApp route handlers · Lifecycle, status, and send endpoints.
src/app/api/whatsapp/init/route.ts
AI Runtime
- AI service adapter · Application-facing Gemini response generation interface.
src/lib/ai.ts - Response selection flow · Selects and generates an intelligent reply from inbound context.
src/ai/flows/intelligent-response-selection.ts - Genkit runtime · Hosts flows with Google Gemini credentials.
src/ai/genkit.ts - Genkit dev entry · Separate local Genkit process.
src/ai/dev.ts - Google Gemini
WhatsApp Integration
- WhatsApp client adapter · Owns persistent WhatsApp Web state, QR auth, and messaging.
src/lib/whatsapp-client.ts - WhatsApp Web
- WhatsApp session files
Persistence
- Data access boundary · Server-side access to operational datasets.
src/lib/db.ts - Server actions
src/lib/actions.ts - Operational JSON data · Agents, conversations, messages, knowledge, logs, and statistics.
src/data/agents.json
Connections 21
- App entry → Console layout: enters console
- Console layout → Agent management: renders
- Console layout → Inbox workspace: renders
- Console layout → Knowledge and QR UI: renders
- Agent management → Domain route handlers: manages agents
- Inbox workspace → Domain route handlers: loads conversations
- Knowledge and QR UI → Domain route handlers: ingests knowledge
- Knowledge and QR UI → WhatsApp route handlers: starts QR login
- Domain route handlers → Server actions: invokes
- Server actions → Data access boundary: uses
- Data access boundary → Operational JSON data: reads and writes
- Domain route handlers → AI service adapter: requests reply generation
- AI service adapter → Response selection flow: invokes
- Response selection flow → Genkit runtime: runs on
- Genkit runtime → Google Gemini: uses
- Genkit dev entry → Genkit runtime: loads flows
- Domain route handlers → WhatsApp route handlers: dispatches generated reply
- WhatsApp route handlers → WhatsApp client adapter: controls
- WhatsApp client adapter → WhatsApp Web: WebSocket connection
- WhatsApp client adapter → WhatsApp session files: persists auth
- WhatsApp client adapter → Domain route handlers: inbound message context