# mitate-gengaku/repree architecture

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

- Interactive diagram: https://gitdiagram.com/mitate-gengaku/repree
- Repository: https://github.com/mitate-gengaku/repree

## Overview

##### Project Type and Purpose
- Project Type: A modern full-stack (or primarily frontend) web application built using Next.js and React. It leverages the React Flow paradigm to create interactive, zoomable, and themable visualizations of code structure.
- Purpose: The tool analyzes a file’s structure (including node modules and internal components) and renders it as an interactive graph. The README emphasizes features such as relation filtering, zooming, theming, and the sidebar display of files and modules.

##### File Structure
- Top-Level Components:
– Configuration Files: Dockerfile, docker-compose.yml, LICENSE.md, tsconfig.json, tailwind.config.ts, and various GitHub workflow configurations.
– README.md: Provides project description and visual feature highlights.
- src Folder:
– Contains the entire Next.js application. The structure under “src/src/app” follows Next.js conventions (layout.tsx, page.tsx, globals.css).
– The “api” directory (src/src/app/api/analyze/route.ts) indicates a backend API route used to perform file system or analysis operations.
– Domain-specific logic is encapsulated within “constant”, “features”, “service”, “stores”, “types”, and “utils” directories. For example, “elk-layout-calculator.ts” hints at using ELK (Eclipse Layout Kernel) for graph layout computation.
- Architectural Patterns:
– The structure suggests a clean separation between presentation (React components, UI controls, layout files) and data/business logic (API, services, stores, hooks, and utilities).
– It uses modular design patterns, evident from components, hooks, and state stores, suggesting reusability and the adoption of a unidirectional data flow mechanism.

##### Elements
– From User Interactions to UI Components.
– From UI to API (for analysis requests) and back.
– Within the frontend, the interaction between components, hooks, and state stores.
- Annotations to denote third-party integrations (e.g., Docker for deployment and Tailwind for styling).

## Diagram (Mermaid)

