# nvbn/termonizer architecture

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

- Interactive diagram: https://gitdiagram.com/nvbn/termonizer
- Repository: https://github.com/nvbn/termonizer

## Overview

##### Main Components
- cmd/termonizer: This is the entry point of the application, the main executable that initializes the system.
- internal/ui: Contains the terminal UI logic (files such as cli.go, goal_editor.go, goals_list.go, period_panel.go) and handles user interactions.
- internal/model: Defines the domain entities (goal, period, setting) that encapsulate the state and behavior of the organizer.
- internal/repository: Provides data access methods for reading/writing models (goals and settings), abstracting the data layer.
- internal/storage: Implements the lower-level data persistence using SQLite (see sqlite.go), acting as the bridge to the database.
- internal/utils: Contains helper functions used throughout the project (e.g., text and time utilities).

##### Relationships and Data Flow
- The entry point from cmd/termonizer starts up the application and interfaces with the terminal UI.
- The UI layer (internal/ui) accepts user commands and translates them into operations on the domain model.
- The UI interacts with the repository layer (internal/repository) to retrieve or update goals, settings, and periods.
- The repository, in turn, delegates the actual data storage and retrieval to the storage layer (internal/storage via SQLite).
- Utility functions (internal/utils) serve all parts of the system to handle common operations or transformations such as text manipulation and time formatting.
- Additionally, a secondary command (cmd/generate-lorem-ipsum-db) is available to generate test data for the database, which is used for development and testing.

##### Architectural Patterns and Design Principles
- Layered Architecture: Notice the clear separation into presentation (UI), business logic (model), data management (repository), and persistence (storage).
- Modularity & Separation of Concerns: Each internal package addresses specific responsibilities, making the system easier to maintain and test.
- Dependency Flow: The higher-level components (UI, cmd) depend upon abstractions in models and repositories, while the storage layer provides an implementation detail using SQLite.

##### Relevant Technologies, Frameworks, or Libraries
- Go (as the primary language),
- SQLite (for data persistence),
- Standard library packages (for CLI management, testing, etc.),
- GitHub Actions configuration is present under .github/workflows for CI, as per go.yml, though it is not directly part of the runtime architecture.

##### Elements
- Clear Labels: Mark nodes “UI (internal/ui)”, “Business Model (internal/model)”, “Repository (internal/repository)”, “Storage (internal/storage - SQLite)” and “Entry Point (cmd/termonizer)” clearly.
- Additional Annotations: Optionally include notes on testing (mark unit tests adjacent to their target modules) and development commands available through the Makefile.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "CLI/Commands"
        A["Entry Point (cmd/termonizer)"]
        B["Secondary Command (Generate Test Data)"]
    end

    subgraph "Presentation Layer"
        C["Terminal UI (internal/ui)"]
    end

    subgraph "Business Logic Layer"
        D["Domain Models (internal/model)"]
        E["Repository (internal/repository)"]
    end

    subgraph "Data Persistence Layer"
        F(("Storage (SQLite)"))
    end

    subgraph "Support/Utility Layer"
        G["Utility Functions (internal/utils)"]
    end

    A -->|"starts"| C
    C -->|"calls"| E
    E -->|"uses"| D
    E -->|"persists"| F
    B -->|"populates"| F

    A -.->|"usesUtils"| G
    C -.->|"usesUtils"| G
    D -.->|"usesUtils"| G
    E -.->|"usesUtils"| G
    F -.->|"usesUtils"| G

    click A "https://github.com/nvbn/termonizer/blob/main/cmd/termonizer/main.go"
    click B "https://github.com/nvbn/termonizer/blob/main/cmd/generate-lorem-ipsum-db/main.go"
    click C "https://github.com/nvbn/termonizer/tree/main/internal/ui"
    click D "https://github.com/nvbn/termonizer/tree/main/internal/model"
    click E "https://github.com/nvbn/termonizer/tree/main/internal/repository"
    click F "https://github.com/nvbn/termonizer/blob/main/internal/storage/sqlite.go"
    click G "https://github.com/nvbn/termonizer/tree/main/internal/utils"

    classDef commands fill:#AED6F1,stroke:#3498DB,stroke-width:2px;
    classDef presentation fill:#ABEBC6,stroke:#1E8449,stroke-width:2px;
    classDef business fill:#F9E79F,stroke:#F1C40F,stroke-width:2px;
    classDef persistence fill:#D2B4DE,stroke:#8E44AD,stroke-width:2px;
    classDef utilities fill:#FADBD8,stroke:#E74C3C,stroke-width:2px;

    class A,B commands;
    class C presentation;
    class D,E business;
    class F persistence;
    class G utilities;
```
