Skip to content

An automated backend system that fetches upcoming coding contests from platforms like Codeforces and LeetCode, stores them in Supabase, and sends timely notifications to users via Courier. Runs daily using cron jobs for full automation

Notifications You must be signed in to change notification settings

rmindit/backend

Repository files navigation

RmindIT Backend

This project sets up an automated system to fetch and notify users about upcoming coding contests from platforms like Codeforces and LeetCode.

Overview

The system consists of:

  • A Python script (main.py) that fetches contest data and sets up notifications
  • A database helper (database_helper.py) for interacting with Supabase
  • A cron helper (cron_helper.py) for managing scheduled tasks
  • A Bash script (run.sh) that sets up a cron job to run the Python script daily

Prerequisites

  • Python 3.x
  • A Unix-like operating system with cron functionality
  • Supabase account and credentials
  • Courier account and credentials

Installation

  1. Clone this repository:

    git clone https://github.com/rmindit/backend.git
    cd backend
    
  2. Set up environment variables:

    cp .env.sample .env
    

    Edit the .env file with your Supabase URL and key, as well as your Courier token & ID:

    SUPABASE_URL=your_supabase_url
    SUPABASE_KEY=your_supabase_key
    COURIER_AUTH_TOKEN=your_courier_auth_token
    COURIER_TEMPLATE_ID=your_courier_profile_id
    
  3. Make run.sh executable:

    chmod +x run.sh
    

Usage

  1. Run the setup script:

    ./run.sh
    

    This script will:

    • Activate the Python virtual environment
    • Install required Python dependencies (including Playwright)
    • Set up a cron job to run your Python script daily at midnight
  2. To manually run the Python script:

    python3 main.py
    

Functionality

  • Fetches upcoming contests from Codeforces and LeetCode
  • Stores contest information in a Supabase database
  • Sets up cron jobs to send notifications 24 hours and 1 hour before each contest

Cron Job Details

The main cron job runs daily at midnight. Additional cron jobs are created dynamically for contest notifications.

Logging and Troubleshooting

The script's output is logged to stdout. If you encounter issues:

  1. Check the script's output for error messages.
  2. Ensure your system's cron service is running correctly.
  3. Verify that env variables are set correctly.

Contributing

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

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

An automated backend system that fetches upcoming coding contests from platforms like Codeforces and LeetCode, stores them in Supabase, and sends timely notifications to users via Courier. Runs daily using cron jobs for full automation

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •