Follow these steps to set up and run the project locally:
-
Clone the repository
git clone https://github.com/nerdyabhi/betterMail.git cd betterMail -
Create a
.envfile- Create
.envinbackendfolders with your environment variables.
# LOCAL SETTINGS PORT = 3000 # NODE_ENV = 'development' ENCRYPTION_KEY='' JWT_SECRET = '' STATE_SECRET ='' DATABASE_URL='' # Google OAuth GOOGLE_AUTH_CLIENT_ID = '' GOOGLE_AUTH_CLIENT_SECRET = '' # Outlook OAuth OUTLOOK_AUTH_CLIENT_ID = '' OUTLOOK_AUTH_CLIENT_SECRET='' # ELASTIC SEARCH ELASTICSEARCH_API = '' ELASTICSEARCH_URL='' ELASTICSEARCH_INDEX ='' # GEMINI # GEMINI_API_KEY='' # SLACK SLACK_WEBHOOK_URL='' SLACK_CLIENT_ID='' SLACK_CLIENT_SECRET='' SLACK_REDIRECT_URI='' # PINECONE PINECONE_HOST='' PINE_CONE_API=''
- Create
-
Start the Frontend
cd frontend npm install npm run dev -
Start the Backend
cd ../backend npm install npm run start -
Drizzle Kit Commands (Database)
- Generate migrations:
npm run db:generate
- Run migrations:
npm run db:migrate
- Open Drizzle Studio:
npm run db:studio
- Generate migrations:
The complete application workflow includes:
- User Login: User logs into the system
- IMAP Account: User adds their IMAP account credentials
- Email Categorization: Gemini AI categorizes incoming emails
- Elastic Search: Emails are stored in Elasticsearch database with indexing
- Pinecone Embeddings: Create and store vector embeddings for sent emails
- Background Monitoring: System runs in IDLE mode, listening for new emails
- New Email Handler: When new emails arrive, the system processes them
- AI Suggestions: Generate intelligent reply suggestions
- Elasticsearch Storage: Classify and store emails with proper indexing
- Slack Integration: Send notifications via Slack webhook
{
"email_data": {
"subject": "string",
"category": "string",
"content": "string"
},
"category": "interested/spam/work etc",
"type": "sent/received",
"userId": "user's uniqueID",
"emailAddress": "string"
}The AI suggestions system works in three main steps:
- User Action: User clicks on an email
- Pinecone Integration: Find related embeddings from Pinecone database based on previous replies by the user
- Gemini AI: Use those embeddings to generate 3-5 appropriate reply suggestions using GEMINI
- Backend: Node.js with Express & TypeScript
- Database: PostgreSQL with Drizzle ORM
- Vector Database: Pinecone for embeddings
- Search Engine: Elasticsearch
- AI Services: Google Gemini AI
- Email Protocol: IMAP for email fetching
- Notifications: Slack Webhook integration
- Package Manager: Bun

