Onboarding Guide: treetracker-web-map-client
Generated from the Understand-Anything knowledge graph. Source commit 42b3a9a.
Project Overview
Treetracker Web Map shows the location and details of the trees that Greenstand tracks (README.md). It is a Next.js web app with React and MUI.
- Package
Name and version:client2.10.3 (package.json)
Node:package.jsonasks for>=16. The README asks for Node v16. - Languages
Code and config: JavaScript, JSON, YAML, CSS, HTML, Markdown, Dockerfile, plain text, and other config files
Binary files: the graph also listssqliteandwebp. These are.vs/slnx.sqliteandpublic/images/bg.webp. - Frameworks
Stack: Next.js 12, React 17, MUI 5, Leaflet
Tests and tools: Jest, Cypress, MSW, Docker, GitHub Actions
Tree map: built on the map core package,treetracker-web-map-core(package.json) - Entry point
File:src/pages/_app.js
Role: it wraps every page and picks the layout. - Graph size
Files: 387
Nodes and edges: 647 and 836
Layers and tour steps: 9 and 13 - Quick start
Run:npm i, thennpm run dev, then openhttp://localhost:3000
With mocks:npm run dev:mockstarts the same server with MSW.
How the parts fit:
- Pages in
src/pages/load their data on the server throughsrc/models/api.js. src/pages/_app.jsputs each page into a layout.- The desktop layout
src/components/Layout.jsshows the page on the left half and the tree map on the right half. - The tree map is
src/components/App.js. It mountsMapfrom the map core package. src/mapContext.jsshares the tree map instance with pages and components.- The README links the current map API repo,
treetracker-query-api. The code reads the API base URL fromNEXT_PUBLIC_API.
Architecture Layers
The graph puts each file into one of 9 layers.
- Pages and Routing
Files: 19
What it holds: Next.js pages, admin pages, error pages, the app shell, and the/api/runtime-envroute.
Key files:src/pages/_app.js,src/pages/_document.js,src/pages/trees/[treeid].js,src/pages/api/runtime-env.js - UI Components
Files: 104
What it holds: React and MUI components for the map, the layouts, entity cards, sharing, search, the admin dashboard, the theme playground, and the design sandbox.
Key files:src/components/App.js,src/components/Layout.js,src/components/LayoutMobile.js,src/components/LayoutEmbed.js,src/components/Navbar.js - State and Hooks
Files: 22
What it holds: React contexts for the map, theme, drawer, config, dashboard, and playground, plus custom hooks.
Key files:src/mapContext.js,src/context/themeContext.js,src/context/configContext.js,src/hooks/globalHooks/index.js - Models and API Client
Files: 13
What it holds: the API client and URL builders, the URL path resolver, runtime env access, OIDC config, the config reducer, and shared helpers.
Key files:src/models/api.js,src/models/apiPaths.js,src/models/pathResolver.js,src/models/runtimeEnv.js,src/models/utils.js - Testing
Files: 96
What it holds: Cypress component, integration, and e2e tests, Jest tests, fixtures, MSW mocks, and test setup.
Key files:src/models/test-utils.js,src/mocks/handlers.js,cypress/plugins/index.js,cypress/tests/integration/nockRoutes.js - Infrastructure
Files: 67
What it holds: three Dockerfiles and five Kustomize trees:deployment/,deployment-alpha/,deployment-beta/,deployment-main/,deployment-next/. Each tree has abase/and the overlaysdevelopment,test, andprod.
Key files:Dockerfile,deployment/base/deployment.yaml,deployment/overlays/prod/deployment.yaml - CI/CD
Files: 6
What it holds: GitHub Actions workflows for pull request checks, release builds, and deploys.
Key files:.github/workflows/pull-request-ci.yml,.github/workflows/dev-build-release.yaml,.github/workflows/deploy.yaml - Documentation
Files: 35
What it holds: the README, the changelog, issue and PR templates, two OpenAPI files, example API payloads, andpublic/robots.txt.
Key files:README.md,doc/web-map-api.yaml,doc/web-map-router.yaml,doc/examples/ - Configuration
Files: 25
What it holds: package, Next.js, Jest, Cypress, lint, format, commit hook, and env config. It also holds the Visual Studio files in.vs/and one static image.
Key files:package.json,next.config.js,.env.development,.env.production,.env.test,.releaserc.json
Key Concepts
The shell picks one of six layouts.
src/pages/_app.jschecks the path first. A path withadmingetssrc/components/LayoutDashboard.jsandAuthProvideronly. It gets no theme, drawer, or map provider from the shell.- Desktop gets
src/components/Layout.js. Desktop in embed mode getssrc/components/LayoutEmbed.js. - Mobile gets
src/components/LayoutMobileB.jswhen the page setsisBLayout, andsrc/components/LayoutMobileC.jswhen the page setsisCLayout. Other pages getsrc/components/LayoutMobile.js. - The home page sets
isBLayout, and the search page setsisCLayout.LayoutMobileB.jsandLayoutMobileC.jsshow no map. So on a phone, the home page shows no map. - The server reads the device type from the user agent. The browser uses the MUI
smbreakpoint. - Embed mode is on when the URL has
embed=trueor when the local storage flagembedis set. The full-screen icon inLayout.jstoggles that flag. The mobile branch ignores embed mode.
The tree map comes from the map core package.
src/components/App.jscreatesMapfrom the map core package (treetracker-web-map-core) and mounts it.- The layouts load
App.jswithnext/dynamicandssr: false. App.jsstores the tree map instance insrc/mapContext.js. Pages get it withuseMapContext()and callsetFilters,gotoView, orgotoBounds.
The URL holds the map state.
- On a tree click,
App.jsfetches the tree and asksgetPathWhenClickTreeinsrc/models/pathResolver.jsfor the next route. Then it callsrouter.push. - When the map stops moving,
updatePathWhenMapMoveEndbuilds?bounds=...and keepstimeline,embed, andtree_id.App.jswrites it withhistory.replaceState. src/components/Home.jsandsrc/pages/top.jsreadboundsback and move the map.next.config.jsredirects old query links (?treeid=,?userid=,?wallet=) to/trees/,/planters/, and/wallets/.App.jsalso posts each clicked tree towindow.parentand to a React Native WebView, if one is present.
- On a tree click,
Tile settings can change at runtime.
src/pages/_document.jsloads/api/runtime-envas a blocking script.src/pages/api/runtime-env.jsreturnswindow.__RUNTIME_ENV__. It escapes the output and setsno-storeandnosniff. It answers 405 to methods other than GET and HEAD.- The allowlist in
src/models/runtimeEnv.jshas three keys:NEXT_PUBLIC_TILE_SERVER_URL,NEXT_PUBLIC_TILE_SERVER_SUBDOMAINS, andNEXT_PUBLIC_TILE_SERVER_WEBMAP_API. getEnvuses the runtime value first and the build-time value second. It throws for any other key.- Other code reads
process.env.NEXT_PUBLIC_*directly. For example,App.jspassesNEXT_PUBLIC_APIto the map asqueryApiServerUrl.
Pages load on the server and degrade on failure.
src/models/api.jswraps axios GET calls.src/models/apiPaths.jsbuilds the URLs fromNEXT_PUBLIC_API. The stakeholder URL usesNEXT_PUBLIC_API_V2.- Calls stop after 15 seconds (
API_TIMEOUT_MSinsrc/models/utils.js). - Not every call goes through
api.js.src/pages/search.jsandsrc/pages/tokens/[tokenid].jscall axios directly.src/pages/top.jsandsrc/pages/wallets/[walletid].jsalso userequestAPIfromutils.js. - The tree, planter, organization, wallet, capture, and top pages use ISR (Incremental Static Regeneration: Next.js builds the page again in the background after
revalidateseconds).revalidateisNEXT_CACHE_REVALIDATION_OVERRIDE, else 300 seconds. The dynamic pages usefallback: 'blocking'.next.config.jssetsisrMemoryCacheSize: 0. wrapperinutils.jscatches loader errors. A 404 givesnotFound. Other errors give aloadErrorprop and a 30 second revalidate. The page then showssrc/components/common/PageLoadError.js.getOrgLinksinapi.jsloads featured trees, associates, and species withPromise.allSettled. One failed part gives apartialErrorsentry, and the page showsSectionUnavailablefor that part.- The token page uses
getServerSidePropswithoutwrapper. Any error gives a 404.
The theme comes from local storage, the OS, or a config API.
src/context/themeContext.jsbuilds the light and dark MUI themes.- The mode comes from local storage, else from the OS color-scheme preference.
- When
NEXT_PUBLIC_CONFIG_APIis set, it loads the theme of organization 1 from that API. The value is empty in.env.developmentand.env.test, and.env.productiondoes not set it. - The admin theme playground sends
playground:theme-updateevents to an iframe of/top.themeContext.jslistens for that event.
Navbar config and admin config are separate.
src/components/Navbar.jsreads its nav items fromConfigProvider._app.jsfillsConfigProviderwithdefaultConfig. WhenNEXT_PUBLIC_SERVER_CONFIG_DISABLEDis unset, it fetches a hard-coded dev URL instead (src/pages/_app.js:255). All three env files set the flag totrue.- The admin dashboard at
/admin/globaledits the logo, the navbar, and the map location.src/context/dashboardContext.jssaves the edits to local storage. No public page reads that state.
Login code exists, but the UI hides it.
_app.jswraps all pages inAuthProviderfromreact-oidc-context.src/models/oidcConfig.jsreads the Keycloak env variables.Navbar.jscomments out the sign-in controls ("hide login temporarily").- The admin pages call
useKeycloakfrom@react-keycloak/ssr.LayoutDashboard.jshas itsSSRKeycloakProvidercommented out.
Each test level has its own mock.
- Dev server:
NEXT_PUBLIC_API_MOCKING=enabled(ornpm run dev:mock) makes_app.jsloadsrc/mocks/index.js. It starts MSW on the server side and the MSW worker in the browser.src/mocks/handlers.jsholds the routes. - Jest:
.jest/setupFile.jsstarts the MSW server for the test run. - Cypress integration:
cypress/plugins/index.jsstarts a custom Next.js server on port 3000. It stubs server-side calls with nock when thenockenv is set.npm run cysets it. - API spec:
npm run mock-serverservesdoc/web-map-api.yamlwith Prism. - The README names
npm run cy:nockandnpm run cyu.package.jsonhas neither script.
- Dev server:
No page reaches 31 files. No page reaches 31 non-test files in
src/. Check this before you build on a file.- Models:
src/models/MapModel.js,src/models/entity.js,src/models/mapConfig.js,src/models/tools.js. Only their own tests importMapModel.js,entity.js, andtools.js. - Search widget: all six files in
src/components/search/, includingmockApi.js. - Components:
src/components/PageWrapper.js,src/components/ShareDeprecated.js,src/components/DrawerDeprecated.js,src/components/ShareIcon.js,src/components/SearchFilterMobile.js,src/components/SearchBoxMobile.js,src/components/Loader.js,src/components/LoaderB.js,src/components/Logo.js,src/components/ImageShower.js,src/components/BackButton.js,src/components/common/BackButton.js,src/components/common/CustomImageWrapper.js,src/components/common/DataTag.js,src/components/common/DrawerTitle.js. - Design sandbox: all six files in
src/DesignSandbox/. Only its test,src/DesignSandbox/DesignSandbox.cy.js, imports it.
- Models:
Guided Tour
Follow these 13 steps in order.
- Project overview
Files:README.md,package.json
What to see: the README covers setup, TDD, and the test rules.package.jsonshows the stack and the scripts. - App shell
Files:src/pages/_app.js,src/pages/_document.js
What to see:_app.jssets up the providers, Google Analytics, error logging, the route progress bar, and the layout choice._document.jsloads the runtime env script and the Google fonts. - Routing with pages
Files:src/pages/index.js,src/pages/trees/[treeid].js,src/pages/planters/[planterid].js,src/pages/organizations/[organizationid].js
What to see: Next.js maps each file to a route. The home page renderssrc/components/Home.js. - Models and API client
Files:src/models/api.js,src/models/apiPaths.js,src/models/runtimeEnv.js,src/models/MapModel.js
What to see: the loaders callapi.js, andapiPaths.jsbuilds the URLs.
Note: no page reachesMapModel.js. Only its test imports it. The tree map issrc/components/App.js. - State, contexts, and hooks
Files:src/mapContext.js,src/context/themeContext.js,src/context/DrawerContext.js,src/hooks/globalHooks/index.js
What to see: the global hooks areuseEmbed,useFullscreen,useLocalStorage,useMobile, anduseClipboard. - Map home and layouts
Files:src/components/Home.js,src/components/Layout.js,src/components/LayoutMobile.js,src/components/CustomWorldMap.js
What to see:Home.jsclears the map filters and goes to the URL bounds or the global view.
Note:CustomWorldMap.jsis areact-world-mapcontinent chart on the planter, organization, and wallet pages. It is not the tree map. - Navigation and search
Files:src/components/Navbar.js,src/components/Link.js,src/components/SearchFilter.js,src/components/search/Search.js
What to see:Link.jsjoins the MUI link and the Next.js link. Many components use it.
Note: no page reachessrc/components/search/.SearchFilter.jsshows only on/searchand/filter. - Detail UI components
Files:src/components/Timeline.js,src/components/common/CustomCard.js,src/components/Share.js,src/components/common/ErrorBoundary.js
What to see: the layouts wrap each page inPageErrorBoundaryand the map in its ownErrorBoundary. - Theming and design sandbox
Files:src/pages/admin/theme.js,src/models/themePlaygroundOptions.js,src/DesignSandbox/DesignSandbox.js
What to see: the playground edits the palette, typography, and fonts, and previews them live. - Testing strategy
Files:src/models/test-utils.js,src/mocks/handlers.js,cypress/tests/integration/nockRoutes.js,cypress/tests/integration/readme.md
What to see: 46 test files importtest-utils.js. It mounts components with the app theme and a mock router. - API documentation
Files:doc/web-map-api.yaml,doc/web-map-router.yaml,doc/examples/trees/186734.json
What to see: the OpenAPI spec describes the backend that the API client calls. The examples also serve as test fixtures. - Containers and Kubernetes
Files:Dockerfile,deployment/base/deployment.yaml,deployment/overlays/prod/kustomization.yaml
What to see: theDockerfilerunsnpm run buildinside the image.Dockerfile-devandDockerfile-testfirst copy.env.developmentor.env.testover.env.production. - CI/CD workflows
Files:.github/workflows/pull-request-ci.yml,.github/workflows/dev-build-release.yaml,.github/workflows/deploy.yaml
What to see: pull requests run Cypress integration tests with nock, Cypress component tests, Jest, and ESLint.
File Map (by layer)
Pages and Routing
src/pages/_app.js: providers, layout choice, analytics. ItsgetInitialPropsfinds the device type and the config.src/pages/_document.js: HTML shell, runtime env script, fonts, emotion cache.src/pages/index.js: home page. It rendersHomeand setsisBLayoutandisFloatingDisabled.src/pages/top.js: Tree Spotlight with featured trees, planters, organizations, wallets, and the country leaderboard.src/pages/trees/[treeid].js: tree detail (ISR).src/pages/planters/[planterid].js,src/pages/organizations/[organizationid].js,src/pages/wallets/[walletid].js: profile pages (ISR).src/pages/tokens/[tokenid].js: token detail with a timeline of transfers (getServerSideProps).src/pages/v2/captures/[captureid].js: version 2 capture detail (ISR).src/pages/search.js,src/pages/filter.js: keyword result list and the date filter page.src/pages/admin/global.js,src/pages/admin/theme.js,src/pages/admin/index.js: admin dashboard, theme playground, and an experimental Keycloak page.src/pages/api/runtime-env.js: the runtime env script route.src/pages/404.js,src/pages/500.js,src/pages/_error.js: error pages.
UI Components
src/components/App.js: the tree map.src/components/Layout.js: desktop split view with the timeline and zoom buttons.src/components/LayoutEmbed.js: full-screen map with a collapsible page drawer.src/components/LayoutMobile.js,src/components/Drawer.js: mobile map with a bottom-sheet drawer.src/components/LayoutMobileB.js,src/components/LayoutMobileC.js: mobile layouts without a map.src/components/LayoutDashboard.js: admin wrapper.src/components/Navbar.js,src/components/Link.js: top bar and the shared link.src/components/Timeline.js,src/components/ZoomInOutButton.js: map date filter and zoom buttons.src/components/Share.js,src/components/TreeInfoDialog.js: share dialog and the full-screen tree dialog.src/components/FeaturedTreesSlider/,src/components/FeaturedPlantersSlider/,src/components/LeaderBoard.js: spotlight and profile widgets.src/components/common/: cards, tags, crumbs, the date filter form, the error boundary, and the page load error.src/components/dashboard/,src/components/GlobalMapLayout.js: admin editors for the logo, navbar, and map location.src/components/playground/: theme playground inputs.src/DesignSandbox/: theme reference sheet. No page reaches it. Only its test imports it.
State and Hooks
src/mapContext.js: the map instance.src/context/themeContext.js: MUI theme and mode.src/context/configContext.js: navbar and map config, anddefaultConfig.src/context/dashboardContext.js: admin config with a reducer and local storage.src/context/playgroundContext.js: playground theme and fonts.src/context/DrawerContext.js: drawer title data.src/hooks/globalHooks/: browser hooks.useLocalStorageprefixes keys withgreenstand-web-map-client-.src/hooks/contextHooks/: thin readers for the theme and playground contexts.src/hooks/usePageLoading.js,src/hooks/useDisclosure.js,src/hooks/cwmHooks/: small state hooks.
Models and API Client
src/models/api.js,src/models/apiPaths.js: API calls and URL builders.src/models/pathResolver.js: route after a click, URL after a map move, context from the path.src/models/runtimeEnv.js: allowlisted runtime env access.src/models/utils.js:requestAPI,wrapper, dates, names, fonts, base path, and number helpers.src/models/config.reducer.js: admin config actions.src/models/oidcConfig.js: OIDC settings from env.src/models/makeStyles.js: tss-react helpers bound to the theme.src/models/themePlaygroundOptions.js: playground options and validation rules.src/models/MapModel.js,src/models/entity.js,src/models/mapConfig.js,src/models/tools.js: no page reaches them.
Testing
src/**/*.cy.js: Cypress component tests next to their components.src/**/*.test.js: Jest tests for models, the runtime env route, and the error boundary.cypress/tests/integration/: page tests with nock mocks fromnockRoutes.js.cypress/tests/e2e/: e2e specs.case1.cy.jsvisitshttp://dev.treetracker.org.cypress/fixtures/: tile and API fixtures.src/mocks/,public/mockServiceWorker.js: MSW handlers and the generated worker.cypress/plugins/index.js,cypress/support/,.jest/: test setup.
Infrastructure
Dockerfile,Dockerfile-dev,Dockerfile-test:node:16-alpine,npm ci,npm run build,npm run start.deployment/: the main-channel tree. Every deploy workflow can apply it. The prod overlay sets the hostmap.treetracker.org.deployment-alpha/,deployment-next/:deploy.yamluses them for thealphaandnextchannels.deployment-beta/,deployment-main/: no workflow selects them.
CI/CD
.github/workflows/pull-request-ci.yml: runs on pull requests to a base branch whose name has no/. Markdown-only changes skip it..github/workflows/dev-build-release.yaml: runs on a push to a branch whose name has no/. The filter'*'does not match/. It stops unless.releaserc.jsonlists the branch. Then it runs semantic-release, builds two images, and deploys the dev image..github/workflows/deploy-main-channel-to-dev.yaml,deploy-main-channel-to-test.yaml,deploy-main-channel-to-prod.yaml: manual deploys ofdeployment/. The prod workflow builds no image. It uses a published image..github/workflows/deploy.yaml: manual deploy of a version to dev, test, or prod. A plainX.Y.Zversion goes todeployment/. A prerelease version goes todeployment-<channel>/, with the channel from.releaserc.json.
Documentation
README.md: setup, TDD rules, component and page rules, mocks.CHANGELOG.md: semantic-release output.doc/web-map-api.yaml,doc/web-map-router.yaml: API spec and page route spec.doc/examples/: example payloads for trees, planters, organizations, wallets, tokens, transactions, species, and countries.cypress/tests/integration/readme.md: how to write integration tests with nock..github/ISSUE_TEMPLATE/,.github/pull_request_template.md: issue and PR templates.public/robots.txt: blocks/admin/for crawlers.
Configuration
package.json: scripts and dependencies.next.config.js: images, rewrites, redirects,basePathfromNEXT_PUBLIC_BASE, SVG loaders.jsconfig.json:baseUrlissrc, so imports likemodels/apiwork..env.development,.env.production,.env.test:NEXT_PUBLIC_*values per environment..releaserc.json: release branches and prerelease channels..eslintignore,.prettierrc.json,.prettierignore,.lintstagedrc.js,scripts/codeshift.js: lint and format. The codemod turns relative imports into alias imports..husky/,commitlint.config.js: commit hooks and conventional commit rules.cypress.config.js,jest.config.js: test runners..vs/: Visual Studio state files. They are not source.
Complexity Hotspots
The graph rates 33 files as complex. Line counts come from the files.
- Entity pages
Files:src/pages/tokens/[tokenid].js(790 lines),src/pages/v2/captures/[captureid].js(782),src/pages/trees/[treeid].js(780),src/pages/planters/[planterid].js(589),src/pages/organizations/[organizationid].js(573),src/pages/wallets/[walletid].js(465),src/pages/top.js(341)
Why: each file holds its data loader, its map logic, and its full UI. - Admin pages
Files:src/pages/admin/theme.js(528),src/pages/admin/index.js(338)
Why: both contain an inlinedjwt-decodebundle. Both load a Keycloak authz script from a dev URL. - Theme
File:src/context/themeContext.js(472)
Why: it builds the light and dark MUI themes, loads a server theme, and handles preview events. - Shared helpers
File:src/models/utils.js(363)
Why: the graph lists 22 functions, the most of any file.wrapperandrequestAPIsit under most page loaders. - App shell
File:src/pages/_app.js(271)
Why: the providers, the layout choice, and the config fetch share one file. - Tree map
File:src/components/App.js(280)
Why: it mounts the tree map, routes clicks, and syncs the URL. The Google Maps script URL and its key are hard-coded (src/components/App.js:158). - Layout and touch UI
Files:src/components/TreeInfoDialog.js(380),src/components/Drawer.js(321),src/components/LayoutEmbed.js(310),src/components/Timeline.js(240)
Why:Drawer.jshandles touch events by hand with a velocity snap.TreeInfoDialog.jsandTimeline.jsrender different UI for mobile and desktop.LayoutEmbed.jshas several blocks thatfalse &&turns off. - Widgets and editors
Files:src/components/playground/TypographyInput.js(290),src/components/LeaderBoard.js(277),src/components/Share.js(251),src/components/GlobalMapLayout.js(226),src/components/FeaturedPlantersSlider/index.js(224),src/components/common/Filter.js(219),src/components/dashboard/CustomizeNavbar.js(205)
Why: each file mixes UI with local logic. Examples: validation inFilter.jsandGlobalMapLayout.js, drag and drop inCustomizeNavbar.js, scroll arrows in the slider, and font loading inTypographyInput.js. - Complex but unused
Files:src/models/MapModel.js(261),src/components/ShareDeprecated.js(242)
Why: no page reaches them. Read them only if you plan to delete or revive them. - CI workflows
Files:.github/workflows/dev-build-release.yaml,.github/workflows/deploy-main-channel-to-dev.yaml,.github/workflows/deploy.yaml
Why: release and environment logic lives in shell steps and inline Node scripts. - Large reference or generated files
Files:CHANGELOG.md(4569),doc/web-map-api.yaml(1105),README.md(459),public/mockServiceWorker.js(338)
Why:CHANGELOG.mdcomes from semantic-release. The worker file says "Please do NOT modify this file". Do not edit these two by hand.
Business Domains
domain-graph.json has 5 domains, 13 flows, and 79 steps. The bold names are the flow labels in the graph. The viewer's domain view shows each step. Here each flow has its entry and a short summary. A "Note" adds a code fact that the graph steps do not state.
Map Exploration: the tree map. Layout.js, LayoutEmbed.js, and LayoutMobile.js mount it.
- Load Map (entry: page load of
/or any other public route)src/pages/_app.jspicks the layout.src/components/App.jsmounts the tree map with the runtime tile settings, and each map move writes?bounds=into the URL. - Open Tree From Map (entry: a click on a tree marker)
App.jsposts the tree to the host windows and loads the full tree.src/models/pathResolver.jspicks the next route, andApp.jscallsrouter.pushonly when the path or thetree_idchanges.
Entity Profiles: detail pages for trees, planters, organizations, wallets, tokens, and version 2 captures.
- View Tree Detail (entry:
GET /trees/[treeid])
The page loads the tree, its planter, and its organization with ISR. On an error,wrappergives a 404 or aPageLoadErrorpanel with Retry. Else the page selects the tree on the tree map and shows the badges, Like, and Share. - View Grower or Organization Profile (entry:
GET /planters/[planterid],/organizations/[organizationid], or/wallets/[walletid])
Planter and organization pages load their parts withgetOrgLinksand mark a failed part withSectionUnavailable. The wallet page usesPromise.all, so one failure fails the whole page. Each page filters the tree map to its entity. - View Token or Capture (entry:
GET /tokens/[tokenid]andGET /v2/captures/[captureid])
The token page usesgetServerSideProps, so any error gives a 404. It shows the claim and transfer tags. The capture page loads the capture, planter, country, and stakeholder with ISR, and no page links to it.
Note: the stakeholder call usesNEXT_PUBLIC_API_V2. No env file, Dockerfile, or manifest in the repo sets it.
Search and Discovery: keyword search, date filters, and the Tree Spotlight.
- Search by Keyword (entry:
GET /search?keyword=<tree id>, by URL only)
No layout shows the search bar.src/pages/search.jsGETs/trees/<keyword>with no error handling and lists one link to the tree page. - Filter by Date Range (entry: a date change in the map timeline on
/or/top)Timeline.jsrejects a start date after the end date. It sets the timeline filter on the tree map only, not in the URL. The form inSearchFilter.jspushes/filter?timeline=, butsrc/pages/filter.jsonly prints the start date twice and a fixed "Found trees: 1,000,000". - Browse Tree Spotlight (entry:
GET /top)src/pages/top.jsloads the featured trees, planters, organizations, and wallets, and the country leaderboard, with ISR. A continent chip reloads the leaderboard, and a click on a country flies the tree map to it.
Note:.env.productionsetsNEXT_PUBLIC_COUNTRY_LEADER_BOARD_DISABLED=true, so the production build shows no leaderboard rows. The five prod overlays set the flag to'false'. That does not change the build:top.jsreads a literalprocess.envvalue, andsrc/models/runtimeEnv.js:9says that Next inlines such values at build time.
Sharing and Embedding: share a page, and run the tree map inside another site or app.
- Share Page (entry: a click on the share icon of a tree, token, or capture page)
src/components/Share.jsoffers embed code, Facebook, Twitter, email, and a link to copy. The link and the iframe code use the current URL as it is, with noembed=true. - View Embedded Map (entry: a public page with
?embed=true, or a click on the full-screen icon)
On desktop,_app.jsrendersLayoutEmbed.jswith a full-screen tree map and a page drawer. On mobile, the normal layouts stay and only the navbar hides.App.jsposts each clicked tree to the host window.
Authentication and Admin: OIDC sign-in, which the UI hides, and the admin pages.
- Sign In and Out (entry: none in the public UI.
/adminhas its own Login button.)_app.jswraps every page inAuthProvider, butNavbar.jscomments outLoginLogoutToggle.src/pages/admin/index.jsshows a Keycloak Login or Logout button, butLayoutDashboard.jscomments outSSRKeycloakProvider. - Configure Global Map (entry:
GET /admin/global)
The page edits the navbar, the logo, and the map location for organization 178, which is hard-coded. It saves the edits in local storage. No public page reads them, and the location moves only the tree map inside/admin/global. - Edit Theme in Playground (entry:
GET /admin/theme)
An admin edits the palette, typography, and fonts, and previews them in an iframe of/top. The preview goes to local storage, so public pages in the same browser use it. A save needs the Keycloak RPT.
Note:.env.developmentand.env.testleaveNEXT_PUBLIC_CONFIG_APIempty, and.env.productiondoes not set it. With these files,load()and the server theme load do not run.
Cross-domain links (7): map to profiles (tree clicks), profiles to map (filters and focus), search to map (timeline and country views), search to profiles (links), profiles to sharing (Share and Like), sharing to map (LayoutEmbed.js and embed=true), and admin to map (the playground preview, in the same browser only).