# skalskip/make-sense architecture

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

- Interactive diagram: https://gitdiagram.com/skalskip/make-sense
- Repository: https://github.com/skalskip/make-sense

## Overview

##### Project’s Core Purpose and Type
- The README makes it clear that makesense.ai is a browser-based tool for labeling photos. It is built using TypeScript with React/Redux and integrates on-device AI (e.g., YOLOv5, SSD, PoseNet via TensorFlow.js) to accelerate deep learning dataset preparation.
- Capturing the separation between the user interface (frontend) and the underlying logic (Redux store, AI integrations, rendering, and utilities).

##### Main Architectural Components
a. User Interface (Frontend Presentation Layer)
- Views: Represented by the many React components in the “src/views” directory (e.g., EditorView, MainView, PopupView, NotificationsView).
- Common components: Present in subdirectories like “Common” that include buttons, inputs, and navigation elements.
- Style: The SCSS files co-located with components indicate a strong focus on styling and user interactions.

b. State Management and Business Logic
- Redux Store: Components for actions, reducers, selectors are clearly delineated within “src/store” and “src/logic/actions”.
- Context and Global State: The “src/logic/context” directory suggests additional context management to handle aspects like editor and popup states.
- The initialization process is visibly handled in “src/logic/initializer/AppInitializer.ts” which sets up the application.

c. AI Integrations and Core Processing
- AI Module: The “src/ai” directory contains modules for different AI functionalities (PoseDetector, RoboflowAPIObjectDetector, SSDObjectDetector, YOLOV5ObjectDetector). These components bridge the gap between UI actions and TensorFlow.js-driven inference.
- AI Actions: There are dedicated actions (e.g., AIActions, AIPoseDetectionActions) that connect the AI modules with the Redux workflow.

d. Rendering & Visualization
- Render Engines: The “src/logic/render” folder holds different rendering engines (Rect, Polygon, Line, Point, and PrimaryEditorRenderEngine). This aspect is crucial for drawing labels and annotations on images.
- The “src/logic/imageRepository” supports image loading and management for annotations.

e. Data and Configuration Models
- Data Layer: The “src/data” structure (with files for EditorData, Import/Export formats, and various label configurations) provides definitions and configurations used throughout the app.
- Interfaces and Enums: Found in “src/interfaces” and “src/data/enums”, these ensure strong typing, which is critical for a TypeScript project.

f. Utility Functions and Helpers
- Numerous helper functions in “src/utils” support array operations, file handling, drawing, notifications, etc. These are utility classes that underpin many core functionalities.

g. Deployment and DevOps
- Docker: The “docker” directory houses the Dockerfile, implying containerization for deployment.
- CI/CD: The “.github/workflows” directory includes GitHub Actions for testing, code analysis, and documentation generation.
- Configuration: Files such as package.json, tsconfig.json, vite.config.ts, and eslint/tslint configurations illustrate the tooling behind the architecture.

##### Relationships and Interactions
- The React views dispatch actions (defined in “src/logic/actions”) to the Redux store, which then updates the state. Connectors (via selectors) allow the UI to react to state changes.
- AI modules are invoked through dedicated actions. For example, when a user initiates an AI-based detection, the corresponding AI action calls one of the detector classes (YOLOV5ObjectDetector, etc.) that process the image data and return predictions.
- The rendering engine in “src/logic/render” consumes both the labeling data and canvas details to display the results interactively.
- Utilities and helpers play a supporting role across these layers (e.g., handling file I/O, rendering calculations, and event management).

##### Architectural Patterns and Design Principles
- Separation of Concerns: The project clearly separates UI components, state management, business logic, and AI functions.
- Modular Design: Dedicated directories for AI models, render engines, and data definitions foster maintainability.
- Testability: The extensive “__tests__” folders indicate unit testing is an important aspect.
- Responsiveness: The presence of both “EditorView” and “MobileMainView” shows attention to cross-platform UI.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend Layer"
        R_Views("React Views"):::ui
    end

    %% Business Logic Layer
    subgraph "Business Logic Layer"
        AppInit("App Initializer"):::logic
        Context("Context Management"):::logic
        RS("Redux Store"):::logic
        R_Actions("Redux Actions"):::logic
    end

    %% AI Processing
    subgraph "AI Processing"
        AI_Actions("AI Actions"):::ai
        AI_Mod("AI Modules"):::ai
    end

    %% Rendering & Visualization
    subgraph "Rendering & Visualization"
        RenderEng("Render Engines"):::rendering
        ImgRepo("Image Management"):::rendering
    end

    %% Data & Configuration
    subgraph "Data & Configuration"
        DM("Data Models"):::data
        Interfaces("Interfaces"):::data
        Enums("Enums"):::data
    end

    %% Utilities
    subgraph "Utilities"
        Utils("Utility Functions"):::utility
    end

    %% Deployment/DevOps
    subgraph "Deployment/DevOps"
        Docker("Docker"):::deployment
        CICD("CI/CD Workflows"):::deployment
    end

    %% Connections between layers
    R_Views -->|"dispatches"| R_Actions
    R_Actions -->|"updates"| RS
    R_Actions -->|"triggers"| AI_Actions
    AI_Actions -->|"calls"| AI_Mod
    RS -->|"providesData"| RenderEng
    RenderEng -->|"manages"| ImgRepo
    RS -->|"stateUpdate"| R_Views
    AppInit --> RS
    AppInit --> Context

    %% Support connections (dotted lines)
    Utils -.-> R_Actions
    Utils -.-> RenderEng
    DM -.-> RS
    Interfaces -.-> RS
    Enums -.-> RS

    %% Click Events
    click R_Views "https://github.com/skalskip/make-sense/tree/develop/src/views"
    click RS "https://github.com/skalskip/make-sense/tree/develop/src/store"
    click R_Actions "https://github.com/skalskip/make-sense/tree/develop/src/logic/actions"
    click Context "https://github.com/skalskip/make-sense/tree/develop/src/logic/context"
    click AppInit "https://github.com/skalskip/make-sense/blob/develop/src/logic/initializer/AppInitializer.ts"
    click AI_Actions "https://github.com/skalskip/make-sense/tree/develop/src/logic/actions"
    click AI_Mod "https://github.com/skalskip/make-sense/tree/develop/src/ai"
    click RenderEng "https://github.com/skalskip/make-sense/tree/develop/src/logic/render"
    click ImgRepo "https://github.com/skalskip/make-sense/tree/develop/src/logic/imageRepository"
    click DM "https://github.com/skalskip/make-sense/tree/develop/src/data"
    click Interfaces "https://github.com/skalskip/make-sense/tree/develop/src/interfaces"
    click Enums "https://github.com/skalskip/make-sense/tree/develop/src/data/enums"
    click Utils "https://github.com/skalskip/make-sense/tree/develop/src/utils"
    click Docker "https://github.com/skalskip/make-sense/tree/develop/docker/Dockerfile"
    click CICD "https://github.com/skalskip/make-sense/tree/develop/.github/workflows"

    %% Styles
    classDef ui fill:#a3d5ff,stroke:#333,stroke-width:2px;
    classDef logic fill:#f9e79f,stroke:#333,stroke-width:2px;
    classDef ai fill:#f5b7b1,stroke:#333,stroke-width:2px;
    classDef rendering fill:#d5f5e3,stroke:#333,stroke-width:2px;
    classDef data fill:#d6eaf8,stroke:#333,stroke-width:2px;
    classDef utility fill:#fad7a0,stroke:#333,stroke-width:2px;
    classDef deployment fill:#e8daef,stroke:#333,stroke-width:2px;
```
