# ischerba32/innowise-lab-internship-level-2-mini-paint architecture

> Architecture diagram of the GitHub repository ischerba32/innowise-lab-internship-level-2-mini-paint, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-04). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ischerba32/innowise-lab-internship-level-2-mini-paint
- Repository: https://github.com/ischerba32/innowise-lab-internship-level-2-mini-paint

## Overview

##### Project Type & Core Purpose
- The project is a single-page application (SPA) built with React. Its purpose is to provide a mini “paint” or drawing application that allows users to create and manage images.
- It uses a modern stack with TypeScript, Redux Toolkit, Redux-Saga for async logic, and Firebase for authentication, the real-time database, and storage. It also leverages various UI and utility libraries like Sass, Moment, React Router, and others.

##### File Structure
- The top-level directories include configuration files (e.g., .eslintrc, .prettierrc), public (static assets and the initial HTML file), and src (all of the application’s code).
- Under src, components are clearly segregated into functional UI pieces:
◦ “AuthForm”, “AuthRoute” – for authentication related UI.
◦ “CanvasMenu”, “Header”, etc. – to support the drawing and layout.
◦ “Images” directory with subcomponents “ImageItem” and “ImagesList” for handling image-related views.
◦ “UI” folder contains stateless, reusable components such as Button, Card, Input, Loader, and ThemeSwitch.
- The redux folder contains slices (reducers and actions), as well as sagas (for images and user async handling), showing usage of a centralized state management system.
- Other directories like config, helpers, hooks, interfaces, and styles support modular application functionalities (e.g., Firebase integration, custom hooks, type definitions, and global styles).

##### Key Architectural Components
a. Frontend Presentation Layer:
- Pages: Home, Canvas, SignIn, SignUp.
- Components: Authentication components (AuthForm, AuthRoute), Header, CanvasMenu, Images components, and the collection of UI components.
b. State Management Layer:
- Redux Store: Highlight the slices (canvasSlice, imagesSlice, menuSlice, themeSlice, userSlice) that manage the application state.
- Redux Sagas: Separate sagas handling asynchronous operations for images and user activities.
- Interaction Flow: Show how UI components dispatch actions that flow into the Redux store, which in turn notifies components about state updates.
c. External Services:
- Firebase: Include the Firebase config component for authentication (via Firebase Auth), Realtime Database, and Storage (for saving images). Illustrate the data flow between Firebase and Redux (for instance, fetching user details and images).
d. Helper/Utility Layer:
- Custom hooks (useDraw, useTheme) that abstract common functionality (drawing on the canvas, theme management).
- Helpers for drawing figures, date formatting, and option selection.

##### Relationships & Interactions
- The static public folder contains the base index.html that bootstraps the React application; this is the root entry point.

