# alexanderthebored/zone-lens architecture

> Architecture diagram of the GitHub repository alexanderthebored/zone-lens, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-02-05). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/alexanderthebored/zone-lens
- Repository: https://github.com/alexanderthebored/zone-lens

## Overview

##### 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)

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Browser (Front-end)"
        direction TB
        IE["UI Shell\nindex.html"]:::frontEnd
        CSS["Styling\nstyles.css"]:::frontEnd
        APP["Map & UI Logic\napp.js"]:::frontEnd
        MAPBOX["Map Engine\nMapbox GL JS"]:::frontEnd
        UIC["UI Controls"]:::frontEnd
        CHATW["Chatbot Widget"]:::frontEnd

        subgraph "Data Sources"
            direction TB
            ZONE["Zoning GeoJSON Source\nmandaue-data.js"]:::dataSrc
            FLOOD["Flood GeoJSON Source\nflood-data.js"]:::dataSrc
            PROTO["Prototype GeoJSON File\nMandaue_Map_V2.geojson"]:::dataSrc
        end
    end

    MBT["Mapbox Tiles & Styles API"]:::external
    MBG["Mapbox Geocoding API"]:::external
    BELA["BelaBot Backend API"]:::external

    subgraph "Project Documentation & Metadata"
        direction TB
        DOC1["Chatbot Manual\nchatbot_manual.md"]:::frontEnd
        DOC2["README.md"]:::frontEnd
        DOC3["ToDoList.txt"]:::frontEnd
        ARCH["Old Versions/"]:::frontEnd
    end

    APP -->|"loads map engine"| MAPBOX
    APP -->|"loads zoning data"| ZONE
    APP -->|"loads flood data"| FLOOD
    APP -->|"loads prototype data"| PROTO
    UIC -->|"toggle/filter control"| APP
    APP -->|"requests tiles & styles"| MBT
    UIC -->|"search input"| MBG
    CHATW -->|"send message"| BELA
    BELA -->|"response + map commands"| CHATW

    subgraph "Legend"
        L1["Blue: Front-end modules"]:::frontEnd
        L2["Green: Data sources"]:::dataSrc
        L3["Orange: External APIs"]:::external
    end

    classDef frontEnd fill:#D0E8FF,stroke:#0366D6,color:#0366D6
    classDef dataSrc fill:#DFFFD6,stroke:#2E8B57,color:#2E8B57
    classDef external fill:#FFE4B5,stroke:#FF8C00,color:#FF8C00

    click IE "https://github.com/alexanderthebored/zone-lens/blob/main/index.html"
    click CSS "https://github.com/alexanderthebored/zone-lens/blob/main/styles.css"
    click APP "https://github.com/alexanderthebored/zone-lens/blob/main/app.js"
    click ZONE "https://github.com/alexanderthebored/zone-lens/blob/main/mandaue-data.js"
    click FLOOD "https://github.com/alexanderthebored/zone-lens/blob/main/flood-data.js"
    click PROTO "https://github.com/alexanderthebored/zone-lens/blob/main/Mandaue_Map_V2.geojson"
    click DOC1 "https://github.com/alexanderthebored/zone-lens/blob/main/chatbot_manual.md"
    click DOC2 "https://github.com/alexanderthebored/zone-lens/blob/main/README.md"
    click DOC3 "https://github.com/alexanderthebored/zone-lens/blob/main/ToDoList.txt"
    click ARCH "https://github.com/alexanderthebored/zone-lens/tree/main/Old Versions/"
```
