# NANDA VENTURES — Satellite Plot Availability Demo

A complete, working demonstration website for a **fictional** real-estate developer based in Bhogapuram, Andhra Pradesh, India.

> **Important:** NANDA VENTURES, all projects, every plot, survey number, dimension, price, availability status, distance reference and photograph caption are **fictional demonstration data**. Nothing here is a real, approved, sanctioned, available, offered or legally verified property. Photography is illustrative stock imagery.

---

## 1. What is included

- Premium responsive homepage with hero, About, Projects, Gallery, Amenities, Locations, FAQs, Contact and an **intentionally empty LIVE PLOT STATUS** section.
- **Satellite-only plot availability** at `plot-availability.html`:
  - Google satellite imagery behind real GeoJSON plot boundaries
  - one tab per layout folder in root `plots-layouts/`
  - combined **All Imported Layouts** view
  - roads layer, plot/edge labels, search, status filters and plot detail panel
  - distinct colours for `Available`, `Reserved`, `Booked`, `Hold`, `Sold` and `Unavailable`
  - blinking coloured `NEW ✦` labels on layouts marked `isNew`
- Project detail page (`project.html`) with overview, gallery, amenities, location and enquiry. The old SVG Plot Explorer has been removed.
- The same top navigation — Home, Projects, Amenities, Satellite Plot Status (blinking NEW ✦), Locations and Contact — appears on every page.
- Zero-dependency Node scripts for local serving, JSON validation, folder discovery and automatic rebuilds.
- Optional `layouts.php` live discovery for PHP hosting (Hostinger): upload or delete a layout folder and the website reflects it with no build step.

---

## 2. Quick start

Requirements: **Node.js 18 or newer**. No packages need to be installed.

Open two terminals in the `NANDA-VENTURES` folder:

```bash
# Terminal 1 — local website server
node scripts/serve.js
# open http://localhost:4173

# Terminal 2 — watcher (rebuilds data whenever layout folders change)
node scripts/watch-plots.js
```

On Windows, if `npm.ps1` is blocked, use `npm.cmd`:

```bash
npm.cmd run serve
npm.cmd run watch
```

One-time build without the watcher:

```bash
node scripts/build-index.js
node scripts/build-satellite-layouts.js
# or: npm.cmd run build
```

> Always use the local server (`http://localhost:4173`). Browsers block local JSON fetches from `file://`.

Open the satellite plot system at:

```text
http://localhost:4173/plot-availability.html
```

### On Hostinger / PHP hosting

No watcher is needed. Upload the whole `NANDA-VENTURES` folder to the site root. `layouts.php` scans `plots-layouts/<folder>/` live:

- upload a folder containing `plots.geojson` → new tab appears
- delete that folder → tab disappears
- no HTML, JavaScript, manifest or build step is required

An open Satellite Plot Status tab checks `layouts.php` every 4 seconds. `UPDATE-LAYOUTS.bat` and the Node watcher are only for local/offline copies.

---

## 3. The satellite plot system

### Add a layout

Copy the included template and add your files:

```text
plots-layouts/
├── _TEMPLATE/                 IGNORED — copy this
│   ├── README.txt
│   ├── layout.json
│   ├── plots.geojson
│   └── roads.geojson
├── layout-1/
│   ├── layout.json
│   ├── plots.geojson
│   └── roads.geojson          optional
├── layout-2/
│   ├── layout.json
│   └── plots.geojson
└── manifest.json              GENERATED — do not hand-edit
```

1. Copy `_TEMPLATE` to a new folder, for example `plots-layouts/phase-a`.
2. Replace `layout.json` and `plots.geojson`. Add `roads.geojson` if needed.
3. Save.

The folder name becomes the layout id. Folders starting with `_` or `.` are ignored. You do **not** need to edit any HTML or JavaScript.

**Hosted with PHP (Hostinger):** step 3 is enough. `layouts.php` finds the folder on the next request.

**Local demo:** double-click `UPDATE-LAYOUTS.bat`, or keep `node scripts/watch-plots.js` running. This regenerates:

- `plots-layouts/manifest.json`
- `assets/js/satellite-plots-data.js`

### Remove a layout

Delete its folder. On PHP hosting the tab disappears on the next page load or poll. Locally, the watcher or `UPDATE-LAYOUTS.bat` rebuilds the generated files. Invalid JSON never removes the previous valid data.

### Automatic refresh in an open tab

The open tab polls whichever source is active:

- **PHP hosting:** `layouts.php` — a true live folder scan
- **Local demo / static hosting:** `plots-layouts/manifest.json`

Every 4 seconds:

- the active source is re-read
- added, removed or edited folders change its stamp
- the page re-discovers layouts and redraws automatically
- an empty response from `layouts.php` is respected, so a stale manifest is never used when every folder was deleted
- the currently selected layout id is preserved through the URL hash; if that layout was removed, the page falls back to the first available layout

A small toast confirms: **“Layouts updated automatically from plots-layouts.”**

---

## 4. `layout.json`

```json
{
  "name": "Demo Layout 4",
  "layoutId": "LYT004",
  "order": 4,
  "sheetCsvUrl": "",
  "isNew": true,
  "note": "Optional note"
}
```

| Field | Meaning |
|---|---|
| `name` | Tab label. Defaults to a title-cased folder name. |
| `layoutId` | Your own layout code (`LYT004`, `PHASE-A`, etc.). |
| `id` | Optional stable id. The folder name is used by default. |
| `order` | Lower numbers appear first. |
| `sheetCsvUrl` | Optional read-only Google Sheet CSV URL. Left blank in this demo. |
| `isNew` | Shows the blinking coloured `NEW ✦` badge on the tab. |
| `note` | Optional preserved note. |

---

## 5. `plots.geojson`

Use a standard GeoJSON `FeatureCollection` in EPSG:4326 (longitude / latitude). Each feature is one plot and must have `Polygon` or `MultiPolygon` geometry.

```json
{
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "id": "LYT004-P001",
      "geometry": {
        "type": "Polygon",
        "coordinates": [[
          [83.47966, 17.95955],
          [83.47966, 17.95945],
          [83.47949, 17.95945],
          [83.47949, 17.95955],
          [83.47966, 17.95955]
        ]]
      },
      "properties": {
        "plot_id": "LYT004-P001",
        "plot_no": "1",
        "status": "AVAILABLE",
        "area_sqft": 2230.18,
        "area_sqyd": 247.8,
        "facing": "North",
        "road_width_ft": 30,
        "price": 4800000
      }
    }
  ]
}
```

### Status values

Canonical values and colours:

| Status | Colour |
|---|---|
| `Available` | Green |
| `Reserved` | Gold |
| `Booked` | Purple |
| `Hold` / `ON HOLD` | Orange |
| `Sold` | Red |
| `Unavailable` | Grey |

Availability is read from each feature’s `status` property. Common aliases are understood, and unknown values fall back to `Unavailable` while the original value is preserved in the source attributes.

### Measurements

Boundary lengths are measured from the drawn geometry in **UTM 44N** so N/E/S/W feet labels stay consistent. Area, facing, road width, price and any extra original properties are retained.

### `roads.geojson`

Optional. It uses the same GeoJSON structure. Road features are drawn as a light layer behind plots and are never counted as plots.

---

## 6. Google satellite imagery

The basemap is configured in `assets/js/satellite-plots-config.js`:

```js
imageryUrl: 'https://mt1.google.com/vt/lyrs=s&x={x}&y={y}&z={z}',
imageryAttribution: 'Imagery © Google',
imageryNativeMaxZoom: 19
```

The imagery needs an internet connection. Plot boundaries, labels, status colours and details are drawn from the bundled GeoJSON and continue to work if tiles fail to load.

> This direct tile URL is suitable for the fictional demo only. For a public launch, replace it with an appropriately licensed Google Maps API implementation and follow Google’s attribution and usage requirements.

To change the refresh interval or discovery sources, edit the same config file:

```js
manifestPollMs: 4000,
layoutsEndpoint: 'layouts.php',
layoutsManifest: 'plots-layouts/manifest.json'
```

`layoutsEndpoint` is tried first on HTTP/HTTPS. If PHP is unavailable, the viewer silently falls back to `layoutsManifest`.

---

## 7. Validation safety

Builds are **all-or-nothing**:

- invalid JSON or GeoJSON exits with code `1`
- a precise file name, line and column are printed
- `plots-layouts/manifest.json` and `assets/js/satellite-plots-data.js` are **not overwritten**
- the last valid generated files keep the website working

Generated files are written atomically, so a browser never reads a half-written manifest.

---

## 8. Pages and navigation

