Home & Introduction
Relevant source files
The following files were used as context for generating this wiki page:
P4N Map is an experimental, private-use web application designed to enhance the trip-planning experience for Park4Night+ users. Unlike the official Park4Night application, which often requires constant back-and-forth navigation, P4N Map provides a unified interface for planning multi-stop "A → B → C" van trips. It integrates mapping, route-based place searching, and hands-free voice assistance to streamline the transition from desktop planning to mobile navigation.
The system acts as a sophisticated wrapper around Park4Night's private endpoints, utilizing a user's session to provide access to premium data and favorite folders. It focuses on "planning geometry," delegating turn-by-turn navigation to dedicated apps like TomTom (which supports van-specific dimensions) or Google Maps.
Sources: README.md:1-20, src/components/Planner.tsx:141-150
Project Architecture & Stack
The project is built on a modern web stack designed for performance and flexibility. It utilizes Next.js for its application framework and MapLibre GL for high-performance, GPU-accelerated map rendering.
Core Technologies
| Component | Technology |
|---|---|
| Framework | Next.js 16 (App Router), React 19, TypeScript |
| Mapping | MapLibre GL, OpenStreetMap raster tiles |
| Routing | OSRM (Open Source Routing Machine) |
| Geocoding/POI | Nominatim (Geocoding), Overpass (OSM Amenities) |
| Backend/AI | Node.js 22, Google Gemini (Voice Assistant) |
| Styling | Tailwind CSS 4 |
Sources: package.json:1-35, README.md:22-28
High-Level System Flow
The following diagram illustrates how user requests move from the UI through internal logic to external services.
The flow of data from the frontend components through Next.js API routes to various external microservices and internal caching.
Sources: README.md:30-40, src/lib/cache.ts:1-15
Core Features
1. Multi-Stop Route Planning
Users can define multiple stops (A, B, C...). The system generates a planning polyline via OSRM. It then samples this polyline to query for Park4Night spots within a defined "corridor" (e.g., 5km from the road).
2. Specialized Filtering & Ranking
The application applies both hard filters (excluding private or off-road places) and soft preferences. Places are ranked based on a composite score considering detour distance, rating, and proximity to amenities like dog parks.
3. Voice Assistant
A voice-driven assistant powered by Google Gemini allows for hands-free queries while driving, such as finding supermarkets en route or overnight spots with specific amenities. Gemini performs "tool-choice" only, ensuring it never invents non-existent places.
4. Favourites Management
Full CRUD (Create, Read, Update, Delete) operations on Park4Night bookmark folders. Users can drag and drop places into folders, which are synced back to their official Park4Night account.
Sources: README.md:10-18, src/lib/planner.ts:20-40, src/components/FavouritesBoard.tsx:40-60
Planning Logic & Data Flow
The planning process is the core engine of P4N Map. It transforms a simple sequence of stops into a detailed travel plan with relevant amenities.
The sequence of operations during a trip planning request, involving routing geometry and spatial searches.
Scoring Mechanism
The ranking system uses a composite score (lower is better) to prioritize results:
- Base Score: The perpendicular distance (km) from the road.
- Rating Bonus: Up to -1.5 km equivalent for a 5-star rating.
- Service Bonus: Each requested service (e.g., water, electricity) provides a -0.4 km equivalent.
- Dog Park Bonus: Proximity to an OSM dog park provides a soft reward.
Sources: src/lib/planner.ts:100-130, src/app/api/plan/route.ts:10-50
Caching Strategy
To minimize upstream requests and respect community-driven services, P4N Map implements a durable, refresh-only JSON cache.
- Durable: Entries are stored in memory and mirrored to a JSON file (defaulting to
.p4n-cache). - No TTL: Entries do not expire automatically; they are only replaced on explicit user refresh.
- Graceful Degradation: If the filesystem is read-only, the cache falls back to memory-only operation.
Sources: src/lib/cache.ts:1-25
Summary
P4N Map provides a specialized, technical interface for the Park4Night ecosystem, focusing on the specific needs of van travelers who require long-term planning and en-route amenity discovery. By combining OSRM routing, OpenStreetMap data, and Park4Night's database, it offers a "one canvas" experience that bridges the gap between planning at home and navigating on the road.