How dali-lab/pine-beetle-frontend works
Project Type and Purpose
• This is a full-stack web application (“Project Pine Beetle”) for visualizing historical and predicted Southern Pine Beetle outbreaks.
• Frontend: React + Redux + React-Router, bundled by webpack, deployed on Netlify.
• Backend: Two Node/Express servers (main CRUD/auth server + automation server). Data stored in MongoDB. Predictive model in R. External data ingestion via Survey123 webhooks.
File Structure
• Top-level:
• config files (.env.example, webpack.config.js, babel.config.js, .eslintrc.json)
• package.json / lockfile
• downloads/ (static PDFs and zips)
• mapbox-tiles/ (scripts and README)
• src/:
• components/ (reusable UI components)
• screens/ (page containers, subcomponents)
• services/ (API wrappers using axios)
• state/ (Redux: actions/reducers)
• utils/, constants/, styles/
• index.html + index.js (app entry)
Extract Key Architecture Notes from README
• Frontend served as static build by Netlify.
• Frontend calls two backend servers:
• Main backend (CRUD/auth, data queries)
• Automation server (data ingestion/aggregation via Survey123 webhooks)
• Backend servers interact with MongoDB.
• Predictive model executed in R (called by main backend).
• External third-party: Mapbox (tilesets & styles), Chart.js for graphs.
Main Components & Relationships
a. Frontend (Client):
• React App (components, screens)
• Redux Store (state/actions/reducers)
• React-Router (route switching)
• Service Layer (axios calls)
• Mapbox GL & Chart.js
b. Static Hosting: Netlify
c. Main Backend (Express/Node):
• API Endpoints (CRUD, auth, data queries)
• R Predictive Model integration
• Calls to MongoDB
d. Automation Server (Express/Node):
• Webhooks from Survey123 (external)
• Data transformation & aggregation
• Writes to MongoDB
e. Database: MongoDB
f. External Services:
• Survey123 (USFS data source)
• Mapbox API (tiles, styles)
g. Users:
• Public users & authenticated researchers (UI interactions)
Architectural Patterns & Design Principles
• Frontend: componentized React + Redux for unidirectional data flow.
• Separation of concerns: UI vs. API vs. data ingestion vs. predictive engine.
• Service layer abstracts HTTP calls (services/*.js → state/actions).
• Mapbox and Chart.js handle visualization.
• CI/CD via Netlify workflows (GitHub → dev/release branches).