# javi-g/constantcommits architecture

> Architecture diagram of the GitHub repository javi-g/constantcommits, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/javi-g/constantcommits
- Repository: https://github.com/javi-g/constantcommits

## Overview

##### Project type and purpose
- This is a Node.js–based command-line tool (“Constant Commits”) that watches a project folder, automatically stages, commits, and pushes changes at regular intervals (and on demand).
- It integrates with the local Git CLI and a remote Git server (GitHub, GitLab, etc.).

##### File structure
- Top level:
- package.json, package-lock.json → Node.js project metadata and dependencies
- monitor.js → single entry-point script implementing the CLI logic
- README*.md, LICENSE → documentation and license
- No frontend or separate backend—the entire system is a single process that runs in a user’s terminal.

##### README for additional insights
- Dependencies: Node.js, Git
- CLI commands: `start`, keyboard shortcuts for manual commits
- Features: file-system monitoring, commit scheduling, Git operations, console UI

##### Main components and interactions
- Node.js Runtime – host environment
- CLI Interface (monitor.js)
– Subcomponents inside monitor.js:
‣ File Watcher (uses fs / chokidar)
‣ Change State Aggregator (tracks pending changes)
‣ Commit Scheduler (timer, groups changes per minute)
‣ Git Executor (runs `git add .`, `git commit`, `git push` via child_process / execa)
‣ Keyboard Listener (captures Alt+C / Option+C)
‣ Console UI Renderer (logs file changes, timestamps, push status)
- Local Git CLI (external dependency)
- Remote Git Server (GitHub/GitLab/Gitea)
- Operating System / File System

b. Relationships and data flows
1. File System events → File Watcher → Change State Aggregator
2. Every minute (or on manual key event) → Commit Scheduler → Git Executor
3. Git Executor → Local Git CLI → Remote Git Server
4. Keyboard Listener → manual override → Git Executor
5. All subcomponents report to Console UI Renderer → Terminal (stdout)

c. Architectural patterns / design principles
- Single-process, modular internal structure
- Event-driven (file-system and keyboard events)
- Timer-based scheduling
- Clear separation of concerns: watching vs. scheduling vs. Git operations vs. UI

d. Key technologies
- Node.js (runtime)
- fs or chokidar (file watching)
- child_process / execa (Git commands)
- readline or a keypress library (keyboard shortcuts)
- process.stdout (console UI)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% External Dependencies
    NodeJS["Node.js Runtime"]:::external
    click NodeJS "https://github.com/javi-g/constantcommits/blob/main/package.json"
    Lock["package-lock.json"]:::external
    click Lock "https://github.com/javi-g/constantcommits/blob/main/package-lock.json"

    %% Documentation & License
    subgraph "Docs & License"
        README1["README.md"]:::external
        click README1 "https://github.com/javi-g/constantcommits/blob/main/README.md"
        README2["README.es.md"]:::external
        click README2 "https://github.com/javi-g/constantcommits/blob/main/README.es.md"
        LICENSE["LICENSE"]:::external
        click LICENSE "https://github.com/javi-g/constantcommits/tree/main/LICENSE"
    end

    %% External Systems
    OS["OS / File System"]:::external
    LocalGit["Local Git CLI"]:::external
    RemoteGit["Remote Git Server"]:::external

    %% CLI Interface
    subgraph "monitor.js (CLI Interface)"
        direction TB
        Mon["monitor.js"]:::external
        click Mon "https://github.com/javi-g/constantcommits/blob/main/monitor.js"

        FW["File Watcher"]:::internal
        CSA["Change State Aggregator"]:::internal
        CScheduler["Commit Scheduler"]:::internal
        GE["Git Executor"]:::internal
        KL["Keyboard Listener"]:::user
        CUI["Console UI Renderer"]:::user
    end

    %% Flows
    OS -->|file events| FW
    FW -->|change data| CSA
    CSA -->|pending changes| CScheduler
    CScheduler -->|schedule trigger| GE
    KL -->|manual commit| GE
    GE -->|git commands| LocalGit
    LocalGit -->|push over HTTP| RemoteGit
    FW -->|logs| CUI
    CSA -->|logs| CUI
    CScheduler -->|logs| CUI
    GE -->|logs| CUI
    KL -->|logs| CUI

    %% Legend
    classDef internal fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef external fill:#90EE90,stroke:#333,stroke-width:1px
    classDef user fill:#FFD700,stroke:#333,stroke-width:1px
```
