Skip to content

R-zin/Public-Infrastructure-Monitoring

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Kerala Infrastructure Monitoring

A web application that monitors public infrastructure issues in Kerala by analyzing news articles from the Onmanorama RSS feed using AI.

Features

  • RSS Feed Scraping: Automatically fetches news from Onmanorama RSS feed and NDTV.
  • AI Analysis: Uses Grok-Fast (via OpenRouter API) to analyze articles and extract:
  • Summary of the issue
  • Severity level (Low, Medium, High)
  • Location (district, city, or area)
  • Caching: Reduces API calls by caching analysis results
  • Modern UI: Beautiful React frontend with filtering and severity indicators
  • FastAPI Backend: High-performance async backend

Project Structure

.
├── backend/
│   ├── main.py              # FastAPI application
│   ├── requirements.txt     # Python dependencies
│   ├── .env.example         # Environment variables template
│   └── .gitignore
├── frontend/
│   ├── src/
│   │   ├── App.js           # Main React component
│   │   ├── App.css          # Styles
│   │   ├── index.js         # React entry point
│   │   └── index.css        # Global styles
│   ├── public/
│   │   └── index.html       # HTML template
│   └── package.json         # Node dependencies
└── README.md

Setup Instructions

Backend Setup

  1. Navigate to the backend directory:

    cd backend
  2. Create a virtual environment (recommended):

    python -m venv venv
    source venv/bin/activate  # On Windows: venv\Scripts\activate
  3. Install dependencies:

    pip install -r requirements.txt
  4. Create a .env file and add your OpenRouter API key:

    cp .env.example .env
    # Edit .env and add your OPENROUTER_API_KEY
  5. Get your OpenRouter API key:

  6. Run the backend server:

    uvicorn main:app --reload

    The API will be available at http://localhost:8000

Frontend Setup

  1. Navigate to the frontend directory:

    cd frontend
  2. Install dependencies:

    npm install
  3. Start the development server:

    npm start

    The app will open at http://localhost:3000

API Endpoints

GET /

Health check endpoint.

GET /scrape

Fetches and parses the RSS feed from Onmanorama. Returns raw RSS items with title, link, pubDate, and description.

POST /analyze

Analyzes an article description using Grok-Fast AI. Request body:

{
  "description": "Article description text"
}

Response:

{
  "summary": "Brief summary of the issue",
  "severity": "High",
  "location": "Kochi"
}

GET /news

Returns analyzed news items with infrastructure issues. Response:

{
  "items": [
    {
      "title": "Bridge collapse in Idukki",
      "summary": "Partial collapse due to heavy rain",
      "severity": "High",
      "location": "Idukki",
      "link": "https://www.onmanorama.com/...",
      "pubDate": "2025-01-09"
    }
  ],
  "count": 10
}

Usage

  1. Start the backend server (port 8000)
  2. Start the frontend server (port 3000)
  3. Open your browser to http://localhost:3000
  4. Click "Refresh News" to fetch and analyze the latest infrastructure issues
  5. Use the filter buttons to view issues by severity level

Caching

The backend caches analysis results in a cache.json file. This reduces API calls and speeds up subsequent requests for the same articles.

Technologies Used

  • Backend: FastAPI, httpx, feedparser
  • Frontend: React, Axios
  • AI: Grok-Fast (via OpenRouter API)
  • Styling: CSS3 with modern design patterns

Notes

  • Make sure you have an active internet connection to fetch RSS feeds
  • The OpenRouter API key is required for AI analysis
  • The first run may take longer as it analyzes all articles
  • Subsequent runs will be faster due to caching

License

MIT

About

A simple Webservice that takes RSS feeds from News outlets and searches specifically for issues related to public infrastructures.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors