6.9 KiB
SecuBox Architecture Notes
Version: 1.0.0
Last Updated: 2025-12-28
Status: Active
These notes capture the current repository structure, conventions, and supporting tooling after scanning the tree (luci-app-*, secubox-tools/, secubox-app-*, scripts/), the root README.md, and the docs set (docs/, DOCS/, TODO-ANALYSE.md, secubox-tools/README.md, scripts/README.md, docs/module-status.md, docs/claude.md, docs/documentation-index.md). Treat this file as the canonical orientation guide before extending the platform.
1. Repository Layout
-
LuCI applications (
luci-app-*)
Each module ships a LuCI frontend (htdocs/luci-static/resources/...), RPCD backend (POSIX shell inroot/usr/libexec/rpcd/luci.<module>), menu + ACL JSON, optional CSS, and a module-specific README. Views follow the “menu path == file path” rule stressed in the documentation. -
Device/service packages (
secubox-app-*)
Native packages that install supporting services or CLIs (e.g.,secubox-app-zigbee2mqttinstalls/etc/config/zigbee2mqtt,/etc/init.d/zigbee2mqtt, and/usr/sbin/zigbee2mqttctl). These expose helpers that LuCI apps consume. -
Themes & shared assets
luci-theme-secuboxcarries the design system (dark palette,sh-*/sb-*classes, Inter + JetBrains Mono). Every LuCI view importssecubox-theme/secubox-theme.cssplus module-specific CSS as needed. -
Tooling (
secubox-tools/)
Contains validation (validate-modules.sh), build automation (local-build.sh), permission repair, deployment helpers, and debug loggers. These scripts mirror GitHub Actions workflows and should be reused for new installer/test tooling. Thesecubox-appCLI now lives here as well, consuming manifests under/usr/share/secubox/plugins/to install and configure “apps”. -
Automation/scripts (
scripts/)
Hosts documentation publishing helpers plus existing diagnostics/smoke scripts. New repo-wide diagnostics should live alongside them. -
Docs
Two mirrored trees (docs/and uppercaseDOCS/) feed MkDocs and the GitHub wiki. All Markdown follows the metadata template defined indocs/documentation-index.md. -
Profiles & App Manifests
App manifests now live under/usr/share/secubox/plugins/, profiles under/usr/share/secubox/profiles/.luci-app-secuboxexposes both through the wizard (UI) andsecubox-appCLI (automation).
2. Target Platforms & Build System
- Supported OpenWrt targets: ARM64 (aarch64-cortex-a53/a72/generic), x86_64, and legacy MIPS variants (per
secubox-tools/local-build.sh+ README badges). - Package formats:
.ipkfor ≤24.10,.apkfor 25.12/SNAPSHOT (handled automatically bylocal-build.sh). - CI: GitHub workflows (
.github/workflows/build-openwrt-packages.yml,test-validate.yml) validate and build all modules. Local parity is achieved viasecubox-tools/local-build.sh full. - Validation:
./secubox-tools/validate-modules.shruns seven structural checks (RPC naming, menu/view parity, permissions, JSON lint, etc.).fix-permissions.shenforces 755 for RPCD scripts and 644 for CSS/JS.
3. Configuration & Runtime Patterns
- UCI-first approach: Every feature stores runtime state in
/etc/config/<module>. CLIs/editors mutate entries viauci set/commit, and procd services read from UCI (seesecubox-app-zigbee2mqttorluci-app-vhost-manager). - Service supervision: Daemons use
/etc/init.d/<name>withUSE_PROCD=1. Procd wrappers call helper CLIs (e.g.,/usr/sbin/zigbee2mqttctl service-run). - RPCD backends: Implemented in POSIX shell. Filename equals ubus object (
root/usr/libexec/rpcd/luci.zigbee2mqtt=>object: 'luci.zigbee2mqtt'). They orchestrate UCI, system utilities, Docker, etc. - LuCI frontends: Built with
view.extendand the SecuBox design components (stat cards, tab strips, forms). Each module includesapi.jswrappers that call the matching ubus object. Auto-refresh usespoll()or manual timers. - Logging/diagnostics:
secubox-loghelper aggregates module activity under/var/log/seccubox.log. Additional repo-wide diagnostics live underscripts/diagnose.sh.
4. Network & Security Conventions
- Firewall & zones: Modules such as
luci-app-client-guardianandluci-app-network-modesmanipulate UCI firewall sections. They always backup configs before applying and keep the LAN management path reachable. - Network modes:
luci-app-network-modesalready models router/relay/AP/sniffer modes with wizards + rollback. Any future “profile” or “DMZ” work should reuse its UCI techniques and UI flow. - Reverse proxy:
luci-app-vhost-managermanages/etc/config/vhosts, renders nginx configs, handles basic auth, and integrates ACME. It is the baseline for any new vhost/TLS features. - Access control: ACL JSON lives in
root/usr/share/rpcd/acl.d/.docs/permissions-guide.mdplusDOCS/CODEX.mdenumerate the ubus permissions each module should request.
5. Existing App Ecosystem (Snapshot)
From docs/module-status.md and module READMEs:
- Core dashboards:
luci-app-secubox,luci-app-system-hub. - Security/monitoring: CrowdSec, Netdata, Netifyd, WireGuard, Client Guardian, Auth Guardian.
- Network orchestration: Network Modes, Traffic Shaper, Bandwidth Manager, Media Flow, CDN Cache.
- Device apps: Zigbee2MQTT already ships as
secubox-app-zigbee2mqtt+luci-app-zigbee2mqtt. - Reverse proxy:
luci-app-vhost-manager.
These modules provide working references for RPC patterns, UI layouts, wizards, and integration with system services.
6. Documentation Standards & Roadmap
- Every Markdown file must include
Version/Last Updated/Statusheaders (perdocs/documentation-index.mdandTODO-ANALYSE.md). - Cross-link related docs (Quick Start ↔ Development Guidelines ↔ Codex).
- Archive stale docs under
docs/archive/. TODO-ANALYSE.mdtracks ongoing documentation work (version standardization, cross-references, architecture diagrams). Keep this file updated when touching docs.
7. Key Takeaways for Future Work
- Extend, don’t fork: Build new features (Docker apps, App Store, wizard, DMZ mode) on top of existing packages (Zigbee2MQTT installer, Network Modes, VHost Manager) instead of introducing parallel systems.
- Reuse tooling: Diagnostics, smoke tests, and installers should hook into
secubox-tools/orscripts/so they can be invoked locally and in CI. - Stay POSIX + UCI driven: Shell scripts, UCI config, and procd remain the glue for Docker/LXC orchestration on resource-constrained routers.
- Document everything twice: Update both
docs/(MkDocs) andDOCS/(wiki) trees when adding guides such as the requested embedded notes.
These notes should be revised whenever new components (App Store, wizard, profiles, DMZ, Docker/LXC frameworks) land so contributors always have an up-to-date architectural map.