Full-stack application for scraping and managing real estate leads from EVV.AZ and Villa.AZ.
.
├── scraper/ # Python scraper backend
│ ├── sources/ # Website-specific scrapers
│ ├── scripts/ # Utilities (validator, telegram)
│ └── main.py # Scraper orchestrator
│
├── app/ # Next.js frontend
│ ├── api/ # API routes
│ ├── dashboard/ # User dashboard
│ ├── admin/ # Admin panel
│ └── login/ # Authentication
│
├── lib/ # Shared utilities
│ ├── db.ts # Database connection
│ └── auth.ts # Authentication helpers
│
└── components/ # React components
- Automated daily scraping from EVV.AZ and Villa.AZ
- Phone number validation (Azerbaijan mobile numbers)
- Telegram notifications with detailed reports
- PostgreSQL storage with duplicate prevention
- GitHub Actions for automated scheduling
- Admin authentication with NextAuth.js
- User management (CRUD operations)
- Leads dashboard with statistics
- Search and pagination
- Excel export functionality
- Role-based access control (Admin/User)
# Initialize leads table
psql $DATABASE_URL -f scraper/init_db.sql
# Initialize users table
psql $DATABASE_URL -f init_users_db.sql# Install dependencies
npm install
# Set up environment
cp .env.example .env.local
# Edit .env.local with your credentials
# Run development server
npm run devVisit http://localhost:3000
Default credentials: admin / admin123
cd scraper
# Local testing
docker compose up scraper
# Or with Python
python main.pyDATABASE_URL=postgresql://...
NEXTAUTH_URL=http://localhost:3000
NEXTAUTH_SECRET=generate-with-openssl-rand-base64-32DATABASE_URL=postgresql://...
TELEGRAM_BOT_TOKEN=your-bot-token
TELEGRAM_CHAT_ID=your-chat-idSee DEPLOYMENT.md for detailed deployment instructions.
# Install Vercel CLI
npm install -g vercel
# Deploy
vercelDon't forget to:
- Initialize users database
- Set environment variables in Vercel
- Generate secure NEXTAUTH_SECRET
- Update NEXTAUTH_URL to production domain
- Full access to all features
- Create/update/delete users
- View and export all leads
- Access to admin panel
- View leads dashboard
- Search and filter leads
- Export data to Excel
- No user management access
POST /api/auth/signin- LoginPOST /api/auth/signout- Logout
GET /api/users- List all usersPOST /api/users- Create userPUT /api/users- Update userDELETE /api/users?id=X- Delete user
GET /api/leads- Get leads (paginated)GET /api/leads/export- Export to ExcelGET /api/stats- Dashboard statistics
GitHub Actions runs scraper:
- Daily at 13:00 UTC (4:00 PM Azerbaijan Time)
- Manual trigger available via GitHub Actions UI
- Next.js 14 (App Router)
- TypeScript
- Tailwind CSS
- NextAuth.js (Authentication)
- XLSX (Excel export)
- Python 3.11
- aiohttp (Async HTTP)
- BeautifulSoup + lxml (HTML parsing)
- PostgreSQL (psycopg2)
- Docker
- Vercel (Frontend hosting)
- Neon Tech (PostgreSQL)
- GitHub Actions (Automation)
- Telegram Bot (Notifications)
id, phone_number (unique), source_url, scraped_atid, username (unique), password_hash, role, is_active, created_at, last_loginid, user_id, session_token, expires, created_atFor automated scraping:
DATABASE_URL- PostgreSQL connection stringTELEGRAM_BOT_TOKEN- Bot token from @BotFatherTELEGRAM_CHAT_ID- Chat/group ID(s) for notifications
# Frontend
npm install
# Backend
cd scraper
pip install -r requirements.txt# Test scraper locally
cd scraper
python main.py
# Test Telegram notifications
python scripts/telegram.pycd scraper
python scripts/get_chat_id.py- Verify DATABASE_URL is correct
- Check SSL mode is enabled
- Ensure database accepts connections
- Verify NEXTAUTH_SECRET is set
- Check NEXTAUTH_URL matches current domain
- Clear browser cookies
- Check phone validation rules
- Verify website structure hasn't changed
- Review GitHub Actions logs
Proprietary - All rights reserved
For issues and questions, contact the development team.