Deskmeter

Productivity Tracking - Architecture Documentation

System Overview

View Full
System Overview

High-level architecture showing local tracking, data sync, and remote portfolio deployment.

Key Components

  • dmcore: Workspace tracking daemon using wmctrl (X11)
  • dmweb: Flask web dashboard with calendar and switches views
  • dmsync: Change Streams daemon pushing data to remote MongoDB
  • GNOME Extension: Panel indicator showing current task

Data Sync Architecture

View Full
Data Sync

Real-time sync using MongoDB Change Streams with resume token persistence.

Collections Synced

Collection Purpose Size
switch Workspace switch events with timestamps and durations ~33k docs
task Current task definitions from task file ~50 docs
task_history Cached historic task path lookups ~200 docs
state Current workspace and task state 1 doc

Why Change Streams?

  • Reacts to actual changes (not polling)
  • Resume token ensures no data loss on restart
  • Native MongoDB feature (requires replica set)
  • Clean, intentional architecture for portfolio

Deployment Architecture

View Full
Deployment

Docker Compose deployment on AWS EC2 with Nginx reverse proxy.

Networks

  • gateway: External network connecting Nginx to dmweb
  • internal: Private network for dmweb ↔ MongoDB communication

Deployment Flow

  • Build Docker image locally
  • Push to private registry (registry.mcrn.ar)
  • Pull and deploy on AWS EC2

Design Decisions

Bare Metal Core

dmcore runs on bare metal (not Docker) because it requires direct OS access for workspace detection via wmctrl and X11.

Single-Node Replica Set

Local MongoDB configured as replica set (rs0) to enable Change Streams. No actual replication, just API requirement.

Push Sync Model

Local machine pushes to remote (not pull). MongoDB on remote is not exposed to internet - only accessible from the sync daemon.

Portfolio-Ready

Remote instance shows historical data. "Current task" reflects last-synced state, not real-time.

Technology Stack

Core

  • Python 3.11
  • Flask
  • PyMongo
  • Jinja2 Templates

Data

  • MongoDB 7
  • Change Streams
  • Replica Set

Infrastructure

  • Docker
  • Docker Compose
  • Nginx
  • AWS EC2

OS Integration

  • wmctrl (X11)
  • GNOME Shell Extension
  • systemd