<div align="center">
  <h1>🗺️ WebGIS - Poverty Alleviation Information System</h1>
  <p><i>A Comprehensive Geographic Information System for Monitoring and Alleviating Poverty in Pontianak</i></p>

  ![Application Screenshot](Screenshot.png)

  <br />

  ![PHP](https://img.shields.io/badge/PHP-7.4+-777BB4?style=flat-square&logo=php&logoColor=white)
  ![MySQL](https://img.shields.io/badge/MySQL-Database-4479A1?style=flat-square&logo=mysql&logoColor=white)
  ![Leaflet](https://img.shields.io/badge/Leaflet.js-Mapping-199900?style=flat-square&logo=leaflet&logoColor=white)
  ![Vanilla JS](https://img.shields.io/badge/JavaScript-Vanilla-F7DF1E?style=flat-square&logo=javascript&logoColor=black)
</div>

<br />

## 🌟 Overview

**WebGIS** is an interactive, map-based web application specifically designed to visualize, manage, and analyze poverty data within the Pontianak region. By utilizing spatial data and socioeconomic indicators, the platform empowers local authorities and agencies to track poverty distributions, score households based on their living conditions, and efficiently manage the delivery of assistance.

## ✨ Key Features

### 🔐 Secure Role-Based Authentication
* **Role Management:** Tailored access for **Admin**, **Petugas** (Data Officer), and **Pimpinan** (Manager).
* **Robust Security:** Utilizes secure bcrypt password hashing and PHP session management with automatic timeouts.

### 📊 Real-Time Analytics Dashboard
* **Dynamic KPIs:** Instantly view the total number of households, average poverty scores, and intervention rates.
* **Granular Breakdown:** Access priority rankings, verification statuses, and detailed area-wise statistics.

### 🗺️ Advanced Spatial Data Management
* **Interactive Mapping:** Powered by **Leaflet.js**, featuring multiple togglable layers (Households, Roads, Parcels, Choropleth).
* **Intuitive Controls:** Drag-and-drop marker repositioning, advanced filtering, and point search functionalities.

### 📝 Comprehensive Household Tracking
* **Detailed Records:** Register households with comprehensive poverty assessments (income, employment, housing conditions).
* **Automated Scoring:** The system automatically computes Socioeconomic Scores (SKR), Geographic Accessibility Scores (SAG), and Intervention Priority Scores (SPI).

### 🎯 Verification & Assistance Monitoring
* **Field Verification:** Seamlessly record and track verification results from field officers.
* **Assistance Logistics:** Monitor the distribution of food, cash, health, and educational assistance with evidence tracking.

---

## 🚀 Quick Start Guide

### Prerequisites
* **PHP 7.4+**
* **MySQL Database** (Local server like XAMPP/Laragon or remote hosting)
* Modern Web Browser (Chrome, Firefox, Edge, Safari)

### Installation & Setup

1. **Clone or Download the Repository:**
   ```bash
   git clone https://github.com/yourusername/webgis-pontianak.git
   cd webgis-pontianak
   ```

2. **Database Configuration:**
   * Import `mysql_schema.sql` into your MySQL server.
   * Open `api/config.php` and update the database credentials to match your environment:
     ```php
     define('DB_HOST', 'localhost');
     define('DB_NAME', 'your_database_name');
     define('DB_USER', 'your_username');
     define('DB_PASS', 'your_password');
     ```

3. **Launch the Application:**
   * You can serve the application using a tool like XAMPP, or use PHP's built-in development server:
     ```bash
     php -S localhost:8000
     ```
   * Open your browser and navigate to `http://localhost:8000`.

4. **Default Login Credentials:**
   * **Email:** `admin@system.local`
   * **Password:** `admin123`

---

## 🏗️ System Architecture

The application follows a clean, decoupled architecture:

| Component | Technology | Description |
|-----------|------------|-------------|
| **Frontend** | HTML5, CSS3, JavaScript | Pure Vanilla JS for maximum performance and minimum dependency bloat. |
| **Maps** | Leaflet.js | OpenStreetMap-compatible library for robust spatial rendering. |
| **Backend** | PHP 7.4+ | Modular RESTful JSON APIs handling business logic. |
| **Database** | MySQL | Highly relational schema with foreign key constraints and geospatial awareness. |

---

## 🗄️ Database Structure

The MySQL database initializes automatically and features a normalized 11-table schema, including:
* `users`: Authentication and role definitions.
* `households` & `household_scores`: Core poverty data and computed intervention scores.
* `assistance_distributions` & `verification_logs`: Audit trails for field operations.
* `markers`, `roads`, `land_parcels`, `pontianak_areas`: Spatial and geospatial boundary data.

---