# minimalistorg/minimalistidev2 architecture

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

- Interactive diagram: https://gitdiagram.com/minimalistorg/minimalistidev2
- Repository: https://github.com/minimalistorg/minimalistidev2

## Overview

##### Project type and purpose
- This is a single-page full-stack (frontend-only) React application bootstrapped with Create React App.
- It visualizes and explores JavaScript/TypeScript code via Tree-Sitter: parsing code into an AST, rendering it, computing call trees, fuzzy-searching identifiers, etc.
- It may fetch code from external sources (GitHub Gist, repos) via `apiService.tsx`.

##### File structure
- Top-level:
- src/ – application source
– components/ – presentational React components grouped by feature
– services/ – business logic: `apiService.tsx` (fetching code), `parser.ts` (driving Tree-Sitter)
– hooks/ – custom React hooks for interactivity
– Root-file/Redux – Redux store and slices for global state (bubbles, call tree, JWT)
– util/ – URL params & helper functions
- tests under src/ – unit & integration tests for parsing, API, utilities
- Configuration:
- package.json, tsconfig.json, .env* – dependencies and environment
- playwright.config.ts – e2e test settings
- GitHub Actions workflow under .github/workflows

##### README for additional insights
- Standard Create React App scripts: start, test, build, eject.

##### Main components
a. User Interface (Browser)
– React SPA UI (index.html → index.tsx → App.tsx → components)
– Key UI modules:
- Code Loader (MenuHeader/LoadCode)
- Code Viewer (CodeBlock, RenderTreeSitter)
- Call Tree Visualizer (CallTree)
- Search (FuzzySearch)
- Alerts (AlertTemplate)
b. State Management Layer
– Redux store (Root-file/Redux/store.ts)
– Slices: addBubbleSlice, callTreeSlice, jwtSlice
c. Services Layer
– apiService.tsx – handles HTTP requests to external APIs (e.g., GitHub Gist, repo endpoints)
– parser.ts – wraps Tree-Sitter WASM parsing engine
d. Static Assets / External Dependencies
– Tree-Sitter WASM modules (public/assets/TreeSitter)
– GitHub or other external code hosting APIs
e. Build & Deployment
– Webpack/Babel under the hood (Create React App)
– CI pipeline (GitHub Actions .github/workflows/test.yml)
f. Testing
– Unit tests (columnCount, services, util)
– Integration tests under src/test
– E2E tests via Playwright

##### Relationships & interactions
- Browser → serves index.html → loads JS bundle
- UI Components dispatch actions → Redux store
- UI triggers parser service → Tree-Sitter WASM → produces AST
- AST fed back into UI (RenderTreeSitter) & call-tree generator
- UI invokes apiService to fetch code → results into Redux or direct props
- Redux updates propagate to components
- CI runs tests, lints, builds via GitHub Actions

