How idieguez/geopark-web works
Purpose and entry points
Geopark is a mobile-first, vanilla-JavaScript SPA for recording, viewing, and sharing parked vehicle locations using device geolocation. The browser starts at index.html; view shells are separated into dashboard and authentication layouts: layouts/dashboard.html, layouts/sign-in.html, and layouts/sign-up.html.
UI composition with Web Components
Feature UI is encapsulated as native Custom Elements, keeping state, markup, and DOM event handling close to each feature. The dashboard is composed from cards, map, and navigation controls in components/dashboard-card.js, components/dashboard-map.js, and components/dashboard-toggle-menu.js. Account and fleet surfaces are implemented in components/profile-card.js and components/vehicles-card.js.
Authentication and access boundary
Authentication screens are represented by dedicated components—components/sign-in-card.js, components/sign-in-side.js, and components/sign-up-card.js. Authentication API operations belong behind scripts/services/auth.js; protected-view enforcement is centralized in scripts/utils/auth-guard.js, separating session/access decisions from individual components.
API service layer
Frontend components should reach the Geopark REST backend through a small service boundary rather than direct HTTP calls. scripts/services/api.js provides shared API communication behavior, while domain services isolate account and vehicle operations in scripts/services/users.js and scripts/services/vehicles.js. Runtime endpoint/environment settings are held in scripts/config.js.
Dashboard, geolocation, and mapping flow
The authenticated dashboard combines user/device location with the user’s vehicle fleet, rendering the result on an interactive Leaflet map. components/dashboard-map.js is the map-facing boundary; fleet data comes through scripts/services/vehicles.js; dashboard orchestration/display is represented by components/dashboard-card.js. Browser geolocation and Leaflet are material external runtime capabilities.
Error and state feedback flow
Async API failures pass through shared handling rather than being interpreted independently by each UI feature. scripts/utils/error-handler.js maps or presents failures using scripts/utils/error-dictionary.js; API-originated errors enter from scripts/services/api.js. This establishes a consistent boundary between backend error contracts and user-facing messages.
Browser runtime and delivery
The application is static HTML/CSS/ES JavaScript, runnable from a local static server without a build system. Global responsive styling is centralized in styles/global.css. Progressive-web-app assets are represented by site.webmanifest and sw.js; static imagery resides under assets/images.
Main entry points: api.js REST API client · dashboard-card.js Dashboard card · dashboard.html View layouts · index.html Browser entry
Components 20
App shell
- Browser entry
index.html - View layouts · Dashboard and authentication view shells.
layouts/dashboard.html - Global styling
styles/global.css - PWA delivery · Manifest and service worker for installable/offline delivery.
site.webmanifest
Web components
- Dashboard card · Orchestrates dashboard display.
components/dashboard-card.js - Dashboard map · Map-facing UI boundary.
components/dashboard-map.js - Dashboard menu
components/dashboard-toggle-menu.js - Profile card
components/profile-card.js - Vehicles card
components/vehicles-card.js - Authentication cards · Sign-in, sign-up, and sign-in side surfaces.
components/sign-in-card.js
Service boundary
- Auth service
scripts/services/auth.js - User service
scripts/services/users.js - Vehicle service
scripts/services/vehicles.js - REST API client · Shared backend communication and error origin.
scripts/services/api.js
Shared runtime
- Runtime config · Endpoint and environment settings.
scripts/config.js - Access guard · Enforces protected views.
scripts/utils/auth-guard.js - Error feedback · Maps API failures to user-facing messages.
scripts/utils/error-handler.js
Other components
- Browser geolocation
- Leaflet
- Geopark REST backend
Connections 21
- Browser entry → View layouts: loads views
- Browser entry → Global styling: applies
- Browser entry → PWA delivery: enables
- View layouts → Dashboard card: hosts
- View layouts → Authentication cards: hosts
- Dashboard card → Dashboard map: composes
- Dashboard card → Dashboard menu: composes
- Dashboard card → Vehicles card: uses fleet UI
- Dashboard map → Browser geolocation: gets device location
- Dashboard map → Leaflet: renders with
- Dashboard card → Vehicle service: loads fleet
- Vehicles card → Vehicle service: manages fleet
- Profile card → User service: uses
- Authentication cards → Auth service: signs in and up
- View layouts → Access guard: protects dashboard
- Auth service → REST API client: uses
- User service → REST API client: uses
- Vehicle service → REST API client: uses
- REST API client → Runtime config: reads endpoint
- REST API client → Geopark REST backend: REST requests
- REST API client → Error feedback: forwards failures