# daylinmorgan/tsm architecture

> Architecture diagram of the GitHub repository daylinmorgan/tsm, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/daylinmorgan/tsm
- Repository: https://github.com/daylinmorgan/tsm

## Overview

Key Components to Include:

##### Core Components
- User Interface Layer (Terminal-based)
- Session Management Core
- Configuration Handler
- Project Selector
- Tmux Integration Layer

##### External Dependencies
- Tmux (External System)
- File System (for project directories)
- Environment Variables

##### Data Flow Representation
- Environment variables (TSM_PATHS, TSM_HEIGHT) flowing into the Configuration Handler
- File system interaction for project discovery
- Communication flow between the core and tmux

##### Component Relationships

**[User Input Layer]**
- ↓
**[Terminal UI Layer]**
- ↓
**[Core Processing Layer]**
- ↓
**[External Integration Layer]**

##### Configuration Flow
- How TSM_PATHS affects project discovery
- Configuration loading from environment variables

##### Session Management
- Interaction between the selector and tmux
- How project paths are processed and converted to sessions

##### External Integration
- Boundary between TSM and tmux
- Command execution flow to tmux

Level of Detail:
- Notes for important configuration requirements

Remember to:
- Version control and build workflow components in a separate section
- Relationship between the nimble package manager and the project
- Nix integration for development environment

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles
    classDef core fill:#2196F3,stroke:#1565C0,color:white
    classDef external fill:#4CAF50,stroke:#2E7D32,color:white
    classDef config fill:#FFC107,stroke:#FFA000,color:black
    classDef storage fill:#90A4AE,stroke:#546E7A,color:white
    classDef ui fill:#9C27B0,stroke:#6A1B9A,color:white
    classDef build fill:#FF5722,stroke:#D84315,color:white

    %% User Input Layer
    UserInput(["User Input"]):::ui

    %% Terminal UI Layer
    TermUI["Terminal UI"]:::ui
    click TermUI "https://github.com/daylinmorgan/tsm/blob/main/src/term.nim"

    %% Core Layer
    SessionCore["Session Management Core"]:::core
    click SessionCore "https://github.com/daylinmorgan/tsm/blob/main/src/tsm.nim"
    
    ConfigHandler["Configuration Handler"]:::config
    click ConfigHandler "https://github.com/daylinmorgan/tsm/blob/main/src/config.nim"
    
    ProjectSelector["Project Selector"]:::core
    click ProjectSelector "https://github.com/daylinmorgan/tsm/blob/main/src/selector.nim"
    
    ProjectMgmt["Project Management"]:::core
    click ProjectMgmt "https://github.com/daylinmorgan/tsm/blob/main/src/project.nim"

    %% External Integration Layer
    TmuxUtils["Tmux Utils"]:::core
    click TmuxUtils "https://github.com/daylinmorgan/tsm/blob/main/src/tmuxutils.nim"
    
    Tmux["Tmux System"]:::external

    %% Build and Config Components
    subgraph Development
        BuildSystem["Build System"]:::build
        click BuildSystem "https://github.com/daylinmorgan/tsm/blob/main/.github/workflows/build.yml"
        
        PackageConfig["Package Configuration"]:::config
        click PackageConfig "https://github.com/daylinmorgan/tsm/blob/main/tsm.nimble"
        
        NixEnv["Nix Environment"]:::config
        click NixEnv "https://github.com/daylinmorgan/tsm/blob/main/nix/flake.nix"
    end

    %% Storage and Environment
    FileSystem[("File System")]:::storage
    EnvVars[("Environment Variables")]:::config

    %% Relationships
    UserInput --> TermUI
    TermUI --> SessionCore
    SessionCore --> ProjectSelector
    SessionCore --> ProjectMgmt
    ProjectSelector --> FileSystem
    ProjectMgmt --> TmuxUtils
    TmuxUtils --> Tmux
    EnvVars --> ConfigHandler
    ConfigHandler --> SessionCore
    FileSystem --> ProjectSelector
    
    %% Legend
    subgraph Legend
        L1["Core Components"]:::core
        L2["External Systems"]:::external
        L3["Configuration"]:::config
        L4["Storage"]:::storage
        L5["User Interface"]:::ui
        L6["Build System"]:::build
    end
```
