How jimzical/file-integrity-manager works
1. What this repository is
- This is a local Go CLI application for file integrity verification.
- Its core job is to walk a directory tree, hash files, persist hashes in a local database, then compare future scans against those stored hashes to detect changes.
2. Top-level flow
- The executable starts in cmd/main.go.
- From there, the app appears to pass control into a UI/interaction layer that collects user input, then into the file manager orchestration layer that performs scanning, hashing, and comparison.
3. Presentation boundary
- ui/ and pkg/basics/ contain the user-facing console layer: prompts, startup screen, styled output, and basic print/input helpers.
- This is the boundary between the user and the integrity engine; it does not appear to contain business logic.
4. Core orchestration
- core/fileManager/fileManager.go is the central coordination point.
- It likely ties together:
- folder traversal,
- per-file hash generation,
- DB reads/writes,
- integrity comparison,
- and result reporting.
- This is the main subsystem an architecture diagram should place in the center.
5. Directory traversal and hashing
- core/fileManager/traverseFolder.go handles recursive discovery of files in nested directories.
- core/fileManager/hashString.go and checkFileHash.go suggest two distinct responsibilities:
- generating a hash for file contents,
- checking whether the current hash matches the stored value.
- The README explicitly says the app uses goroutines, so file processing is likely concurrent and parallelized within this subsystem.
6. Persistence layer
- The app uses BadgerDB as its local key-value store.
- pkg/badgerDB/bdgr.go looks like the database wrapper/adapter.
- core/fileManager/db.go likely contains file-manager-specific DB operations, such as storing and retrieving hashes by file path or similar key.
- This is a local persistence boundary: no remote service or network dependency is indicated.
7. Domain model
- core/models/structs.go defines the data structures shared across layers.
- These likely represent file metadata, hash results, scan outcomes, and maybe user/session configuration.
- In a diagram, this is the shared contract between traversal, hashing, storage, and reporting.
8. Status and logging
- core/status/status.go and core/logs/ provide outcome tracking and human-readable results.
- core/logs/constants.go and logResults.go suggest standardized output categories/messages, likely used to report unchanged, modified, or failed files.
- This layer is important because the CLI’s value is in communicating integrity results clearly.
9. Configuration and initialization
- configs/configuration.go likely holds runtime settings or constants such as paths, defaults, or app configuration.
- This package sits near startup and influences how the CLI initializes its scan and database behavior.
10. Repository structure as layers
- The repo cleanly separates:
- cmd/ for process entry,
- ui/ and pkg/basics/ for console interaction,
- core/ for business logic,
- pkg/badgerDB/ for infrastructure persistence,
- configs/ for configuration.
- That layering is the most important architectural shape in the project.
11. Test corpus
- tests/ contains nested folders and mixed file types, which act as a realistic fixture set for recursive traversal.
- The structure is useful for validating depth-first scanning, file-type agnosticism, and comparison across directory hierarchies.
12. Operational characteristics
- The app is fully local, CPU/filesystem-bound, and optimized for concurrency.
- Its main data flow is: user selects target directory → scanner walks files → hashes are computed concurrently → hashes are stored in BadgerDB → later scans compare current vs stored hashes → UI reports changes.
Main entry points: fileManager.go File manager · print.go Print · startScreen.go Start screen · intput.go Input
Components 19
Entry
Process startup and CLI handoff
- main · Starts the application and hands off to the UI/flow layer
cmd/main.go
Console UI
User prompts, screens, and formatted output
- Start screen · Initial console screen and user-facing startup experience
ui/startScreen.go - Input · Collects target paths and user choices from the console
ui/intput.go - Print · Console printing helpers for interactive messaging
ui/print.go - Style · Text styling and presentation formatting helpers
ui/style.go - Basics input · Low-level input helpers shared by the UI layer
pkg/basics/input.go - Basics prints · Low-level printing helpers shared by the UI layer
pkg/basics/prints.go
Core Engine
Directory scanning, hashing, comparison, and reporting
- File manager · Coordinates traversal, hashing, storage, comparison, and reporting
core/fileManager/fileManager.go - Traverse folder · Recursively discovers files in nested directories
core/fileManager/traverseFolder.go - Hashing · Generates content hashes for scanned files
core/fileManager/hashString.go - Compare hash · Checks current hashes against stored values
core/fileManager/checkFileHash.go
Persistence
Local database adapter and file-manager storage access
- File DB ops · File-manager-specific persistence reads and writes for hashes
core/fileManager/db.go - BadgerDB · Wraps the local BadgerDB key-value database
pkg/badgerDB/bdgr.go
Shared Types
Common models, status, and log vocabulary
- Models · Shared structs for files, hashes, and scan results
core/models/structs.go - Status · Outcome states used to classify scan and integrity results
core/status/status.go - Log constants · Standardized result labels and message constants
core/logs/constants.go - Log results · Formats human-readable integrity results for output
core/logs/logResults.go
Configuration
Runtime settings and defaults
- Config · Runtime configuration and startup defaults
configs/configuration.go
Test Corpus
Nested sample files used to exercise traversal
- Test files · Nested sample tree used to validate recursive scanning
tests
Connections 19
- main → Start screen: launches · Main hands control to the interactive startup flow
- Start screen → Input: collects · Startup screen leads into prompt collection
- Input → Basics input: uses · UI input delegates to shared console input helpers
- Start screen → Print: renders · Startup flow prints messages to the console
- Print → Basics prints: delegates · Presentation output uses shared printing helpers
- Print → Style: formats · Output is styled before being displayed
- Input → File manager: passes target · Selected directory and choices are handed to the core engine
- File manager → Config: reads · Core flow uses configuration and defaults
- File manager → Traverse folder: scans · Orchestrator requests recursive file discovery
- Traverse folder → Test files: validated by · Fixture tree exercises traversal across nested folders
- File manager → Hashing: hashes · Orchestrator computes per-file content hashes
- File manager → Compare hash: compares · Orchestrator checks current hashes against stored values
- File manager → File DB ops: stores · Hash records are persisted and retrieved through file-manager DB operations
- File DB ops → BadgerDB: backed by · Local persistence is implemented on top of BadgerDB
- File manager → Models: uses · Scan and hash data are exchanged via shared structs
- File manager → Status: sets · Integrity outcomes are classified with shared status values
- File manager → Log results: reports · Final scan results are formatted for human output
- Log results → Log constants: uses · Reporting relies on standardized log labels
- Log results → Print: prints · Reported results flow back to the console layer