open source · v0.3

IoT +
GenAI
EdgeAI

From sensor data to answers, on your own hardware.

p4n4 is a command-line tool that sets up a self-hosted IoT and AI stack with Docker Compose. One command gives you MQTT messaging, a time-series database, dashboards, local LLMs and edge model inference, on anything from a Raspberry Pi to a GPU server.

bash — p4n4 init
$ p4n4 init my-factory-stack --layer all
? InfluxDB organisation: ming
? Timezone: UTC
? InfluxDB admin password: (auto-generated)
? Grafana admin password: (auto-generated)
? Node-RED editor password: (auto-generated)
✓ Project created at ./my-factory-stack
iot/ ai/ dashboard/ .p4n4.json .gitignore
$ p4n4 up
✓ iot mosquitto · influxdb · node-red · grafana
✓ ai ollama · ei-runner
✓ dashboard http://localhost:8088
$
4×
Layers, use any mix
10oss
Open Source Services
1cmd
To start everything
0$
Cloud fees to run it

Four layers.
One network.

The MING stack (Mosquitto, InfluxDB, Node-RED, Grafana) handles sensor data. The AI layer runs local LLMs, System 1 and your edge ML models beside it, on one Docker network. Start only the parts you need.

Mosquitto :1883
Node-RED :1880
InfluxDB :8086
Grafana :3000
Telegraf optional
⟷
Ollama :11434
System 1 no port · optional
ei-runner · .eim / .onnx :8080 · optional
Letta :8283 · optional
n8n :5678 · optional
⟷
Your own services opt-in
go2rtc video in a template
REST API · JWT auth :8000
p4n4-lib shared with CLI
⟷
Web UI + proxy :8088
Android · iOS · desktop Flutter
Visual Flows
Node-RED connects sensors, the database and AI in a browser editor.
node-red
Agents with Memory
Letta agents keep a history of past faults and conversations.
letta
ML on Live Data
An Edge Impulse or ONNX model scores each reading that arrives over MQTT.
edge impulse / onnx
Fully Self-Hosted
Nothing calls the cloud at runtime. Works on networks with no internet.
on-premise
Pick What Runs
Choose layers with --layer. Only those start.
docker compose
Use Your Broker
Pull topics from an MQTT broker you already run.
mqtt bridge

p4n4 init.
Then p4n4 up.

The init wizard creates the project and generates every password and token. Then p4n4 up starts it.

p4n4 init
Create a project. Choose layers with --layer.
p4n4 up
Start the enabled stacks, in order.
p4n4 down
Stop the stacks in reverse order.
p4n4 status
Show state, health and ports for each service.
p4n4 logs
Follow logs for a stack or one service.
p4n4 secret
Show, rotate or generate passwords and tokens.
p4n4 validate
Check config files and .env before you start.
p4n4 init — interactive wizard
$ p4n4 init my-factory-stack --layer iot,ai,dashboard ────────────────────────────────── Press Enter to accept defaults. ? InfluxDB organisation: ming ? Timezone (TZ database name): UTC ? InfluxDB admin password: (auto-generated) ? InfluxDB API token: (auto-generated) ? Grafana admin password: (auto-generated) ? Node-RED editor password: (auto-generated) ? Pull topics from an external MQTT broker? No ? Letta server password: (auto-generated) ? n8n encryption key: (auto-generated) ? Run the edge inference runner? No ✓ Project created at ./my-factory-stack .p4n4.json .gitignore iot/docker-compose.yml iot/.env iot/config/… ai/docker-compose.yml ai/.env ai/config/… dashboard/docker-compose.yml dashboard/.env AI: only Ollama starts by default. To run Letta, n8n or the inference runner, add them to COMPOSE_PROFILES in ai/.env cd my-factory-stack && p4n4 up

Start from a working project.

Six example projects in p4n4-templates, each built around a real use case.

mqtt-influx-grafana
IoT
Collect sensor data and chart it. Start here.
mqtt-nodered-influx-grafana
IoT
Greenhouse control with rules in Node-RED.
mqtt-influx-grafana-ollama
IoTGenAI
Ask a local LLM questions about your sensor data.
mqtt-influx-grafana-n8n
IoTGenAI
Cold-chain alerts and daily reports from n8n workflows.
mqtt-influx-grafana-ollama-letta
IoTGenAI
A maintenance assistant that remembers past faults.
mqtt-influx-grafana-ollama-go2rtc
IoTGenAIEdge
Count traffic in camera streams with an edge model.

Templates are a work in progress. Each one's README explains how to run it.

Browse templates

A small model flags it.
An LLM explains it.

A trained model labels each sensor reading in milliseconds. When one looks wrong, System 1 suggests a likely cause from a list you define, and a local LLM explains it in plain words.

Edge Inference Runner
Sensor reading → label + anomaly score
ms
Mosquitto + Node-RED
Moves readings and results between services
ms
InfluxDB
Stores every reading and result
persistent
System 1
Picks a likely cause from a fixed list
<2s
Ollama LLM
Explains the anomaly in plain language
seconds
Letta Agents
Remembers each machine's fault history
stateful
MQTT inference flow
# Publish → sensors/motor-m003/raw
{
"values": [0.12, -0.05, 1.01, 0.33]
}
─────────────────────────────────
# Result → inference/motor-m003/result
{
"device": "motor-m003",
"label": "normal",
"confidence": 0.964,
"anomaly_score": 0.18,
"latency_ms": 4.2,
"mode": "model"
}
Node-RED: anomaly_score > 0.7, raise an alert
─────────────────────────────────
System 1 → cause: "mechanical" (0.94)
Ollama → "Motor M003 vibration is well above its normal range (score 0.91). Last maintenance was 47 days ago. Inspect the bearing within 72 hours."

Built on tools
you already know.

MING is a common open source IoT stack. p4n4 uses it as the base and adds local LLMs and edge ML models on top.

M
Mosquitto
MQTT Broker
Passes messages between devices over MQTT, a light publish/subscribe protocol.
I
InfluxDB
Time-Series Database
Stores each sensor reading with its timestamp.
N
Node-RED
Flow Editor
Connects services with flows you draw in the browser.
G
Grafana
Dashboards & Alerts
Charts your data and sends alerts when values cross a limit.

Runs on the hardware
you already have.

p4n4 runs on 64-bit Linux with Docker, on ARM64 or x86-64. We test on a Raspberry Pi 5, a Jetson Orin Nano and an embedded Linux computer. The other boards below should work but haven't been tested. Models run on the CPU by default, and NVIDIA GPUs work through a Compose override file.

Raspberry Pi
GPIO BCM2712 4× A76 · 2.4GHz BROADCOM LPDDR4X8GB RP1 PCIe PWR HDMI0 HDMI1 FAN Raspberry Pi 5 Model B
Raspberry Pi 4
ARM Cortex-A72 · 2–8 GB RAM · USB 3.0
IoT GenAI Edge
Raspberry Pi 3B+
ARM Cortex-A53 · 1 GB RAM
IoT Edge
Raspberry Pi Zero 2 W
ARM Cortex-A53 · 512 MB RAM · Wi-Fi
Edge
NVIDIA Jetson
ORIN 40-PIN CAM0/1 PMIC DC DP JETSON ORIN NANO
Jetson Nano (4 GB)
ARM Cortex-A57 · 4 GB · 128-core Maxwell GPU
IoT GenAI Edge
Jetson Xavier NX
ARM Carmel · 8 GB · 384-core Volta GPU
IoT GenAI Edge
Banana Pi & Rockchip
RK3588 ROCKCHIP · 6 TOPS LPDDR5 LPDDR5 eMMC64GB PMIC CTRL NVMe SSD M.2 2280 · PCIe 3.0 NAND 2.5G 2.5G PD Banana Pi · RK3588
Banana Pi BPI-M7
RK3588 · 8–32 GB · NPU 6 TOPS
IoT GenAI Edge
Banana Pi BPI-M5 Pro
RK3576 · 4–16 GB · NPU 6 TOPS
IoT GenAI Edge
Rock 5B / Orange Pi 5 Plus
RK3588 · 4–32 GB · NPU 6 TOPS
IoT GenAI Edge
x86-64 Servers & Mini PCs
01 02 RACK SERVER · x86-64 MINI PC
Intel NUC / Beelink Mini PC
x86-64 · 8–32 GB RAM · Intel iGPU
IoT GenAI Edge
Any Linux VPS / VM
x86-64 · 4 GB+ RAM · Ubuntu / Debian
IoT GenAI
ARM64 & x86-64 — every Docker image is built for both
1 GB minimum for the IoT layer · 4 GB+ for the AI layer (8 GB recommended)
Docker 24+ and Docker Compose v2 required
Works offline — no internet needed once images and models are downloaded

No board yet? Test against its limits.

p4n4-emu runs your project on your workstation with a real board's CPU, memory and disk limits. Its settings go in a separate Compose file, so your project files don't change.

Hardware profiles
ProfileCPUsMemoryDisk R/WArch
rpi5 47 GB100 MB/s arm64
rpi4 43.5 GB50 MB/s arm64
nuc 414 GB200 MB/s x86_64
mcu-class 1256 MB10 MB/s x86_64
Compose overlay
An extra Compose file with each board's CPU, RAM and disk limits.
QEMU ARM64
Runs ARM64 images on an x86 computer.
Sensor simulator
Publishes made-up readings over MQTT.
GPIO stub
Stands in for RPi.GPIO, so Pi code runs off the Pi.
p4n4-emu — quickstart
# 1. install once, then check your system $ uv tool install git+https://github.com/raisga/p4n4-emu $ p4n4-emu setup --check-only ✓ Docker 27.x ✓ Compose 2.29.x ✓ cgroup v2 present # 2. start a project with Raspberry Pi 5 limits $ cd my-factory-stack $ p4n4 up --emu rpi5 # 3. compare usage with the board's limits $ p4n4-emu status service CPU memory limits mqtt 0.01 / 0.40 9 MB / 512 MB applied influxdb 0.21 / 1.20 188 MB / 2 GB applied node-red 0.04 / 0.80 96 MB / 1 GB applied grafana 0.03 / 0.80 74 MB / 1 GB applied
p4n4-emu on GitHub

Running in three commands.

You need Docker 24+ with Compose v2, Python 3.11+ and Git. p4n4 uses Git to download the stack files.

quickstart
01
pipx install p4n4
02
p4n4 init my-project # add --layer all for every layer
03
cd my-project && p4n4 up

p4n4 0.3 is for development and trusted local networks. Don't expose its ports to the internet.