How platong34821/project-dsm works
1. Project shape
- This is a SvelteKit frontend application, not a full backend service.
- The repo is centered on a road-safety map experience described in the README: hazards, user reports, and GPS-style alerts.
2. Top-level app boundary
- src/app.html, src/app.d.ts, svelte.config.js, and vite.config.js define the SvelteKit runtime and build pipeline.
- package.json/package-lock.json manage the app dependencies and scripts; Vite is the local dev/build toolchain.
3. Route-level UI structure
- The user-facing app is organized under src/routes.
- +layout.svelte is the shared shell for all pages.
- +page.svelte is the main landing/home view.
- save.svelte is a separate page, likely for persisting or submitting route/report data based on the project theme.
4. Primary functional subsystem: map-centered safety UI
- The README’s “real-time map data” and “gps-based notifications” imply the main experience is map-driven.
- The route components are where the map, hazard overlays, and user-facing alerts would be assembled.
5. Reusable application library layer
- src/lib/index.js is the app’s internal library entry point.
- src/lib/assets holds static application assets used by the Svelte components.
- This is the boundary for shared UI helpers/resources that should not live directly in a route.
6. Vendored Leaflet mapping stack
- The repository includes a full local copy of Leaflet under src/lib/leaflet.
- This is the core map rendering engine and strongly suggests the app runs the map entirely on the client side in the browser.
7. Routing and directions subsystem
- src/lib/leaflet-routing-machine is a vendored routing plugin for Leaflet.
- Its source includes route planning, waypoint handling, itinerary rendering, geocoding hooks, and OSRM/Mapbox adapters.
- Architecturally, this is the part that would turn locations into routes and turn routes into displayed directions.
8. External routing / geocoding dependencies
- The routing machine contains adapters for OSRM v1 and Mapbox, which means the app can integrate with external routing services.
- This matters for architecture because the map UI is likely not doing routing computation locally; it delegates to a route provider.
9. Data flow from user action to map output
- A likely flow is: user loads the Svelte page → map initializes via Leaflet → route/geocoder plugins request route data → the UI displays roads, hazards, and guidance.
- User reports or saved data would likely be captured in a route like save.svelte and then reflected back in the map experience.
10. Testing and examples live inside vendored code, not the app
- The Leaflet Routing Machine copy includes its own examples and test directories, plus Jasmine specs.
- These are library-level artifacts and indicate the routing subsystem is imported as source/vendor code rather than treated as a remote npm-only dependency.
11. Static delivery model
- static/robots.txt and the absence of server-side app code suggest a mostly static/browser-executed application.
- Any real-time behavior is therefore expected to happen through client-side calls to mapping/routing APIs rather than server-rendered logic.
12. Architectural summary
- The repo is essentially a SvelteKit SPA-style frontend with a shared layout, a small set of route pages, and a large embedded mapping stack.
- Leaflet handles map rendering; Leaflet Routing Machine handles directions and geocoding; the Svelte routes provide the application UI for road-safety reporting and alerts.
Main entry points: index.js Routing plugin · +page.svelte Home · svelte.config.js SvelteKit · save.svelte Save page
Components 18
SvelteKit app
Top-level frontend runtime and build boundary.
- Package · Dependency and script manifest for the app.
package.json - Vite · Local dev and production bundling pipeline.
vite.config.js - SvelteKit · SvelteKit app configuration and runtime integration.
svelte.config.js - App shell · Base document template for the client app.
src/app.html - Types · Global app type declarations.
src/app.d.ts - Static · Browser-served static content.
static/robots.txt
Routes
User-facing pages and shared shell.
Shared lib
Reusable app code and assets.
Mapping stack
Vendored client-side mapping and routing libraries.
- Leaflet · Vendored client-side map rendering engine.
src/lib/leaflet/dist/leaflet-src.esm.js
Routing machine
Leaflet routing plugin internals and adapters.
- Routing plugin · Vendored routing and itinerary layer for Leaflet.
src/lib/leaflet-routing-machine/src/index.js - Plan · Waypoint and route-planning model for directions.
src/lib/leaflet-routing-machine/src/plan.js - Itinerary · Builds displayed turn-by-turn directions and route summary.
src/lib/leaflet-routing-machine/src/itinerary-builder.js - Geocoding · Geocoder hooks and provider integrations.
src/lib/leaflet-routing-machine/src/geocoder-element.js - OSRM v1 · Adapter for OSRM-based route services.
src/lib/leaflet-routing-machine/src/osrm-v1.js - Mapbox · Adapter for Mapbox route services.
src/lib/leaflet-routing-machine/src/mapbox.js
Connections 18
- Package → Vite: uses · Scripts and dependencies drive the Vite toolchain.
- Package → SvelteKit: configures · Package setup supports the SvelteKit app runtime.
- SvelteKit → App shell: renders · SvelteKit uses the app shell as the base document.
- SvelteKit → Types: types · App configuration ties into shared type declarations.
- Layout → Home: wraps · Shared shell provides common structure for pages.
- Layout → Save page: wraps · Shared shell provides common structure for pages.
- Home → Leaflet: maps · Main page initializes and displays the map experience.
- Home → Routing plugin: routes · Home view can attach routing and direction controls.
- Save page → Lib entry: uses · Save flow can share internal helpers and UI resources.
- Lib entry → Assets: loads · Shared library exposes application assets.
- Leaflet → Routing plugin: extends · Routing plugin builds on top of the Leaflet map engine.
- Routing plugin → Plan: includes · Routing machine manages route planning state.
- Routing plugin → Itinerary: includes · Routing machine renders route instructions and itinerary UI.
- Routing plugin → Geocoding: includes · Routing machine supports geocoding and search inputs.
- Routing plugin → OSRM v1: adapts · Routing machine can delegate route computation to OSRM.
- Routing plugin → Mapbox: adapts · Routing machine can delegate route computation to Mapbox.
- Home → Static: serves · Client app can deliver browser-visible static content.
- Save page → Static: serves · Static assets are available to the save/report page.