How alexanderthebored/zone-lens works
Project Type and Purpose
• Zone|Lens is a static, front-end Mapbox GL web application for visualizing Mandaue City zoning districts and flood-risk zones.
• It includes interactive map layers, search via Mapbox Geocoding, UI controls (toggles, filters, compass), and a BelaBot chatbot that speaks to a separate backend API.
File-Structure Analysis
Top-level files:
– index.html: main UI shell and control placeholders
– app.js: map initialization, GeoJSON sources (embedded zoning & flood data), layer logic, UI wiring, BelaBot integration
– mandaue-data.js / flood-data.js / Mandaue_Map_V2.geojson: raw data files (some prototyping leftovers)
– chatbot_manual.md: docs for chatbot commands
– Old Versions/: prior prototypes
– README.md, ToDoList.txt, CNAME: project metadata
No build pipeline—static files served directly.
Additional Insights from README
• Uses Mapbox GL JS for rendering, Mapbox Geocoding API for search.
• BelaBot requires an external “BACKEND_URL” for AI responses and map commands.
• Data currently embedded; recommended to externalize for production.
a. Main Components
1. Browser-based Front-End
– Mapbox GL JS engine
– BelaBot chatbot widget
2. Data Sources
– Embedded GeoJSON (zoning, flood risk)
– External static GeoJSON/Tile service (for production)
3. Third-Party Services
– Mapbox Tileserver & Styles API
– Mapbox Geocoding API
4. BelaBot Backend
– AI service endpoint for chat responses and map-control commands
b. Relationships & Data Flows
– Front-end initializes Mapbox GL with access token → loads base map tiles & style from Mapbox.
– Front-end loads embedded or external GeoJSON → renders as fill/outline layers.
– User toggles filters → front-end shows/hides layers.
– Search input → front-end calls Mapbox Geocoding API → pans/zooms map.
– Chatbot message → front-end sends to BelaBot backend → backend returns text + map commands → front-end executes (e.g., toggle layer, flyTo).
c. Architectural Patterns & Design Principles
– Single-page, event-driven front-end with clear separation: rendering vs. control logic vs. chat integration
– Data layer abstraction: GeoJSON as sources, easily switchable to remote APIs
– UI layer handles user interactions, delegates to map or backend
d. Key Technologies & Frameworks
• Mapbox GL JS (rendering, 3D terrain, buildings)
• Mapbox Geocoding API (address search)
• Vanilla JS (app.js) for wiring layers and UI
• BelaBot backend (custom AI API)