# macgreene14/forest-fuel-finder architecture

> Architecture diagram of the GitHub repository macgreene14/forest-fuel-finder, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-17). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/macgreene14/forest-fuel-finder
- Repository: https://github.com/macgreene14/forest-fuel-finder

## Overview

##### Project type and purpose
- The Forest Fuel Finder is a frontend‐centric, full‐stack‐style web application built with Next.js (App Router) for server‐side rendering (SSR) and static generation (SSG).
- It displays USDA raster maps on a Mapbox map, providing interactive mapping, search/geocoding, and responsive styling via Tailwind CSS.

##### File structure
- Top‐level config files: next.config.js, tailwind.config.ts, postcss.config.js, tsconfig.json – indicate Next.js + Tailwind CSS build pipeline.
- src/app: Uses Next.js 13 App Router.
- app/page.tsx – root map view page.
- app/layout.tsx – global layout (includes navbar.jsx).
- app/components – React components: LogCam.jsx, iFly.js, iLegend.js for custom map overlays/legends.
- app/info/page.tsx – info sub‐page.
- globals.css – Tailwind imports and global styles.
- package.json & lock: Node/NPM dependency management.
- README.md: Confirms Mapbox + USDA raster integration, Vercel deployment.

##### README insights
- The app uses Mapbox SDK (client‐side JS) for interactive mapping and geocoding for search.
- USDA raster map tiles are overlaid via Mapbox raster source.
- Deployment target: Vercel (SSR, CDN for static assets).

##### Main components and their interactions
a. Components:
- Client (Browser) – renders UI, runs React/Mapbox JS.
- Next.js Server (Vercel) – SSR/SSG, serves HTML/CSS/JS, API Routes (if any).
- CDN (Vercel) – hosts static assets from /public and built JS/CSS bundles.
- Mapbox Service – Map rendering engine, Mapbox GL JS, geocoding API.
- USDA Raster Tile Server – external raster tile endpoint serving fuel data.
- Developer Toolchain – Node.js, NPM, ESLint, Tailwind/PostCSS (build‐time).

b. Interactions and data flow:
1. User → Next.js on Vercel: initial GET request for `/` or `/info`
2. Next.js (SSR/SSG) → CDN/HTML: returns pre‐rendered HTML + CSS (Tailwind) + JS bundle
3. Browser executes React hydration → interactive UI (navbar, map container)
4. Mapbox GL JS (in browser) → Mapbox API: fetch style, vector tiles, geocoding on search
5. Mapbox (via raster‐source config) → USDA Raster Server: fetch map tiles showing fuel data
6. Browser renders overlay, legends, custom components (LogCam, iFly, iLegend)
7. All static assets (images, CSS) are pulled from Vercel CDN

##### Architectural patterns and design principles
- Component‐based UI with React and Next.js App Router
- SSR/SSG hybrid: pages are either statically generated at build or rendered server‐side per request
- Separation of concerns:
- Routing & layout in Next.js (src/app)
- Presentation in React components
- Styling via Tailwind (utility‐first CSS)
- External integration pattern: abstract Mapbox & USDA tile source configuration into reusable components

