# Auto-LLD QC

**Auto-LLD QC** is a web-based spatial quality control (QC) tool designed to automate verification checks for fiber network designs. It connects to a PostGIS database and enables users to filter data by market and zone, then run various spatial QC checks via a clean map interface.

## 🗺️ What It Does

- Allows users to select a **market** and **zone** from dropdowns to load relevant data.
- Displays map data using **Leaflet.js** and **Turf.js**.
- Enables multiple QC operations via user-triggered buttons:
  - **Graph connectivity** — ensures all segments are spatially connected.
  - **Single-span check** — validates that each segment has exactly two vertices.
  - **Underground termination check** — verifies underground segments end at a pole or handhole.
  - **Site presence and location** — confirms that sites exist and fall within the correct zone.

## 🧰 Tech Stack

- **Frontend:** HTML, CSS, JavaScript, [Leaflet.js](https://leafletjs.com/), [Turf.js](https://turfjs.org/)
- **Backend:** [Go (Golang)](https://golang.org/) with [Gin](https://github.com/gin-gonic/gin)
- **Database:** PostgreSQL with PostGIS extension
- **Deployment target:** Web application (self-hosted or internal use)

---

## 📂 Project Structure

```text
auto-lld-qc/
├── frontend/
│   ├── index.html
│   ├── main.js
│   └── styles.css
├── backend/
│   ├── main.go
│   ├── .env
│   ├── go.mod / go.sum
│   ├── models/
│   │   └── models.go
│   └── qc/
│       ├── graph_connect.go
│       ├── handholes.go
│       └── segment_single_span.go
⚙️ Setup & Usage
Prerequisites
Go 1.20+

PostgreSQL + PostGIS

Node.js (optional, for frontend bundling or tooling)

1. Clone the repo
bash
Copy
Edit
git clone https://github.com/yourusername/auto-lld-qc.git
cd auto-lld-qc
2. Configure environment
In backend/.env, set the following variables:

env
Copy
Edit
DB_HOST=your-db-host
DB_PORT=5432
DB_USER=your-user
DB_PASSWORD=your-password
DB_NAME=your-db
3. Run the backend
bash
Copy
Edit
cd backend
go run main.go
4. Open the frontend
Open frontend/index.html in a browser (or serve via a static file server like http-server or Gin).

✅ QC Features (Complete & Planned)
Feature	Status
Graph connectivity check	✅ Done
Segment single-span (2 vertices)	✅ Done
Handhole/Pole connection check	✅ Done
Site existence + zone inclusion	⏳ Planned
Permit validation	⏳ Planned
Access point location validation	⏳ Planned

📌 To-Do
 Complete remaining QC features (site checks, permits, access points)

 Add UI loading indicators and error handling

 Optionally dockerize for easier deployment

 Write unit tests for backend QC logic

🧑‍💻 Developer Notes
Uses GORM for Go/Postgres ORM modeling.

Turf.js handles spatial logic like intersections and geometry analysis on the frontend.

Each QC module is implemented in a separate .go file under /qc, with a dedicated API route.

Modular structure allows for easy addition of new QC checks.

📃 License
MIT License