Architecture Overview

The LEWS system was designed with simplicity and maintainability in mind for the hackathon context. The architecture consists of a Node.js/Express backend with JSON data storage and a modern frontend with slider controls and visualization.

Backend Implementation

The backend uses Node.js with Express to handle API requests:

  • Technology: Node.js with Express.js framework
  • Data Storage: Local JSON files rather than a database (factory_farming.json, insect_farming.json, etc.)
  • Endpoints: Simple REST API with /calculate endpoint that receives 6 inputs and returns score + stage + year match + window
  • Optional Endpoint: /trajectory that returns JSON data for charts

Key design decisions included avoiding authentication, databases, and external APIs to keep the system simple and focused.

Frontend Architecture

The frontend was built with React components and includes:

  • Slider Interface: 6 input sliders (1-5 values) with weighted scoring to generate 0-100 lock-in scores
  • Result Display: Clean result box showing risk score, stage classification, and intervention window
  • Visualization: Simple line chart showing factory farming trajectory
  • Export Functionality: Optional PDF export capability

Data Management

The system uses a JSON-based approach where:

  • Each animal farming technology has its own JSON file with 7 inputs:
    1. Population scale (1-POPULATION_SCALE)
    2. Sentience probability (2-SENTIENCE)
    3. Suffering intensity (3-SUFFERING)
    4. Industry momentum (4-MOMENTUM)
    5. Advocacy gap (5-ADVOCACY)
    6. Lock-in signals (6-LOCKIN)
    7. Uncertainty (7-UNCERTAINTY)
  • Each JSON file contains default slider values, min/max ranges, plain-language notes, and source metadata
  • Frontend loads JSON automatically when user selects chicken, shrimp, fish, or insect farming

Scoring Algorithm

The core scoring formula uses a linear weighted model:

risk_score =
0.30 × scale_norm +
0.20 × suffering_norm +
0.15 × sentience_norm +
0.20 × momentum_norm +
0.10 × advocacy_gap_norm +
0.05 × time_to_lockin_norm

Then apply uncertainty:
lower = score × (1 - uncertainty)
upper = score × (1 + uncertainty)

Pattern Matching Algorithm

For historical trajectory comparison, the system uses simple similarity matching to compare scores to factory farming and return the closest historical year match. For example: "Current shrimp farming today ≈ chicken farming in 1952".

Uncertainty Handling

Uncertainty is implemented as a proportional range applied to the score:

uncertainty_range = ± (score × uncertainty_value)

This approach provides the familiar output format: "Lock-In: 72 (58–86)".

Integration Approach

The team followed a clear integration plan:

  • Backend Development: API endpoints and mock data by early Sunday
  • Frontend Development: UI components built first, then connected to the API
  • Integration Milestone: Complete integration by Hour 15 on Sunday

Optional Features

Additional functionality that could be implemented includes:

  • More sophisticated similarity matching using Dynamic Time Warping (DTW) or regression
  • Multi-technology comparison views
  • Scenario forecasting capabilities
  • Historical retrodiction to validate the model

Future Improvements

Potential enhancements beyond the hackathon MVP:

  • Full Bayesian model for more sophisticated uncertainty handling
  • Non-linear weighting based on empirical validation
  • Cross-species calibration for consistent scoring
  • Machine learning for momentum estimation
  • Multi-technology comparison dashboard