How helloprkr/knowledgebase works
Project Type and Purpose
• Base is a Linux-daemon + CLI tool for continuous activity monitoring and querying.
• It captures low-level events (keystrokes, mouse clicks, window focus), stores them in a local database (SQLite + daily Parquet), and exposes a query interface (selfstats/Baseview) that uses DuckDB for analytics.
High-Level Architectural Components
a. OS Event Sources
• Keyboard events
• Mouse events
• Window manager (focus/title) events
b. Sniffer Module (sniff_x.py)
• Listens to OS event streams
• Emits normalized activity records
c. Activity Store (activity_store.py)
• Receives events from sniffer
• Writes to SQLite in real time
• Rolls up each day’s data into Parquet files
d. Database Layer
• SQLite: live ingestion, metadata
• Parquet files: archived daily data
• DuckDB: query engine that federates SQLite + Parquet
e. Models & Query Layer (models.py + stats.py)
• Defines table schemas and ORM-like access
• Implements CLI commands (Baseview/selfstats)
• Parses user filters, builds DuckDB queries
f. Configuration (config.py)
• Loads defaults, overrides from CLI or config file
g. CLI Entrypoints
• Base (daemon launcher)
• Baseview/selfstats (analytics interface)
h. External Integrations (future/optional)
• Model API for natural-language queries
• cron/sendEmail for scheduled reports
Relationships and Data Flows
• OS Events → Sniffer → Activity Store → SQLite (real-time)
• Activity Store → Parquet (daily batch)
• CLI (“selfstats”) → Models → DuckDB → (SQLite + Parquet) → Output
• Config is consulted by both Daemon and CLI at startup
• Optional: Cron → selfstats → sendEmail
Architectural Patterns and Principles
• Separation of concerns: sniffing vs. storage vs. querying
• Batch vs. stream: real-time writes in SQLite, daily dumps to Parquet
• Adapter pattern: Models layer adapts DuckDB/SQLite/Parquet to a uniform API
• CLI-driven: no web UI, lightweight Python package, Unix philosophy