Development Guide

How to set up and run DefenSys for development. For contributors and anyone extending the app.

Prerequisites

  • Node.js 18+
  • npm or yarn
  • Python 3 with scikit-learn (optional, for ML)
  • Git

Initial Setup

# Clone the repository
git clone <repository-url>
cd defensys

# Install dependencies
npm install

# Build frontend (for Electron)
cd frontend && npm install && npm run build && cd ..

Running in Dev Mode

# Start Electron with dev tools
npm run dev

This typically starts Electron with the built frontend. For live frontend reload during development:

# Terminal 1: Watch frontend
cd frontend && npm run dev

# Terminal 2: Start Electron (pointing to Vite dev server if configured)
npm run dev

Project Structure

  • main.js – Electron main process
  • preload.js – IPC bridge
  • frontend/ – React app (Vite)
  • backend/ – Services (detection, ML, firewall, etc.)
  • backend/api/ – REST API server
  • ml/ – Python training and inference
  • db/ – SQLite database
  • installer-app/ – Custom Electron installer

Debugging

  • DevTools: Press F12 in the app to open Chrome DevTools for the renderer process.
  • Main process logs: Check the terminal where you rannpm run dev. Backend services log there.
  • IPC: Use console.log in preload or main to trace IPC calls.

Environment Variables

# .env (optional, for desktop app)
USE_PYTHON_ML=true   # or false to force JS fallback
NODE_ENV=development

Landing Page Dev

cd landing-page/defensys-landing
npm install
npm run dev
# Opens on port 3000

Web API Dev

cd web-api
npm install
npm run dev
# Opens on port 3001