# lontor/task-cli architecture

> Architecture diagram of the GitHub repository lontor/task-cli, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-02-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/lontor/task-cli
- Repository: https://github.com/lontor/task-cli

## Overview

##### Main Components
- Entry Point – main.go: This file serves as the main execution point of the application.
- CLI Component – cli/cli.go: Handles command-line interactions and user input parsing. This module interprets commands like “add”, “list”, or “delete” and delegates actions to the appropriate part of the system.
- Task Module – task/task.go and task/task_manager.go: Contains the core logic for managing tasks, including CRUD operations and probably handling the JSON file read/write operations.

##### Relationships and Interactions
- The main.go file initializes the application, setting up necessary configurations and invoking the CLI component.
- The CLI module (cli/cli.go) captures input from the terminal, determines which specific task-related operation to execute, and calls functions in the Task Module.
- The Task Module (task/task.go and task/task_manager.go) processes the task operations (add, update, delete, list, and mark), and interacts with the JSON storage to save or retrieve task data.
- Data flows are mostly unidirectional: User commands go into the CLI, which in turn calls into the Task Module, and then the Task Module performs operations on the persistent JSON file. Optionally, feedback is provided back to the user via the CLI.

##### Architectural Patterns or Principles
- Separation of Concerns: The project splits the responsibilities between the CLI layer and the task logic layer, making it easier to maintain and extend.
- Single Responsibility: Each file/module handles its specific part of functionality (e.g., input handling, task logic, persistence).
- Modularity: The project is organized into separate directories for CLI handling and task management, simplifying the understanding of the code's structure and interface contracts.

##### Technologies and Frameworks
- Go: The implementation language.
- go.mod: Module dependency management.
- JSON: Used as the persistence format for tasks.
- Terminal/CLI: The application operates through a command-line interface.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Application Core"
        AE["Application Entry (main.go)"]:::core
        CLI["CLI Module (cli/cli.go)"]:::cli
    end

    subgraph "Task Management"
        TL["Task Logic (task/task.go)"]:::task
        TM["Task Manager (task/task_manager.go)"]:::task
    end

    D["Data Persistence (JSON File)"]:::data

    AE -->|"initializes"| CLI
    CLI -->|"delegates_command"| TL
    CLI -->|"delegates_command"| TM
    TL -->|"reads_writes"| D
    TM -->|"reads_writes"| D
    TL -->|"feedback"| CLI
    TM -->|"feedback"| CLI

    click AE "https://github.com/lontor/task-cli/blob/main/main.go"
    click CLI "https://github.com/lontor/task-cli/blob/main/cli/cli.go"
    click TL "https://github.com/lontor/task-cli/blob/main/task/task.go"
    click TM "https://github.com/lontor/task-cli/blob/main/task/task_manager.go"

    classDef core fill:#a6cee3,stroke:#1f78b4,stroke-width:2px;
    classDef cli fill:#b2df8a,stroke:#33a02c,stroke-width:2px;
    classDef task fill:#fb9a99,stroke:#e31a1c,stroke-width:2px;
    classDef data fill:#fdbf6f,stroke:#ff7f00,stroke-width:2px;
```