##### Important Architectural Patterns & Design Principles
- Separation of Concerns: The project cleanly separates presentation (React components), business state logic (Redux slices and sagas), and external data handling (Firebase).
- Component-based Architecture: Every UI piece is encapsulated in its own folder with clear boundaries (component logic in index.tsx, typings in props.ts, and styling in a module SCSS file).
- Unidirectional Data Flow: The communication between components and state follows a unidirectional pattern (dispatch → Redux store → state update → UI render).
- Modular and Scalable Structure: The clear segregation of pages, reusable UI components, and state management logic shows an emphasis on maintainability and scalability.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Site Entry
    subgraph "Site Entry"
        Index["public/index.html"]:::entry
    end

    %% UI/Presentation Layer
    subgraph "UI/Presentation Layer"
        Pages["Pages: Home, Canvas, SignIn, SignUp"]:::presentation
        subgraph "Components"
            Header["Header"]:::presentation
            AuthForm["Auth Form"]:::presentation
            AuthRoute["Auth Route"]:::presentation
            CanvasMenu["CanvasMenu"]:::presentation
            ImagesComp["Images Components"]:::presentation
            ReusableUI["Reusable UI Components"]:::presentation
        end
    end

    %% State Management Layer
    subgraph "State Management Layer"
        ReduxStore["Redux Store"]:::redux
        Slices["Slices: canvas, filter, images, menu, theme, user"]:::redux
        subgraph "Redux Sagas"
            ImagesSaga["Images Saga"]:::redux
            UserSaga["User Saga"]:::redux
        end
    end

    %% External Services
    subgraph "External Services"
        Firebase["Firebase"]:::external
    end

    %% Utility Layer
    subgraph "Utility Layer"
        CustomHooks["Custom Hooks"]:::utility
        Helpers["Helpers"]:::utility
    end

    %% Connections
    Index -->|"loads"| Pages
    Pages -->|"renders"| Header
    Pages -->|"renders"| AuthForm
    Pages -->|"renders"| AuthRoute
    Pages -->|"renders"| CanvasMenu
    Pages -->|"renders"| ImagesComp
    Pages -->|"renders"| ReusableUI

    Header -->|"dispatches"| ReduxStore
    AuthForm -->|"dispatches"| ReduxStore
    AuthRoute -->|"dispatches"| ReduxStore
    CanvasMenu -->|"dispatches"| ReduxStore
    ImagesComp -->|"dispatches"| ReduxStore
    ReusableUI -->|"dispatches"| ReduxStore

    ReduxStore -->|"updates state to"| Header
    ReduxStore -->|"updates state to"| AuthForm
    ReduxStore -->|"updates state to"| AuthRoute
    ReduxStore -->|"updates state to"| CanvasMenu
    ReduxStore -->|"updates state to"| ImagesComp
    ReduxStore -->|"updates state to"| ReusableUI

    ReduxStore -->|"triggers"| Slices
    ReduxStore -->|"activates"| ImagesSaga
    ReduxStore -->|"activates"| UserSaga

    ImagesSaga -->|"async_ops"| Firebase
    UserSaga -->|"async_ops"| Firebase

    CustomHooks -->|"supports"| Header
    CustomHooks -->|"supports"| CanvasMenu
    CustomHooks -->|"supports"| ImagesComp

    Helpers -->|"supports"| Header
    Helpers -->|"supports"| AuthForm
    Helpers -->|"supports"| CanvasMenu

    %% Styles
    classDef presentation fill:#f9e79f,stroke:#7d6608,stroke-width:2px;
    classDef redux fill:#aed6f1,stroke:#21618c,stroke-width:2px;
    classDef external fill:#a9dfbf,stroke:#1e8449,stroke-width:2px;
    classDef utility fill:#f5b7b1,stroke:#922b21,stroke-width:2px;
    classDef entry fill:#f9e79f,stroke:#b9770e,stroke-width:2px;

    %% Click Events
    click Index "https://github.com/ischerba32/innowise-lab-internship-level-2-mini-paint/blob/main/public/index.html"
    click Pages "https://github.com/ischerba32/innowise-lab-internship-level-2-mini-paint/tree/main/src/pages"
    click AuthForm "https://github.com/ischerba32/innowise-lab-internship-level-2-mini-paint/tree/main/src/components/AuthForm"
    click AuthRoute "https://github.com/ischerba32/innowise-lab-internship-level-2-mini-paint/tree/main/src/components/AuthRoute"
    click Header "https://github.com/ischerba32/innowise-lab-internship-level-2-mini-paint/tree/main/src/components/Header"
    click CanvasMenu "https://github.com/ischerba32/innowise-lab-internship-level-2-mini-paint/tree/main/src/components/CanvasMenu"
    click ImagesComp "https://github.com/ischerba32/innowise-lab-internship-level-2-mini-paint/tree/main/src/components/Images"
    click ReusableUI "https://github.com/ischerba32/innowise-lab-internship-level-2-mini-paint/tree/main/src/components/UI"
    click ReduxStore "https://github.com/ischerba32/innowise-lab-internship-level-2-mini-paint/blob/main/src/redux/store.ts"
    click Slices "https://github.com/ischerba32/innowise-lab-internship-level-2-mini-paint/tree/main/src/redux/slices"
    click ImagesSaga "https://github.com/ischerba32/innowise-lab-internship-level-2-mini-paint/tree/main/src/redux/sagas/imagesSaga"
    click UserSaga "https://github.com/ischerba32/innowise-lab-internship-level-2-mini-paint/tree/main/src/redux/sagas/userSaga"
    click Firebase "https://github.com/ischerba32/innowise-lab-internship-level-2-mini-paint/blob/main/src/config/firebase.ts"
    click CustomHooks "https://github.com/ischerba32/innowise-lab-internship-level-2-mini-paint/tree/main/src/hooks"
    click Helpers "https://github.com/ischerba32/innowise-lab-internship-level-2-mini-paint/tree/main/src/helpers"
```
