choppingboard
v1.0.11
Published
Salad monitoring server as an npm module with SQLite backend
Downloads
854
Readme
Chopping Board - Salad Analytics Dashboard
A comprehensive monitoring and analytics platform for tracking Salad chopping earnings, electricity consumption, and machine performance. Built with Node.js, Express, and SQLite.
Overview
Chopping Board provides real-time insights into your Salad chopping operations across multiple machines. Track earnings, monitor power consumption with TPLink smart meters, calculate profitability, and visualize performance trends through an intuitive web dashboard.
Features
Earnings Tracking
- Multi-Machine Monitoring - Track unlimited machines across your Salad account
- Real-time Earnings - Hourly and daily earnings with automatic updates every 5 minutes
- Moving Averages - 7, 14, 30, 50, and 100-day moving averages for trend analysis
- Earnings Predictions - Estimated daily earnings based on current performance
- Reward Management - Track and assign Salad rewards to your sub-accounts
- Export Data - Download earnings data as a CSV
Energy Monitoring
- TPLink Integration - Monitor electricity consumption via TPLink (KP115) smart meters
- Cost Analysis - Calculate electricity costs with configurable KWh pricing
- Profit Tracking - Real-time profit calculations (earnings minus electricity costs)
- Machine-Level Power - Per-machine power consumption tracking
Data Visualization
- Interactive Charts - Dynamic charts with Chart.js (line/bar graph toggle)
- Multiple Views - Daily, hourly, 7-day, 14-day, and 30-day timeframes
- Customizable Displays - Filter by machine, profile, or view total aggregated data
- Export Charts - Copy chart images to clipboard with one click
Machine Management
- Custom Names & Colors - Personalize machine labels and graph colors
- Account Assignment - Organize machines by owner/sub-account
- Visibility Toggle - Show/hide machines from charts and tables
- Lifetime Tracking - Historical balance and creation timestamps
Privacy & Security
- Data Blurring - Toggle visibility for earnings, balances, IPs, MAC addresses, and dates
- Session Management - Secure session handling with CSRF protection
- Local Storage - All data stored locally in SQLite (no external analytics)
Prerequisites
- Node.js v14 or higher
- npm (comes with Node.js)
- Salad Account - You'll configure your auth token after installation via the web dashboard
- TPLink Smart Meter (optional, for power monitoring)
Installation
1. Install Node.js and npm
If you don't have Node.js installed, download and install it from the official website:
Download Node.js - Choose the LTS (Long Term Support) version
This will install both Node.js and npm. Verify the installation by running in a command terminal:
node --version
npm --version2. Initialize Your Project
Create a project folder anywhere you like: For example, on Mac, ~/choppingboard Or on Windows, C:\choppingboard
Navigate to your project folder in a terminal and initialize a new Node.js project:
npm init -yThis creates a package.json file in your project folder, which is required for installing packages.
3. Create Your Server File
Create a new file (e.g., app.js) in your project folder:
const { start } = require('choppingboard');
const path = require('path');
const server = start({
port: 3001, // Server port
databasePath: path.join(__dirname, 'data', 'salad.db') // Database location
});4. Install Package
npm install choppingboardNote that on Apple Silicon Macs you will need XCode and Homebrew to install dependencies to compile canvas.js
5. Start the Server
Run your server file:
node app.jsOr add a start script to your package.json:
{
"scripts": {
"start": "node app.js"
}
}Then run:
npm start6. Access Dashboard and Configure Auth Token
Open your browser and navigate to:
http://localhost:3001On first run, you'll see a warning icon in the navigation bar indicating that you need to configure your Salad auth token.
To add your auth token:
- Click on the Settings dropdown in the navigation bar
- Select Auth Token (see ⚠️ SECURITY WARNING: ⚠️ below)
- To get your token on Chrome:
- Open browser Developer Tools (F12)
- Log into your Salad account at https://salad.com/login
- Go to the Application tab
- Under Storage, find Cookies →
https://salad.com - Copy the value of the
authcookie
- Paste the token into the input field and click Save
- The warning will disappear once a valid token is configured
⚠️ SECURITY WARNING: ⚠️ Never share your Salad auth token with anyone. This token provides full access to your Salad account, including earnings, personal information, and the ability to redeem rewards. Treat it like a password and keep it private.
The database will automatically initialize on first run (could take up to ten minutes to see data).
7. Create Profile(s) and Assign Machine(s)
Under "Settings", select "Profiles"
Click the blue + icon on the tab and create a profile.
Then back under "Settings", select "Machines"
If your salad earnings data has been initialized, you will see your machines in there. Click the blue buttons on the table rows to assign the machines to whichever profile you want.
Configuration
Application Settings
Configure via your server file:
| Setting | Description | Default |
|---------|-------------|---------|
| port | Server port number | 3001 |
| databasePath | SQLite database file location | ./data/salad.db |
Dashboard Settings (via Web Interface)
Additional settings configurable through the web dashboard:
Auth Token (Settings → Auth Token):
- Salad Auth Token - Required for API access. Configure this first on initial setup.
App Settings:
| Setting | Description | Default |
|---------|-------------|---------|
| Dashboard Refresh Interval | How often the dashboard polls the server (minutes) | 2 |
| KWh Price | Electricity cost per kilowatt-hour | 0.105 |
Database Location
The SQLite database is stored at the path specified in databasePath. The data/ directory is created automatically if it doesn't exist.
Default: ./data/salad.db
Data Collection vs Dashboard Refresh
Data Collection Interval (Server-side):
- The server automatically fetches data from Salad's API every 5 minutes (hardcoded)
- This includes earnings data, machine status, and TPLink meter readings
- Cannot be changed via dashboard settings
Dashboard Refresh Interval (Client-side):
- Controls how often your browser refreshes the dashboard data from the server
- Configurable in "App Settings" (default: 2 minutes)
- Only affects how often the dashboard updates, not how often data is collected
Usage
Dashboard Overview
The main dashboard displays:
- Current Balance - Total Salad balance across all accounts
- Today's Earnings - Current day earnings with prediction
- Yesterday's Earnings - Previous day totals
- 24-Hour Earnings - Rolling 24-hour window
- 7/14/30-Day Earnings - Weekly, biweekly, and monthly totals with moving averages
Interactive Charts
- Chart/Table Toggle - Switch between visual and tabular data
- Line/Bar Graph - Choose visualization style
- Zoom Levels - 1x, 1.5x, 2x chart height
- Machines/Total Toggle - View per-machine or aggregated data
- Copy Chart - Green button to copy chart as PNG image to clipboard
Managing Profiles
Create multiple accounts to organize machines by owner:
- Go to "Profiles" under "Settings"
- Click "New Account"
- Enter username and profile details
- Assign machines to the account
Managing Machines
Assign to Account:
- Find machine in machines settings
- Select owner from dropdown
- Changes save automatically
Rename Machine:
- Go to Machines Settings
- Click highlighted machine name/id
- Enter new name and select color
- Click "Save"
Hide/Show Machine:
- Toggle visibility checkbox in machine row
- Hidden machines excluded from charts but remain in database
Adding Smart Meters
- Ensure TPLink device is on the same network
- Navigate to "Emeters Table"
- Click "Add Emeter"
- Enter device IP address
- Select meter type (TPLink)
- Assign to a machine
- Data collection begins automatically
Privacy Settings
Toggle data blurring in the dashboard:
- Blur Balances - Hide current and lifetime balances
- Blur Earnings - Hide earnings amounts
- Blur Costs - Hide electricity cost calculations
- Blur IP/MAC - Hide smart meter network addresses
- Blur Machine IDs - Hide Salad machine IDs
- Blur Dates - Hide timestamps
API Endpoints
Data Retrieval
| Method | Endpoint | Description |
|--------|----------|-------------|
| GET | / | Main dashboard (daily view) |
| GET | /hourly | Hourly earnings view |
Configuration
| Method | Endpoint | Description |
|--------|----------|-------------|
| POST | /postStartEnd | Update chart date range |
| POST | /postAppSettings | Update KWh price and refresh interval |
| POST | /postUpdateAuthToken | Update Salad API token |
| POST | /postChartSettings | Configure graph type and display mode |
Machine Management
| Method | Endpoint | Description |
|--------|----------|-------------|
| POST | /postAssign | Assign machine to account |
| POST | /postMachineName | Update machine name and color |
| POST | /postRemoveMachine | Delete machine from database |
Smart Meters
| Method | Endpoint | Description |
|--------|----------|-------------|
| POST | /postEmeter | Add or configure smart meter |
Accounts & Rewards
| Method | Endpoint | Description |
|--------|----------|-------------|
| POST | /postNewAccount | Create new account |
| POST | /postAssignReward | Assign reward recipient |
| POST | /postIntervalRefresh | Trigger manual data refresh |
Database Schema
The application uses SQLite with the following tables:
Core Tables
- machine - Machines with lifetime balance and metadata
- machineOwner - Machine-to-account assignments
- account - User accounts and profiles
- auth - Salad API authentication tokens
- hourlyIncome - Hourly earnings per machine
- incomeDaily - Daily aggregated earnings with moving averages
- reward - Salad rewards (pending and redeemed)
- log - System event logging
Energy Monitoring
- emeter - Smart meter device information
- emeterList - Supported meter types (TPLink)
- emeterDailyEnergyUsage - Daily power consumption per machine
Features
- Auto-updating timestamps via triggers
- Indexed columns for performance
- UPSERT patterns for conflict resolution
- Foreign key enforcement
Module Structure:
app.js- Main server initialization and exportslib/- Database schema and query functionsservice/- Salad API and TPLink integrationwebsite/- Express routes, views, and static assets
Advanced users can explore the module structure in node_modules/choppingboard/ after installation, though the primary interface is the configuration object passed to start().
Troubleshooting
Database Errors
Issue: Database not initialized error
- Solution: Ensure
databasePathis writable and the directory exists
Issue: Database file locked
- Solution: Close other connections to the SQLite file. Better-sqlite3 uses WAL mode for better concurrency.
Authentication Issues
Issue: 401 Unauthorized from Salad API
- Solution: Update your Salad auth token via the web dashboard (Settings → Auth Token)
Issue: Token expired
- Solution: Get a fresh token from https://app.salad.com and update it via the web dashboard (Settings → Auth Token)
Issue: No auth token configured (warning icon in navigation)
- Solution: Configure your Salad auth token via the web dashboard (Settings → Auth Token) - see Step 5 in Installation section
TPLink Connection Issues
Issue: Smart meter not found
- Solution: Verify device is on the same network and IP address is correct
Issue: No power data showing
- Solution: Ensure the emeter is assigned to a machine and wait for the next data collection cycle (5 minutes)
Port Already in Use
Issue: EADDRINUSE: address already in use :::3001
- Solution: Change the port in your server file or stop the process using port 3001
# Find process using port 3001
lsof -i :3001
# Kill the process (replace PID with actual process ID)
kill -9 PIDData Privacy
All data is stored locally in your SQLite database. Chopping Board does not send your earnings data, machine information, or any analytics to third-party servers. The only external connections are:
- Salad API (
app-api.salad.com) - To fetch your earnings data - TPLink Devices - Local network communication only
- npmjs.com - Retrieves latest package version number
Contributing
Contributions are welcome! Please feel free to contact us on the Discord linked in the dashboard!
License
This project is open source under the ISC license.
Support
For questions, issues, or feature requests, please open a ticket on the Discord server.
Happy Chopping! 🥗