```mermaid
flowchart TD
    U["User Interaction (Browser)"]:::client

    subgraph "Frontend/UI Layer"
        subgraph "Next.js App Shell"
            NS1["App Layout"]:::client
            NS2["App Page"]:::client
            NS3["Global Styles"]:::client
        end
        subgraph "UI Components"
            subgraph "Layout Components"
                UI1["Header"]:::client
                UI2["Sidebar"]:::client
                UI3["Main"]:::client
                UI4["Mobile Sidebar"]:::client
            end
            subgraph "Visualization & Controls"
                UI5["Controls"]:::client
                UI6["File Node"]:::client
                UI7["Node Modules Node"]:::client
                UI8["Highlight Edge"]:::client
            end
            subgraph "Feature Modules"
                subgraph "Theme Feature"
                    TF1["Theme Provider"]:::feature
                    TF2["Theme Switch"]:::feature
                    TF3["Toggle Button"]:::feature
                    TF4["useTheme Hook"]:::feature
                end
                subgraph "Upload Feature"
                    UF1["Upload Button"]:::feature
                    UF2["Upload Form"]:::feature
                end
            end
        end
    end

    subgraph "Backend/API Layer"
        API1["Analyze API"]:::api
    end

    subgraph "Service & Business Logic Layer"
        S1["Analysis Service"]:::service
    end

    subgraph "Utility Modules"
        UTL1["ELK Layout"]:::utility
        UTL2["Analyze Utility"]:::utility
        UTL3A["Utils"]:::utility
        UTL3B["Download Image"]:::utility
    end

    subgraph "State Management"
        ST1["Dialog Store"]:::state
        ST2["Node Store"]:::state
        ST3["Edge Store"]:::state
        ST4["Select Node Store"]:::state
        ST5["Theme Store"]:::state
    end

    %% Connections
    U --> NS1
    NS1 --> UI1
    NS1 --> UI5

    UI5 -->|"triggers"| API1
    API1 -->|"processes"| S1
    S1 -->|"calculates"| UTL1
    S1 -->|"analyzes"| UTL2
    S1 -->|"utilizes"| UTL3A
    S1 -->|"downloads"| UTL3B
    S1 -->|"updates"| ST1
    S1 -->|"updates"| ST2
    S1 -->|"updates"| ST3
    S1 -->|"updates"| ST5

    ST2 -->|"renders"| UI6
    ST3 -->|"renders"| UI8
    TF4 -->|"modifies"| ST5
    UF1 --> UF2
    UF2 -->|"submits"| S1

    %% Click Events
    click NS1 "https://github.com/mitate-gengaku/repree/blob/main/src/src/app/layout.tsx"
    click NS2 "https://github.com/mitate-gengaku/repree/blob/main/src/src/app/page.tsx"
    click NS3 "https://github.com/mitate-gengaku/repree/blob/main/src/src/app/globals.css"

    click UI1 "https://github.com/mitate-gengaku/repree/blob/main/src/src/components/layout/header.tsx"
    click UI2 "https://github.com/mitate-gengaku/repree/blob/main/src/src/components/layout/sidebar.tsx"
    click UI3 "https://github.com/mitate-gengaku/repree/blob/main/src/src/components/layout/main.tsx"
    click UI4 "https://github.com/mitate-gengaku/repree/blob/main/src/src/components/layout/mobile-sidebar.tsx"
    click UI5 "https://github.com/mitate-gengaku/repree/tree/main/src/src/components/lib/controls/*"
    click UI6 "https://github.com/mitate-gengaku/repree/blob/main/src/src/components/lib/node/file-node.tsx"
    click UI7 "https://github.com/mitate-gengaku/repree/blob/main/src/src/components/lib/node/node-modules-node.tsx"
    click UI8 "https://github.com/mitate-gengaku/repree/blob/main/src/src/components/lib/edge/highlight.tsx"

    click API1 "https://github.com/mitate-gengaku/repree/blob/main/src/src/app/api/analyze/route.ts"

    click S1 "https://github.com/mitate-gengaku/repree/blob/main/src/src/service/fetch-folder-analyze.ts"

    click UTL1 "https://github.com/mitate-gengaku/repree/blob/main/src/src/utils/elk-layout-calculator.ts"
    click UTL2 "https://github.com/mitate-gengaku/repree/blob/main/src/src/utils/analyze.ts"
    click UTL3A "https://github.com/mitate-gengaku/repree/blob/main/src/src/lib/utils.ts"
    click UTL3B "https://github.com/mitate-gengaku/repree/blob/main/src/src/lib/download-image.ts"

    click ST1 "https://github.com/mitate-gengaku/repree/blob/main/src/src/stores/dialog.ts"
    click ST2 "https://github.com/mitate-gengaku/repree/blob/main/src/src/stores/node.ts"
    click ST3 "https://github.com/mitate-gengaku/repree/blob/main/src/src/stores/edge.ts"
    click ST4 "https://github.com/mitate-gengaku/repree/blob/main/src/src/stores/select-node.ts"
    click ST5 "https://github.com/mitate-gengaku/repree/blob/main/src/src/stores/theme.ts"

    click TF1 "https://github.com/mitate-gengaku/repree/blob/main/src/src/features/theme/components/theme-provider.tsx"
    click TF2 "https://github.com/mitate-gengaku/repree/blob/main/src/src/features/theme/components/theme-switch.tsx"
    click TF3 "https://github.com/mitate-gengaku/repree/blob/main/src/src/features/theme/components/toggle-button.tsx"
    click TF4 "https://github.com/mitate-gengaku/repree/blob/main/src/src/features/theme/hooks/use-theme.ts"

    click UF1 "https://github.com/mitate-gengaku/repree/blob/main/src/src/features/upload/components/upload-button.tsx"
    click UF2 "https://github.com/mitate-gengaku/repree/blob/main/src/src/features/upload/components/upload-form.tsx"

    %% Styles
    classDef client fill:#AEDFF7,stroke:#005792,stroke-width:2px;
    classDef api fill:#F4A261,stroke:#E76F51,stroke-width:2px;
    classDef service fill:#FFB703,stroke:#F77F00,stroke-width:2px;
    classDef utility fill:#AED581,stroke:#7CB342,stroke-width:2px;
    classDef state fill:#CE93D8,stroke:#8E24AA,stroke-width:2px;
    classDef feature fill:#FDD835,stroke:#F9A825,stroke-width:2px;
```