##### Architectural patterns & design principles
- Component-based UI (presentational vs container)
- Unidirectional data flow (React → Redux → UI)
- Separation of concerns: parsing logic in services, state in Redux, rendering in components
- Lazy loading of WASM assets via public folder
- Hooks for encapsulating reusable logic

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Browser / React UI"
        direction TB
        IndexHTML["index.html"]:::ui
        IndexTSX["index.tsx"]:::ui
        AppTSX["App.tsx"]:::ui
        CodeLoader["Code Loader (MenuHeader)"]:::ui
        CodeViewer["Code Viewer"]:::ui
        CallTreeVis["Call Tree Visualizer"]:::ui
        FuzzySearchComp["Fuzzy Search"]:::ui
        AlertComp["Alerts"]:::ui
    end

    subgraph "State Management (Redux)"
        direction TB
        Store["Redux Store"]:::state
        AddBubbleSlice["addBubbleSlice"]:::state
        CallTreeSlice["callTreeSlice"]:::state
        JwtSlice["jwtSlice"]:::state
    end

    subgraph "Services Layer"
        direction TB
        ApiService["apiService"]:::service
        ParserService["parser (Tree-Sitter)"]:::service
    end

    subgraph "External Dependencies"
        direction TB
        WASM["Tree-Sitter WASM Modules"]:::external
        GitHubAPI["GitHub API"]:::external
    end

    subgraph "CI / Build & Deployment"
        direction TB
        Workflow["GitHub Actions Workflow"]:::pipeline
        Build["CRA Build"]:::pipeline
        PlaywrightCfg["Playwright Config"]:::pipeline
        Deploy["Deploy"]:::pipeline
    end

    %% Relationships
    IndexHTML -->|serves| IndexTSX
    IndexTSX -->|renders| AppTSX
    AppTSX -->|renders| CodeLoader
    AppTSX -->|renders| CodeViewer
    AppTSX -->|renders| CallTreeVis
    AppTSX -->|renders| FuzzySearchComp
    AppTSX -->|renders| AlertComp

    CodeLoader -->|dispatches actions| Store
    CodeViewer -->|dispatches actions| Store
    CallTreeVis -->|dispatches actions| Store
    FuzzySearchComp -->|dispatches actions| Store
    AlertComp -->|dispatches actions| Store

    Store -->|state updates| CodeLoader
    Store -->|state updates| CodeViewer
    Store -->|state updates| CallTreeVis
    Store -->|state updates| FuzzySearchComp
    Store -->|state updates| AlertComp

    CodeViewer -->|calls| ParserService
    ParserService -->|loads| WASM
    ParserService -->|returns AST| CodeViewer

    CodeLoader -->|calls| ApiService
    ApiService -->|fetches from| GitHubAPI
    ApiService -->|returns code| Store

    Workflow --> Build
    Workflow --> PlaywrightCfg
    Build --> Deploy

    %% Click Events
    click IndexHTML "https://github.com/minimalistorg/minimalistidev2/blob/main/public/index.html"
    click IndexTSX "https://github.com/minimalistorg/minimalistidev2/blob/main/src/index.tsx"
    click AppTSX "https://github.com/minimalistorg/minimalistidev2/blob/main/src/App.tsx"
    click CodeLoader "https://github.com/minimalistorg/minimalistidev2/blob/main/src/components/MenuHeader/MenuHeader.tsx"
    click CodeViewer "https://github.com/minimalistorg/minimalistidev2/blob/main/src/components/CodeBlock/CodeBlockTS.tsx"
    click CallTreeVis "https://github.com/minimalistorg/minimalistidev2/blob/main/src/components/CallTree/CallTree.tsx"
    click FuzzySearchComp "https://github.com/minimalistorg/minimalistidev2/blob/main/src/components/FuzzySearch/FuzzySearch.tsx"
    click AlertComp "https://github.com/minimalistorg/minimalistidev2/blob/main/src/components/AlertTemplate/AlertTemplate.tsx"
    click Store "https://github.com/minimalistorg/minimalistidev2/blob/main/src/components/Root-file/Redux/store.ts"
    click AddBubbleSlice "https://github.com/minimalistorg/minimalistidev2/blob/main/src/components/Root-file/slice/addBubbleSlice.ts"
    click CallTreeSlice "https://github.com/minimalistorg/minimalistidev2/blob/main/src/components/Root-file/slice/callTreeSlice.ts"
    click JwtSlice "https://github.com/minimalistorg/minimalistidev2/blob/main/src/components/Root-file/slice/jwtSlice.ts"
    click ApiService "https://github.com/minimalistorg/minimalistidev2/blob/main/src/services/apiService.tsx"
    click ParserService "https://github.com/minimalistorg/minimalistidev2/blob/main/src/services/parser.ts"
    click WASM "https://github.com/minimalistorg/minimalistidev2/tree/main/public/assets/TreeSitter"
    click Workflow "https://github.com/minimalistorg/minimalistidev2/blob/main/.github/workflows/test.yml"
    click PlaywrightCfg "https://github.com/minimalistorg/minimalistidev2/blob/main/playwright.config.ts"

    %% Styles
    classDef ui fill:#cfe2ff,stroke:#0366d6,stroke-width:1px
    classDef state fill:#d1e7dd,stroke:#0f5132,stroke-width:1px
    classDef service fill:#ffe5b4,stroke:#d39e00,stroke-width:1px
    classDef external fill:#e2e3e5,stroke:#6c757d,stroke-width:1px
    classDef pipeline fill:#f8d7da,stroke:#842029,stroke-width:1px
```