##### Essential elements
- Clear component labels
- Call out key technologies on each component (Next.js, Tailwind, Mapbox GL JS, USDA Raster)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% User
    Browser["User Browser\n(React & Mapbox GL JS)"]:::user

    %% Next.js App Router and Pages
    subgraph "Next.js App Router"
        direction TB
        AppRouter["App Router\n(src/app)"]:::internal
        Page["Root Map View Page\n(page.tsx)"]:::internal
        Info["Info Sub‑Page\n(info/page.tsx)"]:::internal
        Layout["Global Layout\n(layout.tsx)"]:::internal
        Navbar["Navbar Component\n(navbar.jsx)"]:::internal
        subgraph "Map Overlay & Legend Components"
            direction TB
            LogCam["LogCam\n(Component)"]:::internal
            iFly["iFly\n(Component)"]:::internal
            iLegend["iLegend\n(Component)"]:::internal
        end
        GlobalsCSS["Global Styles\n(globals.css)"]:::internal
    end

    %% CDN
    Public["Vercel CDN\n(static assets)"]:::internal

    %% External Services
    Mapbox["Mapbox Service\n(Mapbox GL JS & Geocoding)"]:::external
    USDA["USDA Raster Tiles\n(Remote Tile Server)"]:::external

    %% Build Tools & Configs
    subgraph "Build Tools & Configs"
        direction TB
        Package["package.json"]:::build
        Lock["package-lock.json"]:::build
        ESLint[".eslintrc.json"]:::build
        NextConfig["next.config.js"]:::build
        TailwindConfig["tailwind.config.ts"]:::build
        PostCSS["postcss.config.js"]:::build
        TSConfig["tsconfig.json"]:::build
        Declarations["declarations.d.ts"]:::build
    end

    %% Data Flows
    Browser -->|"GET / or /info"| AppRouter
    AppRouter -->|"HTML + CSS + JS bundle"| Browser
    Browser -->|"fetch assets"| Public
    Browser -->|"Geocoding API call"| Mapbox
    Browser -->|"Raster tile fetch"| Mapbox
    Mapbox -->|"tile proxy"| USDA
    Package -.->|build-time| AppRouter

    %% Legend
    subgraph Legend
        L1["--> solid: request/response"] 
        L2["-.-> dashed: build-time or client resource"] 
    end

    %% Click Events
    click AppRouter "https://github.com/macgreene14/forest-fuel-finder/tree/main/src/app"
    click Page "https://github.com/macgreene14/forest-fuel-finder/blob/main/src/app/page.tsx"
    click Info "https://github.com/macgreene14/forest-fuel-finder/blob/main/src/app/info/page.tsx"
    click Layout "https://github.com/macgreene14/forest-fuel-finder/blob/main/src/app/layout.tsx"
    click Navbar "https://github.com/macgreene14/forest-fuel-finder/blob/main/src/app/navbar.jsx"
    click LogCam "https://github.com/macgreene14/forest-fuel-finder/blob/main/src/app/components/LogCam.jsx"
    click iFly "https://github.com/macgreene14/forest-fuel-finder/blob/main/src/app/components/iFly.js"
    click iLegend "https://github.com/macgreene14/forest-fuel-finder/blob/main/src/app/components/iLegend.js"
    click GlobalsCSS "https://github.com/macgreene14/forest-fuel-finder/blob/main/src/app/globals.css"
    click Public "https://github.com/macgreene14/forest-fuel-finder/tree/main/public/"
    click NextConfig "https://github.com/macgreene14/forest-fuel-finder/blob/main/next.config.js"
    click TailwindConfig "https://github.com/macgreene14/forest-fuel-finder/blob/main/tailwind.config.ts"
    click PostCSS "https://github.com/macgreene14/forest-fuel-finder/blob/main/postcss.config.js"
    click TSConfig "https://github.com/macgreene14/forest-fuel-finder/blob/main/tsconfig.json"
    click Package "https://github.com/macgreene14/forest-fuel-finder/blob/main/package.json"
    click Lock "https://github.com/macgreene14/forest-fuel-finder/blob/main/package-lock.json"
    click ESLint "https://github.com/macgreene14/forest-fuel-finder/blob/main/.eslintrc.json"
    click Declarations "https://github.com/macgreene14/forest-fuel-finder/blob/main/declarations.d.ts"

    %% Styles
    classDef internal fill:#BBDEFB,stroke:#1E88E5,color:#0D47A1
    classDef external fill:#C8E6C9,stroke:#388E3C,color:#1B5E20
    classDef user fill:#FFF9C4,stroke:#FBC02D,color:#F57F17
    classDef build fill:#E1BEE7,stroke:#8E24AA,color:#4A148C
```
