A comprehensive web application for analyzing satellite nightlights data to understand economic growth, urbanization patterns, and regional development. Built with React and Flask, Quatsch provides interactive visualizations, anomaly detection, growth analysis, and year-over-year comparisons of nightlights data.
- Features
- Tech Stack
- Prerequisites
- Installation
- Configuration
- Usage
- Project Structure
- API Documentation
- Features in Detail
- Troubleshooting
- Contributing
- Real-time Nightlights Visualization: Explore nightlights data on an interactive Leaflet map
- Region Search: Search and select from 100+ regions worldwide
- Year Selection: View data for any year from 2016-2025
- Dynamic Heatmaps: Visualize brightness intensity with color-coded markers
- Contextual Insights: Get region-specific news, events, and information
- Economic Growth Metrics: Calculate GDP proxy, urban area expansion, and sector breakdown
- Time Series Analysis: Analyze growth trends over custom year ranges
- Interactive Charts: Visualize data with line graphs, bar charts, and sector breakdowns
- Growth Hotspots: Identify areas with the fastest development
- Year-over-Year Growth Rates: Track percentage changes across metrics
- Dark Zone Detection: Identify emerging dark zones indicating economic decline
- Anomaly Mapping: Visualize anomalies on interactive maps with detailed popups
- Latest Year Analysis: Automatically detects anomalies for the most recent available year
- Anomaly Context: Get insights about detected anomalies and their implications
- Side-by-Side Comparison: Compare nightlights data between any two years
- Image Blending: Interactive image blender with transparency control
- Pan & Zoom: Navigate and zoom into comparison images
- Comprehensive Metrics: View percentage changes, absolute differences, and sector breakdowns
- Visual Charts: Bar charts and stacked charts for easy comparison
- Email OTP Verification: Secure login with one-time password via email
- Session Management: Persistent sessions with secure cookies
- Protected Routes: Dashboard, Analysis, and Compare pages require authentication
- User-Friendly UI: Beautiful, modern authentication interface
- React 19.2.0 - UI framework
- React Router DOM 7.10.1 - Client-side routing
- Leaflet & React-Leaflet - Interactive maps
- Framer Motion - Animations and transitions
- Tailwind CSS - Styling
- Vite - Build tool and dev server
- Three.js & React Three Fiber - 3D globe visualization
- Flask 3.0.2 - Web framework
- Flask-CORS - Cross-origin resource sharing
- Flask-Session - Session management
- Rasterio - Geospatial raster I/O
- NumPy - Numerical computing
- SciPy - Scientific computing (image processing)
- Python-dotenv - Environment variable management
- Requests - HTTP library for external APIs
- TIF/TIFF File Processing - Satellite nightlights data
- Geospatial Data Extraction - Coordinate transformation
- Image Processing - Median filtering, anomaly detection
- JSON Serialization - Data format conversion
- Node.js (v18 or higher)
- Python (3.8 or higher)
- pip (Python package manager)
- npm or yarn (Node package manager)
- Gmail Account (for email OTP functionality)
- NewsAPI Key (optional, for enhanced insights)
git clone <repository-url>
cd Quatschcd backend
pip install -r app/requirements.txtcd frontend
npm installCreate a .env file in the backend directory:
# Email Configuration (Required for Authentication)
EMAIL_ADDRESS=your-email@gmail.com
EMAIL_PASSWORD=your-16-char-app-password
# Session Secret Key
SECRET_KEY=your-random-secret-key-here
# NewsAPI Key (Optional - for enhanced insights)
NEWS_API_KEY=your-newsapi-key-here- Go to Google Account Settings
- Enable 2-Step Verification if not already enabled
- Generate an App Password for "Mail"
- Copy the 16-character password
- Use it as
EMAIL_PASSWORDin your.envfile
- Visit NewsAPI.org
- Sign up for a free account
- Get your API key from the dashboard
- Add it to your
.envfile
Note: Free tier allows 100 requests per day. For production, upgrade to a paid plan.
Ensure your data is organized as follows:
backend/data/
├── raw/
│ ├── NightLights_Bright_<Region>/
│ │ └── VIIRS_*_<Year>_01.tif
│ └── ...
├── cleaned/
│ ├── NightLights_Bright_<Region>_cleaned/
│ │ ├── VIIRS_*_<Year>_01_clean.tif
│ │ └── VIIRS_*_<Year>_01_view.png
│ └── ...
└── anomalies/
└── ...
cd backend
python app/main.pyThe backend server will start on http://localhost:5000
cd frontend
npm run devThe frontend will be available at http://localhost:5173 or http://localhost:5174
- Login: Navigate to
/loginand enter your email - Verify OTP: Check your email for the OTP code and enter it
- Dashboard:
- Search for a region (e.g., "Tamil Nadu", "Maharashtra", "California")
- Select a year (2016-2025)
- View nightlights data on the interactive map
- Read contextual insights about the region
- Analysis:
- Select a region and year range
- Enable "Growth Analysis" to see economic metrics and charts
- Enable "Anomaly Detection" to identify dark zones
- Compare:
- Select a region and two years
- Use the image blender to compare visualizations
- View comprehensive comparison metrics
The application supports various regions including:
Indian States: Tamil Nadu, Maharashtra, Jharkhand, Uttar Pradesh, and more
US States: California, Texas, Florida, New York, and more
Countries: United States, India, China, and more
Continents: Europe, Asia, Africa, and more
Quatsch/
├── backend/
│ ├── app/
│ │ ├── main.py # Flask application entry point
│ │ ├── routes.py # API route definitions
│ │ ├── auth.py # Authentication logic
│ │ ├── tif_extractor.py # TIF file data extraction
│ │ ├── insights_service.py # Insights fetching service
│ │ ├── anomaly_service.py # Anomaly detection service
│ │ ├── growth_analysis_service.py # Growth analysis service
│ │ ├── comparison_service.py # Year comparison service
│ │ ├── cleaning.py # Data cleaning utilities
│ │ └── requirements.txt # Python dependencies
│ ├── data/
│ │ ├── raw/ # Raw TIF files
│ │ ├── cleaned/ # Processed TIF files and PNGs
│ │ └── anomalies/ # Anomaly detection results
│ └── sessions/ # Session storage
├── frontend/
│ ├── src/
│ │ ├── components/ # Reusable React components
│ │ ├── pages/ # Page components
│ │ │ ├── dashboard/ # Dashboard page
│ │ │ ├── analysis/ # Analysis page
│ │ │ ├── compare/ # Compare page
│ │ │ ├── auth/ # Authentication pages
│ │ │ └── about/ # About page
│ │ ├── context/ # React context providers
│ │ └── App.jsx # Main app component
│ ├── package.json # Node dependencies
│ └── vite.config.js # Vite configuration
└── README.md # This file
POST /api/auth/send-otp
Content-Type: application/json
{
"email": "user@example.com"
}POST /api/auth/verify-otp
Content-Type: application/json
{
"email": "user@example.com",
"otp": "123456"
}GET /api/auth/check-sessionGET /api/data/nightlights/<year>?region=<region_name>&sample_rate=<rate>GET /api/data/available-years?region=<region_name>GET /api/insights?region=<region_name>&year=<year>&max_results=<number>GET /api/analysis/anomalies?region=<region_name>GET /api/analysis/growth?region=<region_name>&start_year=<year>&end_year=<year>GET /api/analysis/available-regionsGET /api/compare?region=<region_name>&year1=<year>&year2=<year>GET /api/images/<path:filepath>Serves PNG images from the data/cleaned directory.
- Interactive map with Leaflet
- Real-time data visualization
- Region search with autocomplete
- Year selection dropdown
- Loading states and error handling
- Contextual insights panel
- GDP proxy calculation based on nightlights intensity
- Urban area estimation
- Sector breakdown (Rural, Urban, Industrial)
- Growth hotspots identification
- Multiple chart visualizations
- Year-over-year growth rate calculations
- Dark zone emergence detection algorithm
- Spatial anomaly identification
- Anomaly clustering and visualization
- Latest year automatic detection
- Detailed anomaly metadata
- Side-by-side image comparison
- Interactive transparency blending
- Pan and zoom functionality
- Comprehensive metrics comparison
- Visual chart representations
- Detailed comparison table
- Ensure backend is running before frontend
- Check that backend is on port 5000
- Verify CORS origins in
backend/app/main.pymatch your frontend port
- Verify Gmail App Password (not regular password)
- Ensure 2-Step Verification is enabled
- Check environment variables are set correctly
- Check spam folder
- Verify data files exist in
backend/data/directory - Check folder naming matches expected patterns
- Ensure TIF files are valid and readable
- Check backend console for error messages
- Ensure cookies are enabled in browser
- Check
backend/sessions/directory exists - Verify
SECRET_KEYis set in environment variables
- Check region name spelling
- Verify data folder exists for the region
- Ensure folder naming follows convention:
NightLights_Bright_<Region>orNightLights_Bright_<Region>_cleaned
Contributions are welcome! Please follow these steps:
- Fork the repository
- Create a feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
- Follow existing code style
- Add comments for complex logic
- Update documentation for new features
- Test thoroughly before submitting PR
- Ensure no linter errors
This project is licensed under the MIT License - see the LICENSE file for details.
- NASA for VIIRS nightlights data
- Leaflet for mapping capabilities
- React and Flask communities
- All contributors and users
For issues, questions, or contributions, please open an issue on the GitHub repository.
Built with ❤️ for analyzing Earth's nightlights and understanding economic growth patterns