# MTBStatus

Static working draft for MTBStatus - UK Trail Intel.

The prototype covers:

- UK MTB events calendar with category/search filtering.
- Trail centre and bike park opening/status cards.
- Local trails and hidden-gem seed records for later verification.
- Rules and rider information model.
- Hidden prototype admin page for manual trail edits, additional admin users, editable feed/scrape/check configuration, top-screen news bulletins and feed monitoring.

## Run

```bash
python3 -m http.server 8090
```

Then open:

```text
http://127.0.0.1:8090/
```

The home page is focused on trail status and closures. Events live on:

```text
http://127.0.0.1:8090/events.html
```

Prototype admin tools are intentionally not linked from the public navigation. Locally they live on:

```text
http://127.0.0.1:8090/admin.html
```

Use the fixed master account locally. Additional prototype admin accounts can be created from the admin portal. This is only a front-end prototype gate; production on the Abledev droplet needs server-side authentication, persisted database writes, password hashing and audit logging.

In production, route the admin portal only through:

```text
https://sadmin.mtbsesh.abledev.net/
```

Do not expose the admin route from the public `abledev.net` host.

The site is static, but use the local server for testing so downloads, links and browser automation behave consistently.

## Deployment Refresh

On the Abledev droplet, schedule the data ingestion job every 15 minutes. The job should update the persisted `lastRefresh` value after a successful run so the public `Last refreshed` marker reflects the latest completed refresh.

Suggested production flow:

1. Cron or systemd timer runs every 15 minutes.
2. Ingest trail status, venue notices, hidden-gem source changes, events, source configuration and source health.
3. Write normalized data and source run state to the production store.
4. Update the public refresh marker only after the write succeeds.

## Test

Install dependencies once:

```bash
npm install
```

Run the browser tests:

```bash
npm run test:e2e
```

Screenshots can be captured with:

```bash
npx playwright screenshot --full-page --viewport-size=1440,1000 http://127.0.0.1:8090 screenshots/full-page.png
```

## Next Build Steps

1. Replace seeded data in `script.js` with an API-backed feed.
2. Add a scraper/normaliser service that writes `events`, `venues`, `trail_statuses`, `rules`, and `source_runs`.
3. Replace the prototype admin gate with authenticated admin views for deduplication, source confidence, source configuration, manual entries and capped bulletins.
4. Add privacy/cookie pages if analytics, email alerts or saved searches are enabled.

See `DATA-SOURCES.md` for the ingestion plan.
