FileGuard keeps the four-layer design from the system overview:
- Event Capture:
FileSystemWatcher,EventQueue,SnapshotManager. - Analysis Pipeline: six analyzers emit metadata-only
AnalysisSignalobjects. - Risk/API Layer:
RiskScorer,AlertManager, JSONL store, FastAPI service. - Presentation: CLI dashboard, React web console, HTML report.
FileSystemWatcher
-> EventQueue
-> AnalysisPipeline
-> SensitivePath / Entropy / Frequency / Honeypot / HashDiff / FuzzyHash
-> RiskScorer
-> AlertManager
-> JSONL Logger
-> CLI Dashboard / FastAPI / SSE / HTML Report / React Console
The core detection algorithms are still isolated in src/fileguard/analyzers/
and src/fileguard/scoring/scorer.py. Round 4 adds orchestration and delivery
capabilities without rewriting those algorithms.
Current FastAPI routes:
GET /api/status: runtime status, totals, highest level, snapshot/report flags.GET /api/events: recent event rows, including optional score/level/signal count.GET /api/alerts: alert timeline, full signal details, escalation metadata, by-level counts.GET /api/analyzers: analyzer enabled state, weight, trigger totals, last trigger time.GET /api/snapshots: baseline, backup, restore, incremental snapshot, auto-restore state.GET /api/reports: report file status.POST /api/reports: generate an HTML report from current timeline or JSONL.GET /api/stream: Server-Sent Events stream for status/event/alert updates.
Alert escalation:
- Implemented in
AlertManagerwith backward-compatible constructor options. - If enabled, repeated alerts in a time window can escalate from
MEDIUMtoHIGH. - Escalation metadata is exposed through API alert items.
Incremental snapshots:
- Implemented in
SnapshotManager.update_incremental(). - Records path, old/new SHA-256, old/new entropy, event type, and timestamp.
- Records are metadata-only and written to a JSONL file under FileGuard metadata paths.
Defensive auto-restore:
- Implemented in
SnapshotManager.auto_restore_if_needed(). - Default config is disabled and dry-run.
- Only targets files under
experiments/sandbox/. - Uses only FileGuard's own snapshot backup copies.
Report trigger:
POST /api/reportsusesReportGenerator.- Output path is validated to stay under the project workspace.
Frontend:
frontend/src/App.tsxprovides a multi-view console with internal tab navigation.frontend/src/hooks/useFileGuardData.tscentralizes API fetch, SSE subscription, polling fallback, and demo-data fallback.frontend/src/demoData.tsmirrors backend DTO shapes for offline presentation.