# hitsedu/web-algorithms architecture

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

- Interactive diagram: https://gitdiagram.com/hitsedu/web-algorithms
- Repository: https://github.com/hitsedu/web-algorithms

## Overview

##### Project Type & Purpose
- This is a full‑client, front‑end application built using React and TypeScript.
- The main purpose is to visually demonstrate algorithmic processes—each algorithm (e.g., A*, Ant Colony) has its dedicated screen/component.

##### Analyzing the File Structure
- Top‑Level Organization:
– There are configuration files (.env.example, package.json, tsconfig.json), a public directory (containing HTML templates and manifest files), and a src directory which contains all the TypeScript/React code.
- Modular Components:
– The src/components/screens folder contains different directories for each algorithm (a_star, ant, clusterization, genetic, neural_network, tree) plus a home screen, indicating that each algorithm demo is a separate “page” or module.
- Reusable Code:
– Custom hooks (found in src/hooks) are used to manage functionality like grid behaviors, canvas rendering, pointer movement, and resizing events.
- This directory structure shows a clear separation of concerns, aligning with a component-based UI architecture.

##### Key Insights from the README
- It also lists the technology stack (Node.js and React) and outlines a git-commit standard, though that part is more for development practices rather than system architecture.
- A linked Figma design shows that the UI has been thought through, which is reflected in the structured components (header, navigation, footer, etc.).

a. Main Components:
– Client-Side Application: Represented as a “React App” container.
– UI Layout and Containers: This includes components for Header, Footer, Navigation, and Info.
– Screens/Pages: Each algorithm demonstration screen (A*, Ant Colony, Clusterization, Genetic Algorithm, Neural Network, and Decision Tree) should be represented as distinct subcomponents.
– Custom Hooks: Represent the utility hooks (e.g., useCanvas, useGrid, usePointer, useResize) that manage behavior and state throughout the UI.
– Public Assets: Show the relationship with static assets contained in the public folder (e.g., index.html) which bootstrap the application.

b. Relationships and Interactions:
– The main App (src/App.tsx) serves as the central hub that ties together the UI structure.
– Navigation and routing (if using React Router or a similar mechanism) allow the application to switch between different algorithm screens.
– Each algorithm module (screen) interacts with shared controls and hooks to display visual updates and allow user interaction.
– Custom hooks (e.g., useCanvas, useResize) are integrated within these components to manage dynamic behavior and state.

c. Architectural Patterns & Design Principles:
– Component-Based Architecture: Emphasize separation of UI functionality into discrete, well-organized components.
– Modularity: Each algorithm is encapsulated within its own screen, which ensures a clear separation of algorithm logic and presentation.
– Reusability: Common elements like controls, grid layouts, and hooks are reused across different parts of the application.
– Maintainability: The project clearly organizes UI, business logic, and utilities in separate directories.

d. Relevant Technologies and Frameworks:
– React & TypeScript: Fundamental for building the UI.
– Node.js (as declared in the README) for running the development environment.
– CSS modules for styling individual components (evidenced by the *.css files alongside components).

– Start with a global view, showing the main App at the center.
– Branch out to layout components (Navigation, Header, Footer, Info).

This approach ensures that every major component and interaction in the project is captured and clearly represented.

## Diagram (Mermaid)

```mermaid
flowchart TD
    A["React App"]:::app

    subgraph "UI Layout"
        H["Header"]:::ui
        N["Navigation"]:::ui
        F["Footer"]:::ui
        I["Info"]:::ui
    end

    subgraph "Algorithm Screens"
        HO["Home Screen"]:::screen
        ASTAR["A* Screen"]:::screen
        ANT["Ant Colony Screen"]:::screen
        CLUST["Clusterization Screen"]:::screen
        GEN["Genetic Algorithm Screen"]:::screen
        NN["Neural Network Screen"]:::screen
        TREE["Decision Tree Screen"]:::screen
    end

    subgraph "Shared Components"
        G["Grid"]:::shared
        C["Controls"]:::shared
        ICON["Icons"]:::shared
    end

    subgraph "Custom Hooks"
        UC["useCanvas"]:::hook
        UG["useGrid"]:::hook
        UP["usePointer"]:::hook
        UR["useResize"]:::hook
    end

    PA["Public Assets"]:::assets

    %% Connections from React App
    A --> H
    A --> N
    A --> F
    A --> I
    A --> HO
    A --> G
    A --> PA
    A --> UC

    %% Navigation directs to Algorithm Screens
    N --> HO
    N --> ASTAR
    N --> ANT
    N --> CLUST
    N --> GEN
    N --> NN
    N --> TREE

    %% Algorithm Screens interactions with Shared Components and Custom Hooks
    ASTAR --> G
    ASTAR --> UC

    ANT --> G
    ANT --> UP

    CLUST --> G
    CLUST --> UG

    GEN --> G
    GEN --> UR

    NN --> G
    NN --> UC

    TREE --> G
    TREE --> UP

    %% Styles
    classDef app fill:#B39DDB,stroke:#4A148C,stroke-width:2px;
    classDef ui fill:#AEDFF7,stroke:#0277BD,stroke-width:2px;
    classDef screen fill:#C8E6C9,stroke:#2E7D32,stroke-width:2px;
    classDef shared fill:#FFF176,stroke:#F57F17,stroke-width:2px;
    classDef hook fill:#FFAB91,stroke:#D84315,stroke-width:2px;
    classDef assets fill:#CE93D8,stroke:#6A1B9A,stroke-width:2px;

    %% Click Events
    click A "https://github.com/hitsedu/web-algorithms/blob/main/src/App.tsx"
    click H "https://github.com/hitsedu/web-algorithms/blob/main/src/components/header/Header.tsx"
    click F "https://github.com/hitsedu/web-algorithms/blob/main/src/components/footer/Footer.tsx"
    click N "https://github.com/hitsedu/web-algorithms/blob/main/src/components/navigation/Navigation.tsx"
    click I "https://github.com/hitsedu/web-algorithms/blob/main/src/components/info/Info.tsx"
    click ASTAR "https://github.com/hitsedu/web-algorithms/blob/main/src/components/screens/a_star/AStar.tsx"
    click ANT "https://github.com/hitsedu/web-algorithms/blob/main/src/components/screens/ant/Ant.tsx"
    click CLUST "https://github.com/hitsedu/web-algorithms/blob/main/src/components/screens/clusterization/Clusterization.tsx"
    click GEN "https://github.com/hitsedu/web-algorithms/tree/main/src/components/screens/genetic"
    click NN "https://github.com/hitsedu/web-algorithms/blob/main/src/components/screens/neural_network/NeuralNetwork.tsx"
    click TREE "https://github.com/hitsedu/web-algorithms/blob/main/src/components/screens/tree/Tree.tsx"
    click G "https://github.com/hitsedu/web-algorithms/blob/main/src/components/grid/Grid.tsx"
    click C "https://github.com/hitsedu/web-algorithms/blob/main/src/components/controls/Controls.tsx"
    click ICON "https://github.com/hitsedu/web-algorithms/tree/main/src/components/icons"
    click UC "https://github.com/hitsedu/web-algorithms/blob/main/src/hooks/useCanvas.ts"
    click UG "https://github.com/hitsedu/web-algorithms/blob/main/src/hooks/useGrid.ts"
    click UP "https://github.com/hitsedu/web-algorithms/blob/main/src/hooks/usePointer.ts"
    click UR "https://github.com/hitsedu/web-algorithms/blob/main/src/hooks/useResize.ts"
    click PA "https://github.com/hitsedu/web-algorithms/tree/main/public"
```
