Development Setup β
This guide covers setting up a local development environment for contributing to MeshMonitor.
π³ DevContainer (Recommended) β
For the easiest setup, we recommend using the DevContainer. This provides a pre-configured environment with all dependencies (Node.js, Python, Git, Docker) ready to go.
Quick Start:
- Open the project in VS Code or Cursor.
- Press
Ctrl+Shift+Pand select "Dev Containers: Reopen in Container". - Wait for it to build, then run
npm run dev:full.
See .devcontainer/README.md for full details.
Manual Setup Prerequisites β
Before you begin, ensure you have:
- Node.js 20+ (Node.js 22+ recommended)
- npm (comes with Node.js)
- Git with submodule support
- A Meshtastic device connected to your network via IP (WiFi or Ethernet)
- OR
meshtasticdrunning as a virtual node
Quick Start β
1. Clone the Repository β
Important: MeshMonitor uses Git submodules for protocol definitions. Clone with --recurse-submodules:
git clone --recurse-submodules https://github.com/yeraze/meshmonitor.git
cd meshmonitorIf you already cloned without submodules:
git submodule update --init --recursive2. Install Dependencies β
npm installThis installs all frontend and backend dependencies defined in package.json.
3. Set Environment Variables β
Create a .env file or export environment variables:
export MESHTASTIC_NODE_IP=192.168.1.100 # Your node's IP
export MESHTASTIC_TCP_PORT=4403 # Default Meshtastic portOptional environment variables:
export PORT=3001 # Backend API port
export TZ=America/New_York # Timezone for timestamps4. Start the Development Server β
MeshMonitor has two components that need to run:
Option 1: Run both together (recommended)
npm run dev:fullThis starts both the frontend (Vite) and backend (Express) in a single terminal using concurrently.
Option 2: Run separately in two terminals
# Terminal 1: Frontend (Vite dev server)
npm run dev
# Terminal 2: Backend (Express API)
npm run dev:server5. Access the Development Server β
Open your browser to:
http://localhost:5173 # Frontend (Vite dev server with hot reload)The backend API runs on:
http://localhost:3001 # Backend (Express API)How it works:
- The Vite dev server (port 5173) proxies API requests to the Express backend (port 3001)
- Frontend changes hot-reload automatically
- Backend changes restart the server automatically (via
tsx --watch)
Development Workflow β
Making Changes β
Frontend changes (React components, CSS):
- Edit files in
src/components/,src/App.tsx, or CSS files - Changes hot-reload automatically in the browser
- No manual refresh needed
- Edit files in
Backend changes (API routes, database):
- Edit files in
src/server/orsrc/services/ - Server automatically restarts via
tsx --watch - Refresh browser to see API changes
- Edit files in
Protocol changes (Meshtastic protobufs):
- Update submodule:
git submodule update --remote - Regenerate types if needed
- Update submodule:
Running Tests β
# Run all tests in watch mode
npm test
# Run tests once (CI mode)
npm run test:run
# Run tests with UI
npm run test:ui
# Generate coverage report
npm run test:coverageType Checking β
# Check TypeScript types (frontend + backend)
npm run typecheckLinting β
# Run ESLint
npm run lintBuilding for Production β
# Build frontend
npm run build
# Build backend
npm run build:server
# Run production build
npm startUsing with Physical or Virtual Devices β
Virtual Nodes with meshtasticd β
If you're developing without physical hardware, use meshtasticd for virtual node simulation:
# Install meshtasticd
pip install meshtasticd
# Run a virtual node
meshtasticd --hwmodel RAK4631
# Point MeshMonitor to localhost
export MESHTASTIC_NODE_IP=localhost
npm run dev:fullSee the meshtasticd configuration guide for more details.
Serial/USB Devices β
For Serial or USB-connected Meshtastic devices, use the Meshtastic Serial Bridge:
# Run the serial bridge
docker run -d --device /dev/ttyUSB0:/dev/ttyUSB0 -p 4403:4403 \
ghcr.io/yeraze/meshtastic-serial-bridge:latest
# Point MeshMonitor to localhost
export MESHTASTIC_NODE_IP=localhost
npm run dev:fullBluetooth Devices β
For Bluetooth Low Energy (BLE) Meshtastic devices, use the MeshMonitor BLE Bridge:
# Run the BLE bridge (see BLE Bridge documentation for setup)
docker compose -f docker-compose.ble.yml up -d
# Point MeshMonitor to localhost
export MESHTASTIC_NODE_IP=localhost
npm run dev:fullDevelopment Environment Details β
Project Structure β
meshmonitor/
βββ src/
β βββ components/ # React components
β βββ services/ # Services (Meshtastic, Database)
β βββ server/ # Express server
β β βββ auth/ # Authentication logic
β β βββ config/ # Configuration handling
β β βββ middleware/ # Express middleware
β βββ utils/ # Shared utilities
β βββ App.tsx # Main React application
βββ docs/ # Documentation (VitePress)
βββ tests/ # Test files
βββ data/ # SQLite database (development)
βββ public/ # Static assets
βββ package.json # Dependencies and scripts
βββ tsconfig.json # TypeScript config (frontend)
βββ tsconfig.server.json # TypeScript config (backend)
βββ vite.config.ts # Vite configurationAvailable npm Scripts β
| Script | Description |
|---|---|
npm run dev | Start frontend dev server (Vite) |
npm run dev:server | Start backend dev server (Express) |
npm run dev:full | Start both frontend and backend |
npm run build | Build frontend for production |
npm run build:server | Build backend for production |
npm start | Start production server |
npm run preview | Preview production build |
npm run lint | Run ESLint |
npm run typecheck | Check TypeScript types |
npm test | Run tests in watch mode |
npm run test:ui | Run tests with interactive UI |
npm run test:run | Run all tests once |
npm run test:coverage | Generate coverage report |
npm run docs:dev | Start VitePress docs server |
npm run docs:build | Build documentation |
Environment Modes β
MeshMonitor behaves differently in development vs production:
Development Mode (NODE_ENV=development or unset):
- Verbose logging
- Auto-generated SESSION_SECRET (with warning)
- CORS allows
http://localhost:5173andhttp://localhost:3001 - Secure cookies disabled (works over HTTP)
- Hot reload for frontend
- Auto-restart for backend
Production Mode (NODE_ENV=production):
- Minimal logging
- SESSION_SECRET required (errors if not set)
- CORS requires explicit ALLOWED_ORIGINS
- Secure cookies enabled (requires HTTPS)
- Optimized build
- Static file serving
Helper Scripts β
To simplify managing the dev container lifecycle, we provide helper scripts in the .devcontainer/ directory:
| Task | Bash (Linux/Mac/WSL) | PowerShell (Windows) | Description |
|---|---|---|---|
| Stop | ./.devcontainer/scripts/stop.sh | .\.devcontainer\scripts\stop.ps1 | Stops the running container. |
| Clean | ./.devcontainer/scripts/clean.sh | .\.devcontainer\scripts\clean.ps1 | Stops container and removes volumes (fixes corruption). |
| Reset | ./.devcontainer/scripts/reset.sh | .\.devcontainer\scripts\reset.ps1 | Runs clean, then rebuilds the container image (fresh start). |
Troubleshooting Development Issues β
Port Already in Use β
If you see Port 5173 is in use or Port 3001 is in use:
# Find process using port
lsof -i :5173
lsof -i :3001
# Kill process
kill -9 <PID>Database Issues β
Development database is stored in data/meshmonitor.db. To reset:
rm -f data/meshmonitor.db
# Restart dev server - database will be recreatedSubmodule Issues β
If you see protobuf-related errors:
# Update submodules
git submodule update --init --recursive
# If that doesn't work, force update
git submodule foreach --recursive git clean -fxd
git submodule update --init --recursive --forceTypeScript Errors β
# Clear TypeScript cache
rm -rf node_modules/.cache
# Reinstall dependencies
rm -rf node_modules package-lock.json
npm installNode Version Issues β
MeshMonitor requires Node.js 20+. Check your version:
node --version # Should be v20.x.x or higherUse nvm to manage Node.js versions:
nvm install 20
nvm use 20IDE Setup β
VS Code (Recommended) β
Recommended Extensions:
Workspace Settings (.vscode/settings.json):
{
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
},
"typescript.tsdk": "node_modules/typescript/lib"
}WebStorm / IntelliJ IDEA β
- Enable ESLint: Settings β Languages & Frameworks β JavaScript β Code Quality Tools β ESLint
- Enable TypeScript: Settings β Languages & Frameworks β TypeScript
Next Steps β
- Architecture Guide - Understand the system design
- Database Schema - Learn about data structures
- API Documentation - Explore API endpoints
- Authentication - Understand auth implementation
Contributing β
Ready to contribute? See the main CONTRIBUTING.md for:
- Code style guidelines
- Pull request process
- Testing requirements
- CI/CD workflows