MostaQL is a specialized job scraping and notification system designed to monitor Mostaql.com for new freelance opportunities. It features intelligent polling, advanced filtering based on hiring rates, and a dual-channel notification system.
- Smart Polling: Optimizes bandwidth by checking the newest job ID first. Full scraping only occurs when new data is detected.
- Hiring Rate Enrichment: Fetches individual job pages to parse hiring rates (budget/success score).
- Anti-Ban Strategy: Implements User-Agent rotation, random delays, and connection validation to maintain access reliability.
- Producer-Consumer Queue: Implements a non-blocking custom Thread and Queue system. The scraper produces tasks while a background worker consumes them.
- Dual-Channel Support: Delivers notifications via Email (SMTP/Brevo) and Telegram (Bot API).
- Smart Grouping: Batches users with identical job sets for efficient processing while respecting individual
min_hiring_ratefilters. - Graceful Lifecycle: Uses a
Lifespancontext manager to ensure the queue finishes processing and worker threads exit cleanly during shutdown.
- Optimized SQLite: Configured for high concurrency using WAL Mode (Write-Ahead Logging),
synchronous=NORMAL, and increased cache size. - Atomic Writes: Ensures consistency of user state and notification logs through transaction-based operations.
- Broadcast System: Includes a secure API endpoint protected by an Admin Secret to push maintenance alerts to all users.
- Infrastructure: Fully Dockerized application using FastAPI and Caddy.
- Reverse Proxy: Caddy manages automatic HTTPS (Let's Encrypt) and gzip compression.
- CI/CD: Automated deployment pipeline via GitHub Actions.
- Security: Implements rate limiting via SlowAPI on public endpoints and strict environment variable management for secrets.
-
Clone & Configure
git clone https://github.com/HossamSaberX/MostaQL.git cd MostaQL cp .env.example .env -
Edit Environment Open
.envand set your secrets (Telegram Token, Email Credentials).nano .env
-
Launch
docker-compose up -d --build
-
Install Dependencies (using
uvorpip)./setup_uv.sh # or pip install -r requirements.txt -
Run Database Migrations
alembic upgrade head
-
Start Backend
python -m backend.main
The system is configured via environment variables. Copy .env.example to .env.
| Variable | Description | Default |
|---|---|---|
SCRAPER_INTERVAL_MINUTES |
Time between full scrapes | 30 |
SCRAPER_POLL_INTERVAL_MINUTES |
Time between "newest ID" checks | 2 |
EMAIL_PROVIDER |
gmail, brevo, or alternate |
gmail |
TELEGRAM_BOT_TOKEN |
Your Telegram Bot Token | Required |
DATABASE_URL |
SQLite connection string | sqlite:///./data/mostaql.db |
This project is licensed under the MIT License - see the LICENSE file for details.