How ni5arga/sightline works
Purpose and Runtime
Sightline is a Next.js geospatial search application for discovering physical infrastructure in OpenStreetMap (OSM). It runs on Node.js 18+ and is deployable to Vercel; it has no required environment variables or owned database. The application relies on public Nominatim, Overpass, and OSM map-tile services.
Application Entry and Composition
The root layout and primary page compose the client experience and global styling:
• app/layout.tsx
• app/page.tsx
• app/globals.css
The page coordinates query state, selected results, filters, and interactions among the search input, list, map, asset details, and sharing controls.
Search Interaction Layer
User input begins in the query and filter UI, while results are presented in synchronized list and geographic views:
• components/SearchBar.tsx
• components/Filters.tsx
• components/ResultList.tsx
• components/MapView.tsx
Search requests cross the browser/server boundary through POST /api/search. MapView is the Leaflet-based visualization boundary; it renders returned asset geometry/locations rather than querying OSM directly. components/AssetInfoModal.tsx exposes per-asset details, and components/ShareButton.tsx shares application/search state.
Server API Boundary
The search orchestration endpoint is:
• app/api/search/route.ts
It accepts natural-language or structured criteria, drives parsing, geographic resolution, OSM retrieval, and caching, then returns normalized search results to the frontend. A separate proxy-style geocoding endpoint exists at:
• app/api/nominatim/route.ts
This separates browser callers from direct external geocoder access and centralizes integration behavior.
Query Interpretation and Domain Model
The query pipeline recognizes asset types, aliases, qualifiers such as operator and region, and proximity/radius syntax:
• lib/parser.ts
• lib/search-index.ts
• lib/types.ts
parser.ts converts raw user text into structured search intent. search-index.ts is the domain catalog/index supporting the broad infrastructure taxonomy. types.ts defines contracts shared across API, data-processing, and UI layers, making it the primary schema boundary for parsed queries and returned assets.
Geographic Resolution and OSM Retrieval
Location intent is resolved before asset retrieval:
• lib/geo.ts
• lib/overpass.ts
geo.ts calls Nominatim to turn place names into coordinates or bounding areas. overpass.ts maps parsed asset constraints and resolved geography into Overpass QL, calls the public Overpass API, and converts OSM elements into application results. External-data boundaries are material: Nominatim is subject to its 1 request/second policy, and Overpass supports read-only, fair-use queries; OSM completeness and accuracy are not guaranteed.
Caching and Operational Constraints
The backend uses process-local in-memory caching:
• lib/cache.ts
• app/api/search/route.ts
Cache reads/writes reduce repeat external calls but are not durable or shared across serverless instances, so behavior can vary after restart or across Vercel invocations. There is no authentication, persistence layer, background monitoring worker, or proprietary data source indicated by this repository. Linting is enforced in CI through .github/workflows/lint.yml.
Main entry points: page.tsx Search page · route.ts Search API · parser.ts Query parser · overpass.ts OSM retriever
Components 18
Next.js Client
- Search page · Coordinates query, selection, filters, results, map, and sharing state.
app/page.tsx - Root layout
app/layout.tsx - Search and filters
components/SearchBar.tsx - Result list
components/ResultList.tsx - Map view · Renders returned asset geometry without querying OSM directly.
components/MapView.tsx - Asset details
components/AssetInfoModal.tsx - Share controls
components/ShareButton.tsx
Server API
- Search API · Orchestrates parsing, geographic resolution, retrieval, caching, and normalized results.
app/api/search/route.ts - Geocoding proxy · Centralizes browser access to Nominatim.
app/api/nominatim/route.ts - Process-local cache · Non-durable and unshared across serverless instances.
lib/cache.ts
Search Domain
- Query parser
lib/parser.ts - Infrastructure catalog · Defines asset taxonomy, aliases, and qualifiers.
lib/search-index.ts - Shared contracts · Defines parsed-query and asset-result contracts shared by API, processing, and UI.
lib/types.ts - Geographic resolver
lib/geo.ts - OSM retriever · Builds Overpass QL and converts OSM elements into application results.
lib/overpass.ts
Public OSM Services
- Nominatim · Subject to a 1 request/second policy.
- Overpass API · Read-only public OSM data service.
- OSM map tiles
Connections 19
- Root layout → Search page: hosts
- Search and filters → Search page: query and filters
- Search page → Search API: POST search
- Search API → Search page: normalized assets
- Search page → Result list: renders results
- Search page → Map view: renders assets and selection
- Search page → Asset details: opens selected asset
- Search page → Share controls: shares app state
- Map view → OSM map tiles: loads tiles
- Search API → Process-local cache: reads and writes
- Search API → Query parser: parses query
- Query parser → Infrastructure catalog: matches taxonomy
- Query parser → Shared contracts: produces intent
- Search API → Geographic resolver: resolves location
- Search API → OSM retriever: retrieves assets
- Geographic resolver → Nominatim: geocodes place
- Geocoding proxy → Nominatim: proxies geocoding
- OSM retriever → Overpass API: queries OSM
- OSM retriever → Shared contracts: normalizes assets