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 processpreload.js– IPC bridgefrontend/– React app (Vite)backend/– Services (detection, ML, firewall, etc.)backend/api/– REST API serverml/– Python training and inferencedb/– SQLite databaseinstaller-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 ran
npm run dev. Backend services log there. - IPC: Use
console.login 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