# felangga/chiko architecture

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

- Interactive diagram: https://gitdiagram.com/felangga/chiko
- Repository: https://github.com/felangga/chiko

## Overview

##### Main Components Identification
The project is a standalone application with these key components:

a. Core Components:
- gRPC Controller: Handles all gRPC-related operations
- UI Layer: Manages the Terminal User Interface
- Storage Controller: Handles file operations and bookmarks
- Entity Layer: Contains core data structures

##### Architectural Pattern
The project follows a clean architecture pattern with clear separation of concerns:
- Controller Layer (pkg/controller)
- UI Layer (pkg/ui)
- Entity Layer (pkg/entity)

- Terminal UI        |
- (tview-based interface)|

- gRPC Controller      |

- Bookmark Controller  |

- Storage Controller   |

- gRPC Services        |
- (External Connections) |

##### Component Relationships

- UI Layer → Controllers (Command flow)
- Controllers → External gRPC Services
- Controllers → Local Storage
- Entity objects flowing between components

##### Specific Component Details

UI Layer Components:
- Bookmark Menu
- Log List
- Output Panel
- Sidebar Menu
- Modal Windows (Authorization, Metadata, Request Payload)

Controller Components:
- gRPC Controller
- Connection handling
- RPC invocation
- Sample generation
- Bookmark Controller
- Save/Load operations
- Migration handling
- Storage Controller
- File operations
- Working directory management

Entity Components:
- App configuration
- Authentication
- Bookmarks
- Logs
- Metadata
- Sessions
- Themes

##### Important Flows to Highlight

Key workflows with numbered sequences:

##### Technical Details

Annotations for:
- grpcurl integration points
- tview UI component connections
- File storage locations
- Configuration paths

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph UI["Terminal User Interface"]
        direction TB
        TUI["Main TUI Interface"]:::ui
        BM["Bookmark Menu"]:::ui
        LL["Log List"]:::ui
        OP["Output Panel"]:::ui
        SM["Sidebar Menu"]:::ui
        MW["Modal Windows"]:::ui
    end

    subgraph Controllers["Controller Layer"]
        direction TB
        GC["gRPC Controller"]:::controller
        BC["Bookmark Controller"]:::controller
        SC["Storage Controller"]:::controller
        
        subgraph GCOps["gRPC Operations"]
            CH["Connection Handler"]:::controller
            RI["RPC Invocation"]:::controller
            SG["Sample Generation"]:::controller
        end
        
        subgraph BCOps["Bookmark Operations"]
            SO["Save Operations"]:::controller
            LO["Load Operations"]:::controller
            MH["Migration Handler"]:::controller
        end
    end

    subgraph Entities["Entity Layer"]
        direction TB
        AC["App Configuration"]:::entity
        AU["Authentication"]:::entity
        BK["Bookmarks"]:::entity
        LG["Logs"]:::entity
        MD["Metadata"]:::entity
        SE["Sessions"]:::entity
        TH["Themes"]:::entity
    end

    subgraph External["External Layer"]
        direction TB
        GRPC["gRPC Services"]:::external
        FS["File System"]:::external
    end

    %% Relationships
    TUI --> BM & LL & OP & SM & MW
    BM --> BC
    BC --> SO & LO & MH
    GC --> CH & RI & SG
    GC --> GRPC
    SC --> FS
    BC --> SC
    
    %% Entity Relationships
    GC --> SE
    BC --> BK
    TUI --> AC
    MW --> MD & AU
    LL --> LG
    TUI --> TH

    %% Click Events
    click GC "https://github.com/felangga/chiko/blob/main/pkg/controller/grpc/grpc.go"
    click CH "https://github.com/felangga/chiko/blob/main/pkg/controller/grpc/connect.go"
    click RI "https://github.com/felangga/chiko/blob/main/pkg/controller/grpc/invoke_rpc.go"
    click SG "https://github.com/felangga/chiko/blob/main/pkg/controller/grpc/generate_rpc_sample.go"
    click BC "https://github.com/felangga/chiko/blob/main/pkg/controller/bookmark/bookmark.go"
    click SO "https://github.com/felangga/chiko/blob/main/pkg/controller/bookmark/save_bookmark.go"
    click LO "https://github.com/felangga/chiko/blob/main/pkg/controller/bookmark/load_bookmark.go"
    click MH "https://github.com/felangga/chiko/blob/main/pkg/controller/bookmark/migrate_bookmark.go"
    click SC "https://github.com/felangga/chiko/blob/main/pkg/controller/storage/storage.go"
    click BM "https://github.com/felangga/chiko/blob/main/pkg/ui/init_bookmark_menu.go"
    click LL "https://github.com/felangga/chiko/blob/main/pkg/ui/init_log_list.go"
    click OP "https://github.com/felangga/chiko/blob/main/pkg/ui/init_output_panel.go"
    click SM "https://github.com/felangga/chiko/blob/main/pkg/ui/init_sidebar_menu.go"
    click MW "https://github.com/felangga/chiko/blob/main/pkg/ui/show_authorization_modal.go"
    click AC "https://github.com/felangga/chiko/blob/main/pkg/entity/app.go"
    click AU "https://github.com/felangga/chiko/blob/main/pkg/entity/auth.go"
    click BK "https://github.com/felangga/chiko/blob/main/pkg/entity/bookmark.go"
    click LG "https://github.com/felangga/chiko/blob/main/pkg/entity/log.go"
    click MD "https://github.com/felangga/chiko/blob/main/pkg/entity/metadata.go"
    click SE "https://github.com/felangga/chiko/blob/main/pkg/entity/session.go"
    click TH "https://github.com/felangga/chiko/blob/main/pkg/entity/theme.go"

    %% Styles
    classDef ui fill:#3498db,stroke:#2980b9,color:#fff
    classDef controller fill:#2ecc71,stroke:#27ae60,color:#fff
    classDef entity fill:#9b59b6,stroke:#8e44ad,color:#fff
    classDef external fill:#f1c40f,stroke:#f39c12,color:#fff
    
    %% Legend
    subgraph Legend
        L1["UI Component"]:::ui
        L2["Controller"]:::controller
        L3["Entity"]:::entity
        L4["External Service"]:::external
    end
```
