# namanlad/cli-journal-viewer architecture

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

- Interactive diagram: https://gitdiagram.com/namanlad/cli-journal-viewer
- Repository: https://github.com/namanlad/cli-journal-viewer

## Overview

##### Main Components
- Terminal UI Component: This is the Bubble Tea-driven module responsible for rendering the terminal interface, handling input events, and updating the display. It includes the date picker and journal view modes.
- Date Picker Subsystem: Consisting of three modes (monthly, month picker, and year picker), this subsystem allows users to navigate by date.
- Journal Entry Retrieval Module: This component interacts with the underlying jrnl CLI or its data source, retrieving journal entries based on the selected date.
- Pagination & Transition Manager: As part of the journal view mode, this handles the logic for scrolling through entries and managing smooth UI transitions.
- Application State Manager: An internal module keeping track of the current view mode, selected date, and other UI state details.

##### Relationships and Interactions
- The Terminal UI Component is the primary interface that orchestrates user input events.
- User inputs (like key presses) are sent to the Application State Manager, which then delegates tasks to either the Date Picker Subsystem or triggers the Journal Entry Retrieval module.
- The Date Picker updates the selected date, subsequently causing the Journal Entry Retrieval Module to fetch new entries.
- Retrieved entries are then passed back to the Terminal UI Component, which uses the Pagination & Transition Manager to display them with clarity.

##### Relevant Technologies
- Golang as the implementation language.
- Bubble Tea framework for terminal UI management.
- Integration with jrnl CLI tool (or its storage backend) for accessing journal entries.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External User Input
    INPUT["User Input"]:::external

    %% Terminal UI Component
    UI["Terminal UI (Bubble Tea Framework)"]:::ui

    %% Application Logic Components
    ASM["Application State Manager (MVU Model/Update)"]:::logic
    DPSC["Date Picker Subsystem (Monthly, Month Picker, Year Picker)"]:::logic
    JERM["Journal Entry Retrieval Module"]:::logic
    PTM["Pagination & Transition Manager"]:::logic

    %% Flow of interactions
    INPUT -->|"triggers"| UI
    UI -->|"dispatches event"| ASM
    ASM -->|"updates date"| DPSC
    DPSC -->|"sends updated date"| ASM
    ASM -->|"requests entries"| JERM
    JERM -->|"returns journal entries"| ASM
    ASM -->|"prepares pagination"| PTM
    PTM -->|"renders view"| UI

    %% Click Events
    click UI "https://github.com/namanlad/cli-journal-viewer/blob/main/README.md"
    click DPSC "https://github.com/namanlad/cli-journal-viewer/blob/main/README.md"
    click JERM "https://github.com/namanlad/cli-journal-viewer/blob/main/README.md"
    click PTM "https://github.com/namanlad/cli-journal-viewer/blob/main/README.md"
    click ASM "https://github.com/namanlad/cli-journal-viewer/blob/main/README.md"

    %% Styles
    classDef ui fill:#aee1f9,stroke:#0077b6,stroke-width:2px;
    classDef logic fill:#f9e1a9,stroke:#f4a261,stroke-width:2px;
    classDef external fill:#d3d3d3,stroke:#696969,stroke-width:2px;
```
