This project is a WhatsApp chat recap generator that uses AI to summarize daily conversations. It's built with TypeScript and uses Bun as the Node.js runtime.
index.ts
: Main entry point for the WhatsApp clientserver.ts
: Express server for handling recap generation requestsrecap.ts
: Contains logic for generating recaps using OpenAImessages.ts
: Handles fetching messages from WhatsApppublic/index.html
: Frontend for the recap generatorprisma/schema.prisma
: Database schema for storing messages
-
WhatsApp Client (
index.ts
):- Uses
whatsapp-web.js
to connect to WhatsApp - Fetches messages and saves them to the database
- Uses
-
Message Fetching (
messages.ts
):- Provides functionality to fetch all messages from a chat
- Uses WhatsApp Web's internal APIs to load messages
-
Database (
prisma/schema.prisma
):- Uses Prisma with SQLite to store messages
- Stores message content, timestamps, and metadata
-
Recap Generation (
recap.ts
):- Fetches messages for a specific date from the database
- Uses OpenAI's GPT model to generate a summary
- Supports multiple languages
-
Web Server (
server.ts
):- Express server that serves the frontend and handles API requests
- Caches generated recaps for 24 hours
-
Frontend (
public/index.html
):- Simple interface for selecting a date and language
- Sends requests to the server and displays the generated recap
-
Install dependencies:
bun install
-
Set up environment variables:
DATABASE_URL
: SQLite database URL (eg."file:./dev.db"
)OPENROUTER_KEY
: OpenAI/OpenRouter API key
-
Run the WhatsApp client:
bun run index.ts
-
Run the web server:
bun run server.ts
-
Open
http://localhost:3000
in your browser to use the recap generator..
whatsapp-web.js
: For interacting with WhatsAppopenai
: For generating recaps using AIprisma
: For database operationsexpress
: For the web servernode-cache
: For caching generated recaps