A full-stack application for tracking, analyzing, and visualizing layoff data across companies. Built with React, Node.js, and Python, this project combines real-time data scraping with interactive dashboards and notifications.
- Features
- Project Structure
- Prerequisites
- Setup & Installation
- Development
- Deployment
- API Endpoints
- Environment Variables
- Contributing
- License
- Real-time Layoff Data: Scrapes layoff data from multiple sources (Layoffs.fyi, RSS feeds)
- Interactive Dashboard: Visualize layoff trends with D3.js and Recharts
- Admin Interface: Manage data and view system metrics
- Alerts System: Get notifications for new layoff events
- Trend Analysis: Analyze layoff patterns by company, sector, and time period
- Deduplication: Smart deduplication of layoff records from multiple sources
- REST API: Comprehensive backend API for all data operations
layoff-tracker/
├── frontend/ # React + Vite + TypeScript frontend
│ ├── src/
│ │ ├── pages/ # Dashboard, Trends, Company, Admin, Alerts pages
│ │ ├── components/ # Reusable React components
│ │ ├── data/ # Mock data and utilities
│ │ ├── lib/ # Analytics and utilities
│ │ ├── App.tsx # Main app component
│ │ └── main.tsx # Entry point
│ ├── public/ # Static assets
│ └── package.json
│
├── backend/ # Node.js + Express API
│ ├── src/
│ │ ├── index.js # Express server setup
│ │ ├── data.js # Data layer
│ │ └── utils.js # Utility functions
│ ├── sql/
│ │ └── schema.sql # Database schema
│ └── package.json
│
├── scraper/ # Python data scraper & scheduler
│ ├── sources/
│ │ ├── layoffs_fyi.py # Scrapes layoffs.fyi
│ │ └── rss_feeds.py # Scrapes RSS feeds
│ ├── main.py # Scraper entry point
│ ├── scheduler.py # Job scheduling
│ ├── normalizer.py # Data normalization
│ ├── deduplicator.py # Duplicate removal
│ ├── notifier.py # Alert notifications
│ ├── requirements.txt # Python dependencies
│ └── README.md # Scraper-specific docs
│
├── .gitignore
├── vercel.json # Vercel deployment config
└── README.md # This file
- Node.js 18+ (for frontend and backend)
- Python 3.8+ (for scraper)
- npm 8+ or yarn 3+
- Git
- Database (MySQL/PostgreSQL - check schema.sql for requirements)
git clone https://github.com/saifmodan2006/Layoff_Tracker.git
cd layoff-trackercd frontend
npm install
npm run build # Build for production
# or
npm run dev # Start development server (http://localhost:5173)Frontend Dependencies:
- React 19.x
- Vite 8.x
- TypeScript 6.x
- D3.js for data visualization
- Recharts for charts
- React Router for navigation
- Tailwind CSS for styling
cd backend
npm install
npm start # Start Express server (default: http://localhost:3000)Backend Dependencies:
- Express 5.x
- JWT for authentication
- CORS for cross-origin requests
- Morgan for logging
- Helmet for security
- Zod for validation
- Rate limiting middleware
Create .env file in backend/:
PORT=3000
DATABASE_URL=your_database_connection_string
JWT_SECRET=your_jwt_secret_key
NODE_ENV=development
cd scraper
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
pip install -r requirements.txt
python main.py # Run scraper once
# or
python scheduler.py # Run with scheduled jobsPython Dependencies:
- feedparser for RSS parsing
- beautifulsoup4 for HTML scraping
- playwright for dynamic content scraping
Create .env file in scraper/:
SCRAPER_INTERVAL=3600 # Run every hour (seconds)
NOTIFICATION_EMAIL=your_email@example.com
cd frontend
npm run dev # Start Vite dev server with hot reload
npm run lint # Run ESLint
npm run build # Build for production
npm run preview # Preview production buildcd backend
npm run dev # Start with nodemon (if configured)
npm start # Start Node servercd scraper
python main.py # Run scraper once
python -m pytest # Run tests (if available)The frontend is configured to deploy automatically to Vercel when you push to the main branch.
Manual Deployment:
# From project root
npx vercel --prodConfiguration: vercel.json is already set up to:
- Install dependencies in
frontend/ - Run
npm run buildfrom the frontend - Serve the production build
Choose your preferred platform:
Heroku:
heroku create your-app-name
git push heroku mainRailway / Render / Fly.io:
# Follow platform-specific instructions
# Ensure DATABASE_URL and JWT_SECRET are set as environment variablesGoogle Cloud Scheduler + Cloud Run:
- Deploy scraper as a container
- Schedule runs hourly/daily
AWS Lambda + EventBridge:
- Package scraper as Lambda function
- Set CloudWatch Events to trigger
Local/VPS Cron:
# Add to crontab (every hour)
0 * * * * cd /path/to/scraper && python main.py >> /var/log/layoff-scraper.log 2>&1GET /api/layoffs- Get all layoff recordsGET /api/layoffs/:id- Get specific layoffPOST /api/layoffs- Create new record (admin)PUT /api/layoffs/:id- Update record (admin)DELETE /api/layoffs/:id- Delete record (admin)
GET /api/analytics/trends- Layoff trends over timeGET /api/analytics/by-company- Stats by companyGET /api/analytics/by-sector- Stats by sector
GET /api/admin/stats- System statisticsPOST /api/admin/import- Import dataGET /api/admin/logs- View system logs
See backend/README.md for complete API documentation.
VITE_API_URL=http://localhost:3000/api
PORT=3000
DATABASE_URL=postgresql://user:password@localhost:5432/layoffs
JWT_SECRET=your-secret-key-change-in-production
JWT_EXPIRY=7d
NODE_ENV=production
SCRAPER_INTERVAL=3600
NOTIFICATION_EMAIL=alerts@example.com
DB_HOST=localhost
DB_USER=scraperuser
DB_PASSWORD=password
DB_NAME=layoffs
# Create feature branch
git checkout -b feature/your-feature
# Make changes and commit
git add .
git commit -m "feat: add your feature"
# Push to GitHub
git push origin feature/your-feature
# Create Pull Request on GitHub
# After review and approval, merge to main- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Commit your changes:
git commit -m 'Add amazing feature' - Push to the branch:
git push origin feature/amazing-feature - Open a Pull Request
- Use TypeScript for frontend code
- Follow ESLint rules (run
npm run lint) - Write meaningful commit messages
- Add tests for new features (if applicable)
- Update documentation when adding features
cd frontend
npm ci # Clean install
npm run build # Rebuild- Check DATABASE_URL is correct
- Verify database is running
- Check port 3000 is not in use
# Check logs
tail -f /var/log/layoff-scraper.log
# Test scraper manually
python scraper/main.py --debugThis project is licensed under the MIT License - see LICENSE file for details.
For issues and questions:
- GitHub Issues: Report a bug
- GitHub Discussions: Ask a question
- Data sources: Layoffs.fyi, industry RSS feeds
- Built with React, Express.js, and Python
- Deployed on Vercel and cloud platforms