- TypeScript 84.2%
- CSS 15.4%
- HTML 0.4%
- open a town from the list or by clicking its map polygon - edit identity, dated events, population observations, and alternate names - reload simple Polygon boundaries into the drawing layer for editing - save edits with version-checked PATCH requests - replace the cramped sidebar form with a styled inspector panel |
||
|---|---|---|
| apps | ||
| .editorconfig | ||
| .gitignore | ||
| package.json | ||
| pnpm-lock.yaml | ||
| pnpm-workspace.yaml | ||
| README.md | ||
| tsconfig.base.json | ||
Dutch Map
A hand-curated atlas of Dutch towns. It currently includes a full-page MapLibre map of the Netherlands, a keyless vector basemap picker, a single-curator protected editor, a SQLite-backed town model, and a town inspector for creating, selecting, and editing places. Saved towns render on both the public and editor maps. Shared-border topology, multipart boundary editing, and data-driven map styling come next.
Stack
- Web — React 19, Vite, MapLibre GL JS, OpenFreeMap vector tiles (OSM data).
- Server — Fastify 5 + TypeScript.
- Storage — SQLite via better-sqlite3.
- Workspace — pnpm monorepo.
Layout
apps/
web/ React + Vite frontend
server/ Fastify API
Development
Requires Node 22.12+ and pnpm.
pnpm install
pnpm dev
The Vite dev server proxies /api to the API server, so the frontend always
talks to the same origin.
Scripts
| Command | Description |
|---|---|
pnpm dev |
Run web and API together |
pnpm dev:web |
Run the web app only |
pnpm dev:server |
Run the API only |
pnpm build |
Type-check and build both apps |
pnpm typecheck |
Type-check without emitting |
pnpm --filter @dutch-map/server hash-password "..." |
Generate an admin password hash |
Auth
The public map is anonymous. /editor is protected by a single-curator
password; there is no public sign-up.
Generate a hash:
pnpm --filter @dutch-map/server hash-password "your password"
Put it in apps/server/.env (gitignored):
ADMIN_PASSWORD_HASH=scrypt$...
Restart the API. Sessions are server-side, in memory, and last seven days; a server restart signs you out. Town data is stored in SQLite (see below).
Routes:
/— public map/login— curator sign-in/editor— protected editor with map drawing and town editing
Town model
Town data lives in apps/server/data/dutch-map.sqlite (gitignored; override
with DATABASE_PATH). Migrations run automatically on API startup.
Tables:
towns— identity, kind, status, GeoJSON geometry, centroid, notes, versiontown_names— alternate and historical names with languagetown_events— first mention, founding, city rights/title, dissolution, …population_observations— population counts over timetown_revisions— a full snapshot for every save
Geometry is validated as a GeoJSON Polygon or MultiPolygon with Turf, and a
centroid is computed when one is not supplied. Writes require the curator
session and use the town version for optimistic concurrency.
API:
| Method | Path | Access |
|---|---|---|
GET |
/api/towns |
public |
GET |
/api/towns.geojson |
public |
GET |
/api/towns/:id |
public |
POST |
/api/towns |
curator |
PATCH |
/api/towns/:id |
curator |
GET /api/towns.geojson returns the town features used by the map overlays.
The editor’s Add town flow draws a polygon on the map: click to add points,
click the first point to close, drag points to adjust, click an edge to insert,
and right-click a point to delete. New points snap to existing town vertices.
The form takes a name, kind, optional local term, status, and notes; saving
posts the polygon and refreshes both maps. Towns without geometry appear in the
editor list but not on the map yet.
Select a town in the list, or click its polygon while the editor is idle, to
open the inspector. It edits identity fields, dated history (first mention,
founding, city rights, city title, market rights, dissolution, and generic
events, each with a status, a year range, precision, and source), population
observations, and alternate/historical names with language and kind. Saves use
PATCH with the town’s current version; a stale editor gets a conflict
message instead of overwriting. A simple single-ring Polygon boundary loads
back into the drawing layer for editing. Multipart or holed boundaries are
read-only for now, with a notice in the inspector.
Shared-border topology, multipart boundary editing, and data-driven map styling are the next steps.
Notes
- The basemap is OpenFreeMap's public vector tile instance: free, keyless, and built from OpenStreetMap data. Attribution is required and is rendered by the map. For a high-traffic deployment, consider self-hosting OpenFreeMap or using a commercial tile provider.
- Basemap: switch between Positron, Bright, Liberty, Fiord, and Dark from the
bottom-left picker. Each thumbnail previews that style at the current map
center, and the choice is reflected in
?basemap=...so it can be deep-linked. - Auth is a single-curator password with an HttpOnly session cookie and login rate limiting. The editor can create, select, and edit towns, including history, population, and name records.
- Town data is SQLite-backed; auth sessions are still in memory, so an API restart signs you out but keeps towns.