Claude Code Development Guide for MeshMonitor β
This guide provides step-by-step instructions for new developers to set up MeshMonitor for development work using Claude Code as an AI assistant.
Quick Start Prompt for Claude β
New contributors can copy and paste this prompt into Claude Code to get oriented with the project:
I'm a new contributor to MeshMonitor. Please help me get started by:
1. Reading the project instructions in /CLAUDE.md
2. Reviewing docs/development/claude-getting-started.md for the full setup guide
3. Reading docs/ARCHITECTURE_LESSONS.md to understand critical patterns
Then give me a summary of:
- What MeshMonitor is and its tech stack
- How to set up my development environment (I'll tell you if I'm using DevContainer or manual setup)
- The key rules I need to follow when contributing
- Common pitfalls to avoid
I have the repo cloned and ready to configure.After running this prompt, Claude will understand the project context and can help you with:
- Environment setup and troubleshooting
- Understanding the codebase architecture
- Implementing features following project patterns
- Preparing PRs with proper testing
Overview β
MeshMonitor is a full-stack web application for monitoring Meshtastic mesh networks over IP. It consists of:
- Frontend: React 19 + TypeScript + Vite 7
- Backend: Node.js + Express 5 + TypeScript
- Database: SQLite (better-sqlite3)
- Container: Docker with multi-architecture support
Prerequisites β
Before starting, ensure you have:
- Node.js 20+ (22+ recommended)
- npm (comes with Node.js)
- Git with submodule support
- Docker and Docker Compose (for containerized development)
- A Meshtastic device with WiFi/Ethernet connectivity OR
meshtasticdfor virtual testing
Quick Start: DevContainer (Recommended) β
The easiest way to get started is using the DevContainer, which provides a fully configured environment.
VS Code / Cursor β
- Install the "Dev Containers" extension
- Open this project in VS Code/Cursor
- Press
Ctrl+Shift+P(orCmd+Shift+Pon Mac) - Select "Dev Containers: Reopen in Container"
- Wait for container to build (2-5 minutes first time)
- Run
npm run dev:fullto start development
The DevContainer automatically:
- Initializes Git submodules (
protobufs/directory) - Installs npm dependencies
- Creates
.envfrom.env.example - Installs VS Code extensions (ESLint, Prettier, Vitest, etc.)
- Makes Docker available for testing
- Installs Claude Code CLI
Manual Setup β
If not using DevContainer, follow these steps:
Step 1: Clone with Git Submodules β
Critical: MeshMonitor uses Git submodules for Meshtastic protocol definitions. You must include submodules:
git clone --recurse-submodules https://github.com/Yeraze/meshmonitor.git
cd meshmonitorIf you already cloned without submodules:
git submodule update --init --recursiveVerify submodules are initialized:
ls protobufs/meshtastic/mesh.proto
# Should show the file existsStep 2: Install npm Dependencies β
npm installThis installs all frontend and backend dependencies defined in package.json.
Step 3: Configure Environment Variables β
Create a .env file from the template:
cp .env.example .envRequired configuration - Edit .env and set:
# Your Meshtastic node's IP address (required)
MESHTASTIC_NODE_IP=192.168.1.100
# TCP port (default is 4403)
MESHTASTIC_TCP_PORT=4403Optional but useful for development:
PORT=3001 # Backend API port
TZ=America/New_York # Timezone for timestampsStep 4: Start Development Servers β
Option A: Both servers together (recommended)
npm run dev:fullThis starts both frontend (Vite) and backend (Express) with hot reload.
Option B: Separate terminals
# Terminal 1: Frontend
npm run dev
# Terminal 2: Backend
npm run dev:serverStep 5: Access the Application β
- Frontend (dev server): http://localhost:5173
- Backend API: http://localhost:3001
The Vite dev server proxies API requests to the Express backend automatically.
Docker Development β
For testing the full containerized deployment (closer to production):
Build and Run β
# Build from local code
docker compose -f docker-compose.dev.yml build
# Start the container
docker compose -f docker-compose.dev.yml up -d
# Access at http://localhost:8081/meshmonitorImportant Notes:
- Development Docker uses port 8081 (to avoid conflicts with DevContainer)
- The
BASE_URLis configured as/meshmonitorfor testing subfolder deployments - You cannot run Docker AND
npm run dev:fullsimultaneously (port conflicts)
Verify Your Code Is Deployed β
After starting Docker, verify the correct code is running:
docker compose -f docker-compose.dev.yml logs meshmonitor | head -20Look for the version number in the startup logs.
Running Tests β
Unit Tests β
npm run test # Watch mode
npm run test:run # Single run (CI mode)
npm run test:coverage # With coverage report
npm run test:ui # Interactive Vitest UISystem Tests β
The full system test suite validates the complete deployment:
./tests/system-tests.shThis script:
- Builds a fresh Docker image
- Runs Quick Start tests
- Runs Reverse Proxy tests
- Runs Virtual Node tests
- Runs Backup/Restore tests
- Produces a test report
Note: The system tests require a specific hardware/network setup that may not be available to all contributors.
For PRs involving core functionality or node communication changes:
- Request @Yeraze to run the system tests on your PR
- Tag the PR with a comment like: "This PR modifies node communication - requesting @Yeraze to run system tests"
- The test results will be posted back on the PR
Type Checking and Linting β
npm run typecheck # TypeScript type checking
npm run lint # ESLintKey Documentation to Review β
Before implementing features, review these critical documents:
| Document | When to Read |
|---|---|
| ARCHITECTURE_LESSONS.md | Before ANY node communication, state management, backup/restore, or async operations |
| SYSTEM_ARCHITECTURE.md | Understanding overall system design |
| API Documentation | Working with REST API endpoints |
| SCHEMA.md | Database schema and models |
| AUTHENTICATION.md | Auth implementation details |
| FAQ.md | Common issues and solutions |
Claude Code Instructions β
When using Claude Code for development on this project, these rules are enforced via CLAUDE.md:
Critical Rules β
Review ARCHITECTURE_LESSONS.md first - Before implementing node communication, state management, backup/restore, or async operations
Backend-only node communication - The frontend NEVER talks directly to the Meshtastic node. All node communication goes through the backend.
Use Docker for development - Start the dev environment via Docker and always build first
No direct pushes to main - Always create a branch for your work
System tests for core changes - For PRs involving core functionality or node communication, request @Yeraze to run system tests
Testing channel - When sending test messages, use the "gauntlet" channel. Never send on Primary!
BASE_URL in testing - The webserver has
BASE_URL=/meshmonitorconfigured for testingVersion updates - When updating versions, change:
package.json, Helm chart, Tauri config, then regeneratepackage-lock.json
Context for Claude β
The project includes comprehensive instructions in:
/CLAUDE.md- Project-level instructions/.claude/instructions.md- Detailed agent context (if using DevContainer)
Common Problems and Solutions β
Submodule Issues β
Problem: Protobuf-related errors or missing files
# Force update submodules
git submodule foreach --recursive git clean -fxd
git submodule update --init --recursive --force
# Verify
ls protobufs/meshtastic/mesh.protoPort Already in Use β
Problem: "Port 5173 is in use" or "Port 3001 is in use"
# Find what's using the port
lsof -i :5173
lsof -i :3001
# Kill the process
kill -9 <PID>
# Or stop conflicting Docker containers
docker compose -f docker-compose.dev.yml downDocker and npm Running Simultaneously β
Problem: Strange behavior, connection issues
You cannot run both the Docker environment and npm run dev:full at the same time. They will conflict on ports and the node connection.
Solution: Choose one:
# Stop Docker
docker compose -f docker-compose.dev.yml down
# Then run npm
npm run dev:fullOr vice versa.
Node Version Issues β
Problem: Errors about unsupported Node.js features
# Check version
node --version # Should be v20.x.x or higher
# Use nvm to switch
nvm install 22
nvm use 22Database Issues β
Problem: Database errors or corruption
# Development (local)
rm -f data/meshmonitor.db
# Restart dev server - database will be recreated
# Docker
docker compose -f docker-compose.dev.yml down -v
docker compose -f docker-compose.dev.yml up -dTypeScript Errors After Changes β
Problem: Type errors that don't make sense
# Clear caches
rm -rf node_modules/.cache
# Full reset
rm -rf node_modules package-lock.json
npm installCan't Connect to Meshtastic Node β
Problem: "Cannot connect to node" errors
Verify node is reachable:
bashping 192.168.1.100 # Use your node's IPCheck TCP port:
bashtelnet 192.168.1.100 4403 # Or: nc -zv 192.168.1.100 4403Verify node settings:
- Ensure WiFi/Ethernet is enabled on the node
- Check that TCP is enabled in the node's network settings
- Confirm port 4403 is accessible
Test with Meshtastic CLI:
bashpip install meshtastic meshtastic --host 192.168.1.100
CORS/Blank Page Issues β
Problem: Blank white screen or CORS errors in browser console
Set ALLOWED_ORIGINS in your .env file:
# For localhost access
ALLOWED_ORIGINS=http://localhost:5173,http://localhost:3001
# For Docker on port 8081
ALLOWED_ORIGINS=http://localhost:8081
# Multiple origins
ALLOWED_ORIGINS=http://localhost:5173,http://localhost:8081,http://192.168.1.50:8080Container Doesn't Have sqlite3 Binary β
The Docker container doesn't include the sqlite3 CLI tool. If you need to inspect the database:
# Copy database out of container
docker cp meshmonitor:/data/meshmonitor.db ./meshmonitor.db
# Use sqlite3 on your host
sqlite3 meshmonitor.db ".tables"Or use the DevContainer which includes sqlite3.
Project Structure Overview β
meshmonitor/
βββ src/
β βββ server/ # Backend (Express API)
β β βββ server.ts # Main server entry
β β βββ routes/v1/ # API endpoints
β β βββ models/ # Database models
β β βββ services/ # Business logic
β β βββ middleware/ # Express middleware
β β βββ auth/ # Authentication
β β βββ migrations/ # DB migrations
β βββ pages/ # React route pages
β βββ components/ # React components
β βββ hooks/ # Custom React hooks
β βββ services/ # Frontend services
β βββ contexts/ # React Context
β βββ types/ # TypeScript types
β βββ test/ # Test utilities
βββ tests/ # Integration tests
β βββ system-tests.sh # Full test suite
β βββ unit/ # Unit test files
βββ docs/ # VitePress documentation
βββ protobufs/ # Git submodule: Meshtastic protos
βββ helm/ # Kubernetes Helm charts
βββ desktop/ # Tauri desktop app
βββ docker-compose.yml # Production config
βββ docker-compose.dev.yml # Development config
βββ Dockerfile # Production build
βββ vite.config.ts # Vite configuration
βββ vitest.config.ts # Test configuration
βββ tsconfig.json # Frontend TypeScript
βββ tsconfig.server.json # Backend TypeScript
βββ CLAUDE.md # Claude Code instructionsAvailable npm Scripts β
| Script | Description |
|---|---|
npm run dev | Start frontend dev server (Vite, port 5173) |
npm run dev:server | Start backend dev server (Express, port 3001) |
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 lint | Run ESLint |
npm run typecheck | Check TypeScript types |
npm test | Run tests in watch mode |
npm run test:run | Run all tests once |
npm run test:coverage | Generate coverage report |
npm run docs:dev | Start documentation server |
Workflow Summary β
- Clone with submodules:
git clone --recurse-submodules ... - Install dependencies:
npm install - Configure environment:
cp .env.example .envand setMESHTASTIC_NODE_IP - Start development:
npm run dev:fullor use Docker - Create a branch:
git checkout -b feature/my-feature - Make changes: Follow ARCHITECTURE_LESSONS.md patterns
- Run unit tests:
npm run test:run - Create PR: Never push directly to main
- Request system tests: For core/node changes, ask @Yeraze to run system tests
Getting Help β
- Documentation: https://meshmonitor.org/
- GitHub Issues: https://github.com/Yeraze/meshmonitor/issues
- Discord: https://discord.gg/JVR3VBETQE
- FAQ: /faq
Happy coding! π