npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@aayvyas/gmail-classifier

v0.0.3

Published

Privacy-focused Gmail classifier using local LLM - automatically organize your inbox with AI

Readme

📧 Local Gmail Classifier with AI

Classify your Gmail inbox using a local LLM (Llama 3, Gemma, etc.) - 100% Privacy-Focused.

License: ISC TypeScript Node.js

This project automates email organization by fetching unread emails from your Gmail, analyzing them with a locally running Large Language Model (LLM), and applying granular labels automatically. No email data leaves your machine for classification!

✨ Features

  • 🔒 Privacy First: Uses a local LLM server (e.g., via llama.cpp or Ollama). Your emails are not sent to OpenAI or Anthropic.
  • 🏷️ Granular Classification: Automatically categorizes emails into:
    • bank-alert, finance, payments
    • job-application, interview, coding-assessment
    • newsletter, promotions, spam
    • social, travel, shopping
    • ...and more!
  • 🤖 Smart & Context-Aware: Uses the email subject, snippet, and body to determine the best label.
  • ⏱️ Automated: Runs as a background cron job (default: every 5 minutes).
  • 🛠️ Easy Management: Includes a CLI helper to start/stop/monitor the service.

🚀 Prerequisites

  1. Node.js: v18 or higher.
  2. Local LLM Server:
    • You need an LLM running locally that accepts OpenAI-compatible requests.
    • Default URL: http://localhost:12434/engines/llama.cpp/v1
    • Tip: You can use Ollama or LocalAI. If using Ollama, you might need a proxy or ensure it exposes the OpenAI compatible endpoint.
  3. Google Cloud Project:
    • Enable the Gmail API.
    • Create OAuth 2.0 Desktop App credentials.
    • Download the credentials.json file.

🛠️ Installation & Setup

1. Clone the Repository

git clone https://github.com/yourusername/gmail-classifier.git
cd gmail-classifier

2. Install Dependencies

npm install

3. Configure Environment Variables (Required)

Create a .env file in the project root based on the example:

cp .env.example .env

Edit .env with your settings:

# LLM Configuration
LLM_BASE_URL=http://localhost:12434/engines/llama.cpp/v1
LLM_API_KEY=sk-local-key
LLM_MODEL=ai/gemma3

# Cron Schedule (Default: Every 5 minutes)
CRON_SCHEDULE=*/5 * * * *

Note: The application will fail to start if LLM_BASE_URL or LLM_MODEL are missing.

4. Configure Credentials

Place your downloaded credentials.json file in the root directory of the project.

# It should look like this
ls -F
credentials.json  .env  package.json  src/ ...

🏃‍♂️ Usage

First Run (Authentication)

The first time you run the app, it will open your browser to authenticate with Google.

npx ts-node src/index.ts

Running as a Service (Recommended)

We provide a handy zsh helper script to manage the classifier as a background service.

  1. Add to your shell: Add the following to your ~/.zshrc (or ~/.bashrc):

    # Optional: Set custom project path if not in default location
    # export GMAIL_CLASSIFIER_DIR="/path/to/gmail-classifier"
        
    source /path/to/gmail-classifier/service.zsh
  2. Reload shell:

    source ~/.zshrc
  3. Commands:

    gmail-classifier start   # 🚀 Start the background service
    gmail-classifier status  # 🔍 Check if running
    gmail-classifier log     # 📄 View real-time logs
    gmail-classifier stop    # 🛑 Stop the service

⚙️ Customization

Modifying Labels

Edit src/prompts.ts to add or remove categories. The system will automatically create new labels in Gmail if they don't exist.

export const getLabels = (): string[] => {
  return [
    "urgent",
    "family",
    // ... add your own
  ];
};

Adjusting the Prompt

You can tweak the system prompt in src/prompts.ts to better suit your specific needs or to give the LLM more context about how you like things filed.

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the project
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

📄 License

This project is licensed under the ISC License - see the package.json file for details.