# idieguez/geopark-web architecture

> Architecture diagram of the GitHub repository idieguez/geopark-web, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-31). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/idieguez/geopark-web
- Repository: https://github.com/idieguez/geopark-web

## Overview

#### 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: [`scripts/services/api.js`](https://github.com/idieguez/geopark-web/blob/main/scripts/services/api.js) (REST API client), [`components/dashboard-card.js`](https://github.com/idieguez/geopark-web/blob/main/components/dashboard-card.js) (Dashboard card), [`layouts/dashboard.html`](https://github.com/idieguez/geopark-web/blob/main/layouts/dashboard.html) (View layouts), [`index.html`](https://github.com/idieguez/geopark-web/blob/main/index.html) (Browser entry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_shell["App shell"]
  node_entry["Browser entry<br/>HTML entry<br/>[index.html]"]
  node_layouts["View layouts<br/>HTML shells<br/>[dashboard.html]"]
  node_styles["Global styling<br/>CSS<br/>[global.css]"]
  node_pwa["PWA delivery<br/>manifest and worker<br/>[site.webmanifest]"]
end

subgraph group_ui["Web components"]
  node_dashboard["Dashboard card<br/>custom element<br/>[dashboard-card.js]"]
  node_map["Dashboard map<br/>custom element<br/>[dashboard-map.js]"]
  node_menu["Dashboard menu<br/>custom element"]
  node_profile["Profile card<br/>custom element<br/>[profile-card.js]"]
  node_fleet["Vehicles card<br/>custom element<br/>[vehicles-card.js]"]
  node_auth_ui["Authentication cards<br/>custom elements<br/>[sign-in-card.js]"]
end

subgraph group_services["Service boundary"]
  node_auth["Auth service<br/>domain service<br/>[auth.js]"]
  node_users["User service<br/>domain service<br/>[users.js]"]
  node_vehicles["Vehicle service<br/>domain service<br/>[vehicles.js]"]
  node_api["REST API client<br/>shared service<br/>[api.js]"]
end

subgraph group_shared["Shared runtime"]
  node_config["Runtime config<br/>settings module<br/>[config.js]"]
  node_guard["Access guard<br/>auth utility<br/>[auth-guard.js]"]
  node_errors["Error feedback<br/>error utilities<br/>[error-handler.js]"]
end

node_geolocation{{"Browser geolocation<br/>browser API"}}
node_leaflet{{"Leaflet<br/>mapping runtime"}}
node_backend{{"Geopark REST backend<br/>external API"}}

node_entry -->|"loads views"| node_layouts
node_entry -->|"applies"| node_styles
node_entry -->|"enables"| node_pwa
node_layouts -->|"hosts"| node_dashboard
node_layouts -->|"hosts"| node_auth_ui
node_dashboard -->|"composes"| node_map
node_dashboard -->|"composes"| node_menu
node_dashboard -->|"uses fleet UI"| node_fleet
node_map -->|"gets device location"| node_geolocation
node_map -->|"renders with"| node_leaflet
node_dashboard -->|"loads fleet"| node_vehicles
node_fleet -->|"manages fleet"| node_vehicles
node_profile -->|"uses"| node_users
node_auth_ui -->|"signs in and up"| node_auth
node_layouts -->|"protects dashboard"| node_guard
node_auth -->|"uses"| node_api
node_users -->|"uses"| node_api
node_vehicles -->|"uses"| node_api
node_api -->|"reads endpoint"| node_config
node_api -->|"REST requests"| node_backend
node_api -->|"forwards failures"| node_errors

click node_entry "https://github.com/idieguez/geopark-web/blob/main/index.html"
click node_layouts "https://github.com/idieguez/geopark-web/blob/main/layouts/dashboard.html"
click node_styles "https://github.com/idieguez/geopark-web/blob/main/styles/global.css"
click node_dashboard "https://github.com/idieguez/geopark-web/blob/main/components/dashboard-card.js"
click node_map "https://github.com/idieguez/geopark-web/blob/main/components/dashboard-map.js"
click node_menu "https://github.com/idieguez/geopark-web/blob/main/components/dashboard-toggle-menu.js"
click node_profile "https://github.com/idieguez/geopark-web/blob/main/components/profile-card.js"
click node_fleet "https://github.com/idieguez/geopark-web/blob/main/components/vehicles-card.js"
click node_auth_ui "https://github.com/idieguez/geopark-web/blob/main/components/sign-in-card.js"
click node_auth "https://github.com/idieguez/geopark-web/blob/main/scripts/services/auth.js"
click node_users "https://github.com/idieguez/geopark-web/blob/main/scripts/services/users.js"
click node_vehicles "https://github.com/idieguez/geopark-web/blob/main/scripts/services/vehicles.js"
click node_api "https://github.com/idieguez/geopark-web/blob/main/scripts/services/api.js"
click node_config "https://github.com/idieguez/geopark-web/blob/main/scripts/config.js"
click node_guard "https://github.com/idieguez/geopark-web/blob/main/scripts/utils/auth-guard.js"
click node_errors "https://github.com/idieguez/geopark-web/blob/main/scripts/utils/error-handler.js"
click node_pwa "https://github.com/idieguez/geopark-web/blob/main/site.webmanifest"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_entry,node_layouts,node_styles,node_pwa toneBlue
class node_dashboard,node_map,node_menu,node_profile,node_fleet,node_auth_ui toneAmber
class node_auth,node_users,node_vehicles,node_api toneMint
class node_config,node_guard,node_errors toneRose
class node_geolocation,node_leaflet,node_backend toneNeutral
```

## Components

### App shell

- [Browser entry](https://github.com/idieguez/geopark-web/blob/main/index.html): HTML entry · `index.html`
- [View layouts](https://github.com/idieguez/geopark-web/blob/main/layouts/dashboard.html): HTML shells · Dashboard and authentication view shells. · `layouts/dashboard.html`
- [Global styling](https://github.com/idieguez/geopark-web/blob/main/styles/global.css): CSS · `styles/global.css`
- [PWA delivery](https://github.com/idieguez/geopark-web/blob/main/site.webmanifest): manifest and worker · Manifest and service worker for installable/offline delivery. · `site.webmanifest`

### Web components

- [Dashboard card](https://github.com/idieguez/geopark-web/blob/main/components/dashboard-card.js): custom element · Orchestrates dashboard display. · `components/dashboard-card.js`
- [Dashboard map](https://github.com/idieguez/geopark-web/blob/main/components/dashboard-map.js): custom element · Map-facing UI boundary. · `components/dashboard-map.js`
- [Dashboard menu](https://github.com/idieguez/geopark-web/blob/main/components/dashboard-toggle-menu.js): custom element · `components/dashboard-toggle-menu.js`
- [Profile card](https://github.com/idieguez/geopark-web/blob/main/components/profile-card.js): custom element · `components/profile-card.js`
- [Vehicles card](https://github.com/idieguez/geopark-web/blob/main/components/vehicles-card.js): custom element · `components/vehicles-card.js`
- [Authentication cards](https://github.com/idieguez/geopark-web/blob/main/components/sign-in-card.js): custom elements · Sign-in, sign-up, and sign-in side surfaces. · `components/sign-in-card.js`

### Service boundary

- [Auth service](https://github.com/idieguez/geopark-web/blob/main/scripts/services/auth.js): domain service · `scripts/services/auth.js`
- [User service](https://github.com/idieguez/geopark-web/blob/main/scripts/services/users.js): domain service · `scripts/services/users.js`
- [Vehicle service](https://github.com/idieguez/geopark-web/blob/main/scripts/services/vehicles.js): domain service · `scripts/services/vehicles.js`
- [REST API client](https://github.com/idieguez/geopark-web/blob/main/scripts/services/api.js): shared service · Shared backend communication and error origin. · `scripts/services/api.js`

### Shared runtime

- [Runtime config](https://github.com/idieguez/geopark-web/blob/main/scripts/config.js): settings module · Endpoint and environment settings. · `scripts/config.js`
- [Access guard](https://github.com/idieguez/geopark-web/blob/main/scripts/utils/auth-guard.js): auth utility · Enforces protected views. · `scripts/utils/auth-guard.js`
- [Error feedback](https://github.com/idieguez/geopark-web/blob/main/scripts/utils/error-handler.js): error utilities · Maps API failures to user-facing messages. · `scripts/utils/error-handler.js`

### Other components

- **Browser geolocation**: browser API
- **Leaflet**: mapping runtime
- **Geopark REST backend**: external API

## Connections

- 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
