# over-coder/stash architecture

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

- Interactive diagram: https://gitdiagram.com/over-coder/stash
- Repository: https://github.com/over-coder/stash

## Overview

##### High-Level Architecture Overview

a) Frontend Layer (Next.js)
- Components from /app directory
- Components like SessionCard, ActionRing, and NavbarSearch

b) Middleware Layer (Tauri/Rust)
- In the middle
- Src-tauri/main.rs as the bridge
- Command handling and IPC

c) Backend Layer (Python)
- At the bottom
- Main.py and scripts (dumpconfig.py, getwindows.py, restorewin.py)
- Interaction with Windows OS

##### Component Relationships

a) User Interface Flow:
- Frontend components:
- NavbarSearch → SessionCard
- ActionRing → Session management actions
- Conditional components → Configuration layout

b) Data Flow:
- Frontend → Tauri Commands
- Tauri → Python Backend
- Python Backend → Windows OS
- Windows OS → Python Scripts
- Results back through the chain

##### Specific Components

Frontend Section:
**┌─ Next.js UI Layer ─────────────┐**
- Components                  │
- SessionCard             │
- ActionRing              │
- NavbarSearch            │
- Conditional Logic          │
- Configuration Layout       │
- ┘

Middleware Section:
**┌─ Tauri/Rust Layer ────────────┐**
- Command Handlers          │
- IPC Bridge               │
- Python Sidecar Manager   │
- ┘

Backend Section:
**┌─ Python Backend ──────────────┐**
- Window Management         │
- Config Management        │
- Session Restoration      │
- ┘

##### Important Details to Highlight
- The "Jugaad" tech stack nature
- Python executable as a sidecar
- Window state management flow
- Session storage and restoration paths

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Frontend
        UI[Next.js UI]:::frontend
        SC[SessionCard]:::frontend
        AR[ActionRing]:::frontend
        NS[NavbarSearch]:::frontend
        CL["Configuration Layout"]:::frontend
        CC["Conditional Components"]:::frontend
        SU["Startup Management"]:::frontend
        API["API Utils"]:::frontend
        
        UI --> SC
        UI --> AR
        UI --> NS
        UI --> CL
        UI --> CC
        UI --> SU
        UI --> API
    end

    subgraph Middleware
        TB["Tauri Bridge"]:::middleware
        TC["Tauri Config"]:::middleware
        CH["Command Handlers"]:::middleware
        IPC["IPC Bridge"]:::middleware
        PSM["Python Sidecar Manager"]:::middleware
        
        TB --> CH
        TB --> IPC
        TC --> TB
        CH --> PSM
        IPC --> PSM
    end

    subgraph Backend
        PB["Python Backend"]:::backend
        WM["Window Management"]:::backend
        CM["Config Management"]:::backend
        SR["Session Restoration"]:::backend
        
        PB --> WM
        PB --> CM
        PB --> SR
    end

    subgraph OS
        WIN["Windows OS"]:::system
    end

    API -..-> TB
    PSM -..-> PB
    SR --> WIN
    WM --> WIN
    
    %% Component Mappings
    click SC "https://github.com/OVER-CODER/Stash/blob/main/app/Components/SessionCard.jsx"
    click AR "https://github.com/OVER-CODER/Stash/blob/main/app/Components/ActionRing.jsx"
    click NS "https://github.com/OVER-CODER/Stash/blob/main/app/Components/NavbarSearch.js"
    click CL "https://github.com/OVER-CODER/Stash/blob/main/app/configlayout/page.jsx"
    click CC "https://github.com/OVER-CODER/Stash/blob/main/app/conditional/page.jsx"
    click TB "https://github.com/OVER-CODER/Stash/blob/main/src-tauri/src/main.rs"
    click TC "https://github.com/OVER-CODER/Stash/blob/main/src-tauri/tauri.conf.json"
    click PB "https://github.com/OVER-CODER/Stash/blob/main/src/backends/main.py"
    click WM "https://github.com/OVER-CODER/Stash/blob/main/src/backends/scripts/getwindows.py"
    click CM "https://github.com/OVER-CODER/Stash/blob/main/src/backends/scripts/dumpconfig.py"
    click SR "https://github.com/OVER-CODER/Stash/blob/main/src/backends/scripts/restorewin.py"
    click API "https://github.com/OVER-CODER/Stash/blob/main/app/utils/api.js"
    click SU "https://github.com/OVER-CODER/Stash/blob/main/app/startup/page.jsx"

    %% Styling
    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef middleware fill:#e67e22,stroke:#d35400,color:white
    classDef backend fill:#2ecc71,stroke:#27ae60,color:white
    classDef system fill:#e74c3c,stroke:#c0392b,color:white

    %% Legend
    subgraph Legend
        F["Frontend Component"]:::frontend
        M["Middleware Component"]:::middleware
        B["Backend Component"]:::backend
        S["System Component"]:::system
        D["--> Direct Connection"]
        A["-.-> Async Connection"]
    end
```