| File | Purpose |
|---|---|
| `index.html` | Homepage, projects, gallery, location, FAQs, contact, empty Live Plot Status |
| `project.html` | Sample project detail page; no SVG explorer |
| `plot-availability.html` | The only plot explorer — Google satellite + folder layouts |
| `assets/css/style.css` | Shared design system, navigation, brand and footer |
| `assets/css/satellite-plots.css` | Satellite workspace styling |
| `layouts.php` | Live PHP folder discovery for Hostinger/PHP hosting |
| `UPDATE-LAYOUTS.bat` | Windows one-step local refresh (double-click) |
| `assets/js/satellite-plots.js` | Map engine, layout discovery, active-source polling |
| `assets/js/satellite-plots-config.js` | Imagery, discovery sources and refresh settings |
| `assets/js/satellite-plots-data.js` | GENERATED inline fallback data |
| `scripts/build-satellite-layouts.js` | Root layout folder builder |
| `scripts/build-index.js` | Builds project card data from `data/projects/` |
| `scripts/watch-plots.js` | Watches both data systems and rebuilds them |
| `scripts/serve.js` | Zero-dependency localhost static server |

The old `assets/js/plot-explorer.js` file has been removed. The legacy per-project `data/projects/<project>/plots-layouts/` folders are no longer shown anywhere in the UI; the satellite page reads only root `plots-layouts/`. They are retained only because `build-index.js` still derives sample project card statistics from them.

---

## 9. LIVE PLOT STATUS

The homepage `#live-status` section is intentionally empty. It contains only:

- the title `LIVE PLOT STATUS`
- the sentence `Real-time plot availability and project updates.`
- a blinking coloured `NEW ✦` label

No sample plots or fake availability are placed there.

---

## 10. Contact configuration

Edit `assets/js/config.js` if needed:

```js
window.NV_CONFIG = Object.freeze({
  demoMode: true,
  whatsappNumber: '',
  phoneDisplay: '',
  email: '',
  enquiryEndpoint: '',
  mapEmbedUrl: '',
  brandName: 'NANDA VENTURES'
});
```

With empty values, buttons explain they are not configured. No fake phone number or email is invented. The enquiry form validates locally and sends data only when an `https://` endpoint is configured.

---

## 11. Troubleshooting

| Problem | Fix |
|---|---|
| Satellite page shows “No layouts found” | Check root `plots-layouts/` has folders containing `plots.geojson`; folder names must not start with `_` or `.`. On PHP hosting, confirm `layouts.php` is reachable. Locally, run `UPDATE-LAYOUTS.bat` or `npm.cmd run build:satellite`. |
| New layout folder not showing | Ensure the folder is directly inside `plots-layouts/` and has valid `plots.geojson`. On PHP hosting no build is needed. Locally, keep the watcher running or double-click `UPDATE-LAYOUTS.bat`. |
| Removed layout still shows | Delete the folder. On PHP hosting the next poll/page load removes it. Locally, run the watcher or `UPDATE-LAYOUTS.bat`. |
| Open tab does not refresh | Check `manifestPollMs` is not disabled. On PHP hosting confirm `layouts.php` returns JSON; locally confirm `node scripts/watch-plots.js` is running. |
| Google imagery is blank | Check the internet connection and that `imageryUrl` in `satellite-plots-config.js` is reachable. Boundaries and labels still work from local GeoJSON. |
| `NEW ✦` not blinking | Set `"isNew": true` in that layout’s `layout.json`, then save. |
| Build fails | Read the printed file name and line/column. Fix the JSON/GeoJSON and save again. Previous valid generated data is untouched. |
| Browser opened as `file://` | Use `http://localhost:4173`. |
| CSS/JS looks stale | The local server sends `Cache-Control: no-store`; hard-reload once if needed. |

---

## 12. Final reminder

This is a **fictional demonstration website**. Before adapting it for a real developer:

- replace all sample projects, plot data, survey numbers and photography with verified, licensed material
- add verified approvals, distances and legal disclaimers
- configure real contact details and a secure enquiry endpoint
- use a licensed Google Maps API implementation for satellite imagery
- have all property content reviewed for local advertising and legal compliance

---

## 14. Project pages and per-project Live Plot Status (v5)

- Home → **Our Projects** shows 3 projects. Each card has **View Project Details** and **Live Plot Status**.
- `project.html?project=project-0X` shows layout plan images, location photos, amenity photos, gallery and a **Live Plot Status** button (hero, sub-menu and a floating button on screen).
- `plot-availability.html?project=project-0X` opens that project's own layouts (Demo Layout 1, Demo Layout 2) from `data/projects/project-0X/plots-layouts/`. `#layout-1` / `#layout-2` opens a specific layout tab.
- Without `?project=` the page still shows the combined root `plots-layouts/` demo.
- Layout plan images are generated by `python3 scripts/render-layout-images.py` (needs matplotlib). Detail photos are listed under `detailMedia` in each `project.json`; then run `node scripts/build-index.js`.
