How galsakuri/homesoc works
1. Overall shape
- HomeSOC is a three-part local SOC stack: a macOS collection agent, a Python/FastAPI backend, and a React/TypeScript dashboard.
- The backend is the system of record: it stores events, evaluates detections, exposes APIs, and pushes live updates to the UI.
2. macOS agent boundary
- agents/macos is a privileged endpoint collector that runs on the host Mac.
- It is split into a small agent core plus collectors for different telemetry sources, including Endpoint Security / eslogger and network observation.
- The agent sends batched security events to the backend over HTTP/JSON and periodically reports state/health so the backend can show agent status.
3. Telemetry sources on the host
- The agent focuses on host-level security signals: process execution, file/system activity, auth-related activity, network connections, and other macOS events mentioned in the README.
- This is important architecturally because the system is not scraping logs from a cloud service; it is gathering local machine telemetry at the endpoint boundary.
4. Backend API surface
- backend/api is organized by domain: events, alerts, agents, rules, auth, users, dashboard, setup, demo, websocket.
- The API serves both machine clients and the dashboard:
- agents authenticate and submit events,
- the dashboard reads data and manages settings,
- WebSocket clients subscribe to live updates.
5. Ingestion and persistence pipeline
- backend/ingestion/pipeline.py is the central event path.
- Incoming agent events are normalized, filtered, and written through the repository layer into SQLite (backend/db).
- The database layer is intentionally isolated behind models.py, repository.py, and connection.py, which makes the storage boundary clear for diagrams.
6. Detection engine
- backend/engine contains the rule loader and detector.
- Detection rules are stored as YAML in backend/rules, with built-in macOS-focused rules such as suspicious shell execution, outbound connections, privilege escalation, and brute-force auth.
- The engine runs against ingested events and emits alerts when rules match; rules can be single-event or threshold-based.
7. Alert delivery / async side effects
- Alert dispatch is separated from the main API path via backend/worker.
- redis_client.py and notifier.py indicate a queue-backed worker model: detection results can be handed off to Redis and processed asynchronously for notifications.
- Redis is optional in deployment, but when enabled it is the main decoupling point between detection and delivery.
8. Dashboard boundary
- dashboard/ is a standalone Vite React app served behind Nginx in its container.
- It talks to the backend through the REST API and dashboard/src/api/websocket.ts for live event streaming.
- The UI is split by concerns: dashboard overview, live feed, events table, alerts, agents, rules, settings, and setup guidance.
9. Shared contracts
- shared/ holds cross-cutting types and protocol/schema definitions used by multiple layers.
- This is the repo’s contract boundary: it keeps agent/backend/dashboard payloads aligned and reduces drift in event and rule formats.
10. Security and identity model
- The system uses API-key auth for agents and JWT-based auth for dashboard/user access.
- The README’s setup flow and the backend modules suggest separate concerns for onboarding, user management, and authenticated operations.
- This separation matters in diagrams: endpoint trust is different from human dashboard access.
11. Operational configuration
- Runtime configuration is driven by HOMESOC_* environment variables, including API key, JWT secret, port, SQLite path, event retention, and Redis URL.
- Deployment is containerized with compose.yaml, with separate Dockerfiles for backend and dashboard.
- The backend is therefore a local-first service, not a cloud/SaaS architecture.
12. Data flow summary
- The main flow is: macOS agent collects events → backend ingests and stores them → detection engine evaluates rules → alerts are generated → WebSocket/API updates reach the dashboard → optional worker sends notifications.
- Per-agent settings loop back from the dashboard to the backend, affecting collector toggles, rule enablement, and whitelist filtering on the next heartbeat.
13. Testing and support tooling
- tests/ covers API behavior, refresh/retention logic, and related fixes.
- scripts/ includes dev/demo helpers and test-event generation, which supports local validation of the full pipeline.
- docs/runbooks suggests the project is designed for reproducible local operations and troubleshooting rather than ad hoc use.
Main entry points: api API router · client.ts API client · transport.py HTTP send · main.py Agent core
Components 21
macOS agent
Privileged local telemetry collector on the host Mac.
- Agent core · Entry point and coordination layer for the host collector.
agents/macos/main.py - Agent shell · Shared agent base and transport integration.
agents/common/base_agent.py - ES logger · Endpoint Security and process/system activity collection.
agents/macos/collectors/eslogger.py - Network · Network observation and connection telemetry collection.
agents/macos/collectors/network.py - HTTP send · Batched JSON delivery of security events and health state.
agents/common/transport.py
Backend
FastAPI service that ingests, detects, stores, and serves data.
- API router · Domain API surface for agents, alerts, events, auth, users, setup, demo, and dashboard.
backend/api - WebSocket · Push channel for dashboard and streaming clients.
backend/api/ws.py - Auth · API-key and JWT authentication boundary.
backend/api/auth.py - Pipeline · Normalizes, filters, and routes incoming agent events.
backend/ingestion/pipeline.py - Detector · Evaluates ingested events against macOS detection rules.
backend/engine/detector.py - Rules load · Loads YAML rule definitions into the detection engine.
backend/engine/rules_loader.py - Repository · Storage abstraction over event, alert, agent, and user records.
backend/db/repository.py - SQLite · System of record for persisted events and derived state.
backend/db/connection.py - Worker · Background side effects and notification dispatch.
backend/worker/notifier.py - Redis · Optional queue-backed decoupling point for alert delivery.
backend/worker/redis_client.py - Rule pack · Built-in macOS-focused detection rules.
backend/rules
Dashboard
Standalone React UI for local SOC monitoring and control.
- UI shell · Main dashboard application and layout composition.
dashboard/src/App.tsx - Pages · Dashboard, events, alerts, agents, rules, settings, and guide screens.
dashboard/src/pages - API client · REST client and WebSocket subscription hooks.
dashboard/src/api/client.ts
Connections 25
- Agent core → Agent shell: runs on · Main agent entry uses the shared base runtime.
- Agent core → ES logger: collects · Coordinates Endpoint Security telemetry collection.
- Agent core → Network: collects · Coordinates network observation collection.
- ES logger → HTTP send: batches · Collected events are handed to the transport layer.
- Network → HTTP send: batches · Network events are handed to the transport layer.
- HTTP send → API router: POST events · Sends batched events and health state to the backend API.
- Auth → API router: protects · Authentication gates machine and human API access.
- API router → Pipeline: ingest · Incoming agent events flow into the central pipeline.
- Pipeline → Repository: stores · Normalized events and derived records are written through the repository.
- Repository → SQLite: persists · Repository talks to the SQLite storage layer.
- Pipeline → Detector: evaluates · Events are passed into the detection engine.
- Detector → Rules load: loads · Detection uses the YAML rule pack.
- Rules load → Rule pack: reads · Rule definitions are sourced from backend/rules.
- Detector → Worker: alerts · Detection results can trigger async side effects.
- Worker → Redis: queues · Optional queue-backed handoff for notifications.
- API router → WebSocket: streams · API publishes live updates over WebSocket.
- UI shell → Pages: composes · Application shell hosts the major dashboard pages.
- UI shell → API client: fetches · Dashboard uses REST and WebSocket client code.
- API client → API router: reads/writes · Frontend data layer talks to backend REST endpoints.
- API client → WebSocket: subscribes · Frontend subscribes to live updates.
- Contracts → HTTP send: aligns · Shared payload contracts keep agent messages consistent.
- Contracts → API router: aligns · Backend API models follow the shared schemas.
- Contracts → API client: aligns · Frontend types and API parsing follow the shared contracts.
- Compose → API router: deploys · Compose defines backend runtime wiring.
- Compose → UI shell: deploys · Compose and containers serve the dashboard build.