# erikkalkoken/janice architecture

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

- Interactive diagram: https://gitdiagram.com/erikkalkoken/janice
- Repository: https://github.com/erikkalkoken/janice

## Overview

##### Main Components
- Entry Point: The application’s starting point is main.go, which sets up and initiates the program.
- User Interface (UI) Module: Located under internal/ui, this module comprises various files (about, menu, searchbar, treenode, etc.) responsible for managing the UI elements, theme (dark/light), user interactions, and overall layout.
- JSON Processing Module: Under internal/jsondocument, you have components like jsondocument.go, helper.go, and treesizer.go. These handle JSON parsing, document manipulation, formatting, and possibly efficiency improvements for large JSON structures.
- GitHub Integration (Optional/Supporting): The internal/github directory contains code that likely interfaces with GitHub – maybe for version checks, release information, or other integrations.
- Tools: The tools directory includes scripts and programs (like generate_json and multiply_json) that either assist in testing, generating JSON files, or automating the build and packaging processes.
- Build & Deployment: Files like FyneApp.toml, Makefile, .github workflows, and AppImage packaging scripts (in tools/build_appimage.sh) cover build automation, CI/CD, and deployment.

##### Relationships and Interactions
- The main.go launches the application, initializing the Fyne framework.
- The UI module (internal/ui) interacts with the JSON Processing module (internal/jsondocument) to load, parse, display, and search through JSON files.
- User actions in the UI (like selecting a file, performing a search, or expanding a tree node) trigger corresponding function calls in the JSON processing components.
- The GitHub internal module might be accessed for update checks or external service calls.
- The tool scripts support auxiliary functions like generating JSON data for testing or building distributable packages (AppImage for Linux, etc.).
- Testing files (not shown in production but available in subdirectories) indicate that unit and integration tests ensure each component behaves as expected.

##### Architectural Patterns and Design Principles
- Separation of Concerns: The project is neatly divided into modules (UI, JSON processing, GitHub integration, and tools), each responsible for a distinct aspect of the application.
- Modular Design: The clear organization (using the “internal” directory) indicates that the app’s key functionalities are encapsulated in separate packages. This helps maintain clarity and ease of testing.
- Event-Driven UI Architecture: Given that the application relies on Fyne for a responsive desktop GUI, the UI components likely follow an event-driven design.
- Single Executable “Fat” Application: The design embraces Go’s philosophy of producing a standalone binary that includes all necessary dependencies.

##### Relevant Technologies
- Fyne: The primary UI toolkit referenced by FyneApp.toml and the README.
- Go: The programming language used, with dependencies managed via go.mod and go.sum.
- CI/CD: GitHub actions defined under .github/workflows/ci-cd.yml, ensuring quality and integration.
- Build tooling: Tools such as Makefile and scripts for generating or multiplying JSON files to support functionality and testing.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Application Entry Layer
    subgraph "Application Entry"
        M["Main Entry (main.go)"]:::entry
    end

    %% Presentation Layer (UI)
    subgraph "Presentation Layer (UI - Fyne)"
        UI["UI Module (internal/ui)"]:::ui
        UINote["Handles about, menu, searchbar, treenode, etc."]:::note
    end

    %% Business Logic / Domain Layer
    subgraph "Business Logic / Domain"
        JP["JSON Processing Module (internal/jsondocument)"]:::logic
        JPNote["Parses, manipulates, and formats JSON data"]:::note
    end

    %% Integration Layer
    subgraph "Integration Layer"
        GH["GitHub Integration Module (internal/github)"]:::integration
        GHNote["Handles GitHub update checking and integrations"]:::note
    end

    %% Tools & Build Infrastructure
    subgraph "Tools & Build Infrastructure"
        subgraph "Tools & Scripts"
            TB["Tools & Scripts (tools)"]:::tools
        end
        subgraph "Build & Deployment"
            TOML["Fyne Application Config (FyneApp.toml)"]:::build
            MF["Build Script (Makefile)"]:::build
            CI["CI/CD Pipeline (.github/workflows)"]:::build
        end
    end

    %% Connections and Data Flows
    M -->|"initializes"| UI
    UI -->|"triggers JSON load"| JP
    JP -->|"returns parsed JSON"| UI
    UI -->|"requests update check"| GH
    GH -->|"provides update info"| UI
    TB -.->|"supports"| UI
    TB -.->|"supports"| JP
    TB -.->|"triggers"| TOML
    TB -.->|"triggers"| MF
    TB -.->|"triggers"| CI

    %% Click Events for component mappings
    click M "https://github.com/erikkalkoken/janice/blob/main/main.go"
    click UI "https://github.com/erikkalkoken/janice/tree/main/internal/ui"
    click JP "https://github.com/erikkalkoken/janice/tree/main/internal/jsondocument"
    click GH "https://github.com/erikkalkoken/janice/tree/main/internal/github"
    click TB "https://github.com/erikkalkoken/janice/tree/main/tools"
    click TOML "https://github.com/erikkalkoken/janice/blob/main/FyneApp.toml"
    click MF "https://github.com/erikkalkoken/janice/tree/main/Makefile"
    click CI "https://github.com/erikkalkoken/janice/tree/main/.github/workflows"

    %% Styles
    classDef entry fill:#ffcccc,stroke:#660000,stroke-width:2px;
    classDef ui fill:#ccf2ff,stroke:#003366,stroke-width:2px;
    classDef logic fill:#ccffcc,stroke:#006600,stroke-width:2px;
    classDef integration fill:#ffffcc,stroke:#999900,stroke-width:2px;
    classDef tools fill:#f2e6ff,stroke:#660099,stroke-width:2px;
    classDef build fill:#e6ffe6,stroke:#006600,stroke-width:2px;
    classDef note fill:#ffffff,stroke:#cccccc,stroke-dasharray: 5 5;
```
