NetIgnite Server is the server-side core of the NetIgnite / Device Power Management platform. It provides:
- HTTP/REST API for authentication and management of agents & devices
- WebSocket "Agent Control Service" for bidirectional control of registered agents (servers / microcontrollers)
- Persistence via embedded SQLite (libsql) database
- Session-based authentication (HTTP cookies)
- Automatic startup initialization (DB, default admin, session handler, agent loading)
- Extensible command system for agents (heartbeat, future commands)
- Docker-ready deployment with separate volumes for data, configuration & logs
- Overview & Architecture
- Features
- Directory Structure (server portion)
- Prerequisites
- Installation & Development (Bun / Node)
- Docker Deployment
- Configuration (
config.json, ENV variables) - Database
- Authentication & Sessions
- API Endpoints (excerpt)
- Agent Control WebSocket
- Logging & Error Handling
- Security Notes
- Roadmap / Extensions
- License
The server is built on Nuxt 3 (Nitro) with experimental WebSocket support enabled (nitro.experimental.websocket = true). At startup a bootstrap plugin (server/plugins/startup.ts) loads in sequence:
- Configuration (
ConfigHandler) - Database & tables (
DBStorage.init()) - Default admin (if no users exist) – credentials written to
./data/initial_admin_credentials - Session management (
SessionHandler.init()) - Agents from the database and initialization of the
AgentControlService
The REST API is exposed via Nitro routes under server/api/**. The WebSocket service manages connected agents, periodically sends heartbeats and accepts commands.
- Agents (type
serverormicrocontroller) with secret and owner assignment - Basic Auth for WebSocket agent connections (ID:Secret)
- Session-based user login (cookie
session) - CRUD for agents including online/offline status queries
- Heartbeat every 60 seconds to connected agents
- Dynamic log level control (
debug,info,warn,error,critical) - Automatic generation of a secure admin password on first start
server/
api/
auth/ (login, logout, session)
agents/ (CRUD & status)
devices/, account/, admin/ (...additional routes)
agent-control-service/
agent.ts (agent model & command dispatch)
server.ts (WebSocket handler, heartbeat cron)
index.ts (initialization & access)
db/
index.ts (table setup & access)
models/ (*.ts per table)
plugins/startup.ts (bootstrap sequence)
utils/
auth/ (sessions.ts, handler.ts)
config.ts (configuration loading logic)
logger.ts (log level handling)
- Node.js >= 18 or Bun >= 1
- Git
- (Optional) Docker
bun install
bun run dev # runs via nuxt dev (port 3000 in development)If you do not use Bun:
npm install
npx nuxt dev --host 0.0.0.0 --port 3000Production build (artifacts):
bun run build # or: npx nuxt buildPreview (test Nitro output):
bun run preview # or: npx nuxt previewThe provided Dockerfile builds a production image:
- Base:
oven/bun:1 - Build artifact:
.output/server/index.mjs - Exposed port:
18232/tcp - Volumes:
/opt/netignite/data(SQLite DB, initial admin credentials)/opt/netignite/config(configuration file)/opt/netignite/logs(optional log output)
Build & run example:
docker build -t netignite:latest ./app
docker run -d ^
-p 18232:18232 ^
-v netignite_data:/opt/netignite/data ^
-v netignite_config:/opt/netignite/config ^
-v netignite_logs:/opt/netignite/logs ^
--name netignite netignite:latestDefault file path: ./config/config.json (override via ENV CONFIG_FILE_PATH). Minimal example:
{}Current possible fields (more planned):
logLevel:"debug" | "info" | "warn" | "error" | "critical"- (Agents are loaded from the DB, not the config file)
CONFIG_FILE_PATH– custom path to configuration fileNITRO_ENV– production mode (Docker setsproduction)NITRO_HOST– host bind (0.0.0.0)NITRO_PORT– API / web app port (default in container:18232)NODE_ENV– influences cookiesecureflag for sessions
- Driver:
@libsql/client(local SQLite file) at./data/db.sqlite - Tables automatically created (Users, PasswordResets, Agents, Devices)
- On first start: admin creation & credential output
- Login:
POST /api/auth/loginwithusername,password - Successful login sets
sessioncookie - Session lifetime: 30 days (refreshed on use)
- Logout:
POST /api/auth/logoutclears the session - Session status:
GET /api/auth/sessionSuccess response shape:
{ "status": "OK", "data": { "userID": 1, "username": "admin", "role": "admin", "favorites": [] } }All agent routes require a valid session.
| Method | Path | Description |
|---|---|---|
| GET | /api/agents |
List all own agents |
| POST | /api/agents |
Create agent (name, description, type, secret) |
| GET | /api/agents/status?ids=1,2 |
Online status filtered or all own agents |
| GET | /api/agents/{id} |
Agent detail |
| PUT | /api/agents/{id} |
Update (changing secret disconnects existing connection) |
| DELETE | /api/agents/{id} |
Delete agent |
Payload example (POST):
{
"name": "Server A",
"description": "Main host",
"type": "server", // or "microcontroller"
"secret": "<RANDOM-STRING>"
}Generic success response:
{ "status": "OK", "message": "...", "data": null }Errors use standard HTTP status codes (400, 401, 404, 500).
The WebSocket service manages online status & heartbeats. Agents connect using a Basic Auth header:
Authorization: Basic base64("<agentID>:<secret>")
Flow:
- Server validates credentials & closes old connection on reconnect
- Stores socket + peer ID for the agent
- Cron (every minute) sends HEARTBEAT command
The concrete WebSocket path depends on Nitro deployment / config (experimental feature). Check your reverse proxy and Nitro documentation; by default the server can accept upgrades on the main port.
- HEARTBEAT (Server → Agent)
- More via
AgentCMDRegistry(extension potential)
Configurable log levels: debug, info, warn, error, critical. Startup failures (e.g. config or DB init) trigger process termination (process.exit(1)) to avoid inconsistent state.
- Change the admin password immediately after first start.
- Use long cryptographically random secrets for agents.
- Enable TLS (reverse proxy: Nginx / Caddy) before production use.
- Set
NODE_ENV=productionso cookies use thesecureflag (with HTTPS). - Restrict network access to the WebSocket port if only internal agents connect.
- Expanded role / permission matrix (admin vs superadmin vs user granularity)
- Device-specific Wake-on-LAN actions directly via API
- Persistent agent command queue
- Token-based API auth in addition to sessions
- Encryption at rest (secret rotation)
- Metrics / Prometheus export
See the project license file (LICENSE).
# Development
bun install
bun run dev
# First start: check file ./data/initial_admin_credentials
# Login with admin + generated password
# Docker
docker build -t netignite:latest ./app
docker run -d -p 18232:18232 netignite:latest