This project sets up an automated system to fetch and notify users about upcoming coding contests from platforms like Codeforces and LeetCode.
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
- Python 3.x
- A Unix-like operating system with cron functionality
- Supabase account and credentials
- Courier account and credentials
-
Clone this repository:
git clone https://github.com/rmindit/backend.git cd backend -
Set up environment variables:
cp .env.sample .envEdit the
.envfile 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 -
Make
run.shexecutable:chmod +x run.sh
-
Run the setup script:
./run.shThis 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
-
To manually run the Python script:
python3 main.py
- 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
The main cron job runs daily at midnight. Additional cron jobs are created dynamically for contest notifications.
The script's output is logged to stdout. If you encounter issues:
- Check the script's output for error messages.
- Ensure your system's cron service is running correctly.
- Verify that env variables are set correctly.
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.