A full-stack web application for mapping and tracking wind farm news in Poland. The application combines web scraping, geospatial mapping, and real-time data visualization to provide insights into Poland's renewable energy sector.
- πΊοΈ Interactive Map: Leaflet-based map showing wind farm locations and news articles
- π° News Scraping: Automated scraping of Polish renewable energy news sources
- π Statistics Dashboard: Real-time statistics on wind farms and news coverage
- π³ Docker Support: Easy deployment with Docker Compose
- π REST API: FastAPI backend with comprehensive endpoints
- Python 3.11 with FastAPI
- PostgreSQL for data persistence
- SQLAlchemy ORM
- BeautifulSoup4 for web scraping
- Uvicorn ASGI server
- React 18 with TypeScript
- Vite build tool
- Leaflet for interactive maps
- Axios for API communication
WindNewsMapper/
βββ backend/
β βββ app/
β β βββ __init__.py
β β βββ main.py # FastAPI application
β β βββ models.py # Database models
β β βββ scraper.py # Web scraping logic
β β βββ api/
β β βββ __init__.py
β β βββ routes.py # API endpoints
β βββ requirements.txt
β βββ .env.example
β βββ Dockerfile
βββ frontend/
β βββ src/
β β βββ components/
β β β βββ Map.tsx # Leaflet map component
β β βββ App.tsx
β β βββ App.css
β β βββ main.tsx
β β βββ index.css
β βββ package.json
β βββ tsconfig.json
β βββ vite.config.ts
β βββ Dockerfile
βββ docker-compose.yml
βββ .gitignore
βββ README.md
- Python 3.11+
- Node.js 18+
- Docker and Docker Compose (optional, for containerized setup)
-
Clone the repository
git clone https://github.com/rabciak/WindResarcherAI.git cd WindResarcherAI -
Start all services
docker-compose up -d
-
Access the application
- Frontend: http://localhost:5173
- Backend API: http://localhost:8000
- API Documentation: http://localhost:8000/docs
-
Navigate to backend directory
cd backend -
Create virtual environment
python3 -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies
pip install -r requirements.txt
-
Configure environment variables
cp .env.example .env # Edit .env with your database credentials -
Run the backend server
uvicorn app.main:app --reload --host 0.0.0.0 --port 8000
-
Navigate to frontend directory
cd frontend -
Install dependencies
npm install
-
Configure environment variables
cp .env.example .env # Edit .env if needed -
Start development server
npm run dev
If not using Docker, you'll need to set up PostgreSQL manually:
# Install PostgreSQL (Ubuntu/Debian)
sudo apt-get install postgresql postgresql-contrib
# Create database
sudo -u postgres psql
CREATE DATABASE windnewsdb;
CREATE USER winduser WITH PASSWORD 'windpass';
GRANT ALL PRIVILEGES ON DATABASE windnewsdb TO winduser;
\qGET /api/news- Get all news articlesGET /api/news/{id}- Get specific news articlePOST /api/news/scrape- Trigger news scraping
GET /api/wind-farms- Get all wind farmsGET /api/wind-farms/{id}- Get specific wind farmPOST /api/wind-farms- Create new wind farm entry
GET /api/map-data- Get combined data for map visualizationGET /api/stats- Get statisticsGET /health- Health check
- Access the application at http://localhost:5173
- Click "Scrape Latest News" to fetch recent articles from Polish renewable energy news sources
- Explore the map to see wind farm locations (green markers) and news locations (blue markers)
- Click on markers to view detailed information
The application scrapes news from:
- gramwzielone.pl
- wysokienapiecie.pl
- wnp.pl
Edit backend/app/scraper.py and add a new scraping method:
def scrape_new_source(self) -> List[Dict]:
# Implement scraping logic
passThen add it to scrape_all() method.
cd backend
alembic revision --autogenerate -m "Description"
alembic upgrade headDATABASE_URL=postgresql://winduser:windpass@localhost:5432/windnewsdb
CORS_ORIGINS=http://localhost:5173,http://localhost:3000
DEBUG=True
LOG_LEVEL=INFO
VITE_API_URL=http://localhost:8000
# Check what's using the port
lsof -i :5173 # or :8000
# Kill the process or change the port in configuration- Ensure PostgreSQL is running
- Check DATABASE_URL in backend/.env
- Verify database credentials
- Check browser console for errors
- Verify VITE_API_URL is set correctly
- Ensure backend is running and accessible
We welcome contributions! Please read our Contributing Guidelines before submitting a Pull Request.
- Fork the repository on GitHub
- Clone your fork:
git clone https://github.com/YOUR_USERNAME/WindResarcherAI.git cd WindResarcherAI - Create a feature branch:
git checkout develop git checkout -b feature/your-feature-name
- Make your changes following our Code Style Guidelines
- Commit using Conventional Commits:
git commit -m "feat: add your feature description" - Push and create a Pull Request:
git push origin feature/your-feature-name
See CONTRIBUTING.md for detailed guidelines.
We use Git Flow for our branching strategy:
main- Production-ready code (deploys to windnews.rabciak.site)develop- Development branch (deploys to dev.windnews.rabciak.site)feature/*- New features (branch fromdevelop)bugfix/*- Bug fixes (branch fromdevelop)hotfix/*- Urgent production fixes (branch frommain)
# Start from develop
git checkout develop
git pull origin develop
# Create feature branch
git checkout -b feature/add-news-filtering
# Work on your feature, commit changes
git add .
git commit -m "feat: add news filtering by category"
# Push and create PR to develop
git push origin feature/add-news-filteringSee DEPLOYMENT.md for detailed workflow and deployment instructions.
We use Conventional Commits:
feat:- New featurefix:- Bug fixdocs:- Documentation changesstyle:- Code formattingrefactor:- Code restructuringtest:- Adding testschore:- Maintenance tasks
Examples:
git commit -m "feat(backend): add pagination to news endpoint"
git commit -m "fix(frontend): resolve map marker positioning bug"
git commit -m "docs: update API documentation"Every push and pull request triggers automated checks:
- β Linting - Python (flake8, black) and TypeScript (ESLint)
- β Tests - Backend tests with pytest
- β Build - Docker images for backend and frontend
- π Deploy - Automatic deployment to development/production
Before submitting a PR:
Backend:
cd backend
# Format code
black app/
isort app/
# Lint
flake8 app/ --max-line-length=120
# Run tests
pytest tests/ -vFrontend:
cd frontend
# Lint
npm run lint
# Build
npm run build- URL: https://dev.windnews.rabciak.site
- Deploys: Automatically on push to
developbranch - Purpose: Testing and staging
- URL: https://windnews.rabciak.site
- API: https://api.windnews.rabciak.site
- Deploys: Manually from
mainbranch - Purpose: Live production environment
For detailed deployment instructions, see DEPLOYMENT.md.
Development:
./scripts/deploy-dev.shProduction:
./scripts/deploy-prod.sh- README.md - This file, project overview and setup
- CONTRIBUTING.md - Contributing guidelines and code style
- DEPLOYMENT.md - Deployment and workflow documentation
- claude.md - Comprehensive project context for AI assistance
This project is licensed under the MIT License.
- GitHub: https://github.com/rabciak/WindResarcherAI
- Issues: https://github.com/rabciak/WindResarcherAI/issues
- OpenStreetMap - Map tiles and geocoding
- Leaflet - Interactive mapping library
- FastAPI - Modern Python web framework
- React - Frontend UI library
Note: This application is designed for educational and research purposes. Please respect the robots.txt and terms of service of the websites being scraped.