How mrtracker-new/bar works
Project Type and Purpose
• BAR is a standalone, offline desktop application (Python + PyQt5) for secure file management with built-in self-destruct mechanisms. There is no client-server communication; all components run locally. Its goals are file encryption, secure deletion, hardware-bound key management, user authentication (with 2FA), and comprehensive audit logging.
High-Level Architecture Overview
• Layered, modular design with clearly separated concerns:
• Presentation Layer (GUI)
• Application Core / Orchestration
• Domain Services (File Management, Crypto, Security, User Management, Config)
• Persistence (Local Filesystem storage under ~/.bar, logs)
Main Components
a. Presentation (src/gui)
• LoginDialog, RegisterDialog, TwoFactorDialog → handle user auth flows
• MainWindow, FileViewer, FileDialog, SettingsDialog → core UI for file operations
• Styles → theming
b. Application Core
• main.py → entry point; initializes config, logging, GUI event loop, thread pools
• build.py, setup.py → packaging and installation
c. Configuration (src/config)
• config_manager.py → loads/saves app settings, theme, default security policies
d. User Management (src/user_manager)
• user_manager.py → local user registration, password hashing (PBKDF2), 2FA setup/integration
e. File Management (src/file_manager)
• file_manager.py → creates/decrypts .bar files, enforces time/access limits
• file_scanner.py → multi-threaded scanning of drives for .bar files
f. Cryptography (src/crypto)
• encryption.py → AES-256-GCM encryption/decryption, key derivation, secure memory handling
g. Security (src/security)
• session_manager.py → tracks user login session and expiration
• two_factor_auth.py → TOTP generation/verification
• audit_log.py → writes audit events to ~/.bar/logs
• secure_delete.py → multi-pass overwrite per DoD standards
• hardware_id.* → hardware-binding support (C/Cython bridge)
• screen_protection.py, win_screenshot_prevention.py → screenshot blocking
h. Persistence
• Local filesystem under user home (~/.bar) for encrypted files, configs, logs
Interactions and Data Flows
1. Startup: main.py → config_manager loads settings → GUI (MainWindow)
2. User Login: GUI → session_manager + user_manager → two_factor_auth → audit_log
3. File: GUI → file_manager
→ crypto.encrypt(file, policy)
→ secure_delete (for overwritten originals)
→ write to ~/.bar/files
→ audit_log
4. Access File: GUI → file_manager → crypto.decrypt
→ session_manager checks policy (time/access count)
→ audit_log
5. Scan Drives: GUI → file_scanner (thread pool) → each thread invokes file_manager integrity checks, crypto.verify → returns found items to GUI
6. Background Enforcement: security background threads monitor policies (deadman switch, anti-brute force), trigger secure_delete if violated
Architectural Patterns & Principles
• Layered architecture: GUI → Services → Persistence
• Dependency inversion: high-level modules (GUI/core) depend on abstractions in domain services
• Single Responsibility: each module handles one aspect (config vs. crypto vs. scanning vs. UI)
• Observer/Event logging: audit_log captures events from all layers
• Concurrency: file scanning and background enforcement run in separate threads
• file_manager ↔ encryption (bidirectional: supplies plaintext/ciphertext)
• security modules (session_manager, hardware_id) → file_manager and crypto (to enforce policy/timeouts)
• file_scanner → file_manager → crypto (for integrity checks)
• audit_log ← all major operations (login, encrypt, decrypt, delete)
Final Checklist
• [ ] All 8 major modules represented
• [ ] Layer labels (Presentation, Core, Services, Persistence)
• [ ] Note storage location (~/.bar) and logging directory