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.

How the parts fit:

Architecture Layers

The graph puts each file into one of 9 layers.

Key Concepts

Guided Tour

Follow these 13 steps in order.

  1. Project overview
    Files: README.md, package.json
    What to see: the README covers setup, TDD, and the test rules. package.json shows the stack and the scripts.
  2. App shell
    Files: src/pages/_app.js, src/pages/_document.js
    What to see: _app.js sets up the providers, Google Analytics, error logging, the route progress bar, and the layout choice. _document.js loads the runtime env script and the Google fonts.
  3. 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 renders src/components/Home.js.
  4. 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 call api.js, and apiPaths.js builds the URLs.
    Note: no page reaches MapModel.js. Only its test imports it. The tree map is src/components/App.js.
  5. 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 are useEmbed, useFullscreen, useLocalStorage, useMobile, and useClipboard.
  6. 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.js clears the map filters and goes to the URL bounds or the global view.
    Note: CustomWorldMap.js is a react-world-map continent chart on the planter, organization, and wallet pages. It is not the tree map.
  7. 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.js joins the MUI link and the Next.js link. Many components use it.
    Note: no page reaches src/components/search/. SearchFilter.js shows only on /search and /filter.
  8. 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 in PageErrorBoundary and the map in its own ErrorBoundary.
  9. 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.
  10. 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 import test-utils.js. It mounts components with the app theme and a mock router.
  11. 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.
  12. Containers and Kubernetes
    Files: Dockerfile, deployment/base/deployment.yaml, deployment/overlays/prod/kustomization.yaml
    What to see: the Dockerfile runs npm run build inside the image. Dockerfile-dev and Dockerfile-test first copy .env.development or .env.test over .env.production.
  13. 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

UI Components

State and Hooks

Models and API Client

Testing

Infrastructure

CI/CD

Documentation

Configuration

Complexity Hotspots

The graph rates 33 files as complex. Line counts come from the files.

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.

Entity Profiles: detail pages for trees, planters, organizations, wallets, tokens, and version 2 captures.

Search and Discovery: keyword search, date filters, and the Tree Spotlight.

Sharing and Embedding: share a page, and run the tree map inside another site or app.

Authentication and Admin: OIDC sign-in, which the UI hides, and the admin pages.

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).