dragndrop_hld/oldqc/CLAUDE.md

64 lines
2.6 KiB
Markdown
Raw Normal View History

# CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
## Project Overview
Auto-LLD QC is a web-based spatial quality control tool for fiber network designs. It connects to a PostGIS database to run automated QC checks on network segments through a map interface.
## Commands
### Backend Development
```bash
cd Backend
go run main.go # Start the server (default port 8080)
go mod tidy # Clean up dependencies
```
### Frontend Development
- Frontend is static HTML/CSS/JavaScript served from `Frontend/` directory
- Open `Frontend/index.html` in browser or use static file server
- Backend serves frontend at root path when running
## Architecture
### Backend Structure (Go + Gin)
- **main.go**: Main server setup, database connection, API routes
- **models/models.go**: GORM database models for segments, sites, poles, access points
- **qc/**: Quality control modules (graph_connect.go, handholes.go, segment_single_span.go)
- **db/connect.go**: Database connection utilities
### Frontend Structure
- **index.html**: Main UI with market/zone dropdowns and QC control buttons
- **main.js**: JavaScript handling map display (Leaflet), API calls, QC operations
- **styles.css**: UI styling
### Database Integration
- Uses PostGIS spatial database with configurable schema/table names
- Environment variables in `.env` control database connection and table configuration
- Key tables: segments (main data), sites, poles, access_points, map_projects
### API Endpoints
- `/api/markets` - Get available market/project options
- `/api/zones` - Get zones for selected market
- `/api/segments` - Get segment data as GeoJSON
- `/api/sites`, `/api/poles`, `/api/access_points` - Get spatial features
- `/api/qc/*` - QC check endpoints (connectivity, single-span, etc.)
### QC Module Pattern
Each QC check follows this pattern:
1. Separate Go file in `/qc` directory
2. Route registration function called from main.go
3. Returns GeoJSON FeatureCollection of affected segments
4. Updates `qc_flag` column to mark issues
### Environment Configuration
Backend uses environment variables for database connection and table/column names:
- DB_HOST, DB_PORT, DB_USER, DB_PASS, DB_NAME
- SCHEMA_NAME, SEGMENT_TABLE, ZONE_COLUMN, MAPID_COLUMN, etc.
- SERVER_PORT for web server port
### Key Technologies
- **Backend**: Go 1.24+, Gin web framework, GORM ORM, PostGIS
- **Frontend**: Vanilla JavaScript, Leaflet.js for maps, Turf.js for spatial operations
- **Database**: PostgreSQL with PostGIS extension