Skip to content

friendywill/leetmail

 
 

Repository files navigation

LeetMail 📧

A minimal, Dockerized LeetCode accountability system that helps groups track their coding progress together. LeetMail automatically fetches LeetCode progress for group members and sends email updates to keep everyone motivated and accountable.

Features 🚀

  • Progress Tracking: Automatically fetches LeetCode progress for all group members
  • Email Updates: Sends formatted progress reports via email using Resend
  • Simple Configuration: YAML-based user management
  • Secure Updates: Basic authentication for cron job endpoints
  • Docker Ready: Easy deployment with Docker

Prerequisites 📋

  • Docker
  • Resend API key (Get one here)
  • LeetCode usernames of group members
  • Email addresses for updates

Quick Start 🏃‍♂️

  1. Clone the repository

    git clone https://github.com/yourusername/leetmail.git
    cd leetmail
  2. Set up environment variables

    cp .env.template .env

    Edit .env with your actual values.

  3. Configure users Edit config.yml to add group members:

    users:
      - leetcode_username: "user1"
        email: "[email protected]"
      - leetcode_username: "user2"
        email: "[email protected]"
  4. Build and run with Docker Compose

    NOTE: If building the CRON job, please execute:

    git submodule update --init
    docker-compose up -d # Add --build if required.
    # If looking to run without CRON, just do:
    docker-compose up -d app

API Endpoints 🛠️

List Users

GET /users

Returns list of registered users and their email addresses.

Add User

POST /users
Content-Type: application/json

{
    "leetcode_username": "user1",
    "email": "[email protected]"
}

Get Progress

GET /progress

Returns current LeetCode progress for all users.

Trigger Update

POST /trigger-update
# Requires Basic Authentication

Triggers progress check and sends email updates to all users.

Scheduling Updates ⏰

To schedule regular updates, set up a cron job that calls the trigger endpoint. Example:

# Run daily at 9 PM
0 21 * * * curl -X POST http://localhost:8000/trigger-update -u $CRON_USERNAME:$CRON_PASSWORD

Email Format 📝

Updates are sent in a clean, readable format:

LeetCode Progress Update

User: username1
Problems Solved: 125
Current Streak: 7 days
Recent Problems:
- Two Sum
- Valid Parentheses
- ...

User: username2
...

Development

  1. Local Setup

    python -m venv venv
    source venv/bin/activate  # or `venv\Scripts\activate` on Windows
    pip install -r requirements.txt
  2. Run Development Server

    python app.py
  3. Testing API Endpoints

    # List users
    curl http://localhost:8000/users
    
    # Add user
    curl -X POST http://localhost:8000/users \
      -H "Content-Type: application/json" \
      -d '{"leetcode_username":"newuser","email":"[email protected]"}'
    
    # Trigger update
    curl -X POST http://localhost:8000/trigger-update -u admin:your_password

Configuration Options ⚙️

Environment Variables

Variable Description Default
RESEND_API_KEY Resend API key for sending emails Required
CRON_USERNAME Username for update endpoint auth admin
CRON_PASSWORD Password for update endpoint auth Required
PORT Server port 8000
HOST Server host 0.0.0.0

Contributing 🤝

  1. Fork the repository
  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 📄

Distributed under the MIT License. See LICENSE for more information.

Acknowledgments 🙏

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages

  • Python 96.1%
  • Dockerfile 3.9%