# 0xanon0602/feed-flow-frontend architecture

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

- Interactive diagram: https://gitdiagram.com/0xanon0602/feed-flow-frontend
- Repository: https://github.com/0xanon0602/feed-flow-frontend

## Overview

##### Main Components
- UI Layer – Focus on the React components:
- Core components like App.js, Navbar, FlowDiagram, and PredictionForm.
- Popups such as ArrayReactorPopup, FeedWaterDataPopup, ConcentrateDataPopup, FlowRatesPopup, and ProductDataPopup.
- State Management – The Redux store, including slices (reactorSlice, flowRatesSlice, feedWaterSlice, productSlice, concentrateSlice) is central to data sharing across components.
- Service Layer – The API service (src/services/api.js) that abstracts communication with external data sources.
- Public Assets – The public folder (index.html) is where the initial HTML structure is provided.

##### Relationships and Interactions
- The App component acts as the container from which child components (Navbar, FlowDiagram, PredictionForm, and various popups) are rendered.
- Each UI component communicates with the Redux store. For instance, interactions within a popup or the prediction form result in updates to specific slices in the store.
- The Redux slices form the core data model, managing state for different domains (reactor, feed water, flow rates, product, and concentrate data).
- The API service is used by components (directly or via Redux middleware/thunks/sagas, if implemented) to fetch or send data to an external system.
- From UI Components to Redux Store (state dispatches, subscriptions).
- From Redux or Components to the API service, denoting external data calls.

##### Architectural Patterns & Design Principles
- Component-Based Architecture – Each React component (and popup) is self-contained, with its corresponding CSS, ensuring modularity.
- Redux Pattern – Clearly separates application state management from UI rendering.
- Separation of Concerns – Divide the system into presentation (components), state management (Redux), and external data interactions (API services).

Patterns visually (e.g., grouping components under “UI Layer”, grouping Redux slices together as “State Management”, etc.).

##### Technologies and Frameworks
- React – for the component-based UI.
- Create React App (CRA) infrastructure – note that the build, development, and ejection processes are standardized.
- CSS – used for styling each component, indicated by the dedicated CSS files.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Public Assets
    subgraph "Public Assets"
        INDEX["index.html (Entry HTML)"]:::public
    end

    %% UI Layer
    subgraph "UI Layer"
        APP["App Component"]:::ui
        NAV["Navbar Component"]:::ui
        FLOW["FlowDiagram Component"]:::ui
        PRED["PredictionForm Component"]:::ui
        ARRPOP["ArrayReactorPopup"]:::ui
        CONPOP["ConcentrateDataPopup"]:::ui
        FWPPOP["FeedWaterDataPopup"]:::ui
        FRPOP["FlowRatesPopup"]:::ui
        PRODPOP["ProductDataPopup"]:::ui
        CSS["CSS Styles"]:::css
    end

    %% State Management
    subgraph "State Management"
        STORE["Redux Store"]:::redux
        REACTOR["Reactor Slice"]:::redux
        FLOWRATES["Flow Rates Slice"]:::redux
        FEEDWATER["Feed Water Slice"]:::redux
        PRODUCT["Product Slice"]:::redux
        CONCENTRATE["Concentrate Slice"]:::redux
    end

    %% Service Layer
    subgraph "Service Layer"
        API["API Service"]:::service
    end

    %% Connections from Public Assets to UI Layer
    INDEX -->|"loads"| APP

    %% UI Components rendering
    APP -->|"renders"| NAV
    APP -->|"renders"| FLOW
    APP -->|"renders"| PRED
    APP -->|"renders"| ARRPOP
    APP -->|"renders"| CONPOP
    APP -->|"renders"| FWPPOP
    APP -->|"renders"| FRPOP
    APP -->|"renders"| PRODPOP

    %% UI Components dispatch actions to Redux Store
    NAV -->|"updates_state"| STORE
    FLOW -->|"updates_state"| STORE
    PRED -->|"dispatches"| STORE
    ARRPOP -->|"dispatches"| STORE
    CONPOP -->|"dispatches"| STORE
    FWPPOP -->|"dispatches"| STORE
    FRPOP -->|"dispatches"| STORE
    PRODPOP -->|"dispatches"| STORE

    %% Redux Store contains individual slices
    STORE --> REACTOR
    STORE --> FLOWRATES
    STORE --> FEEDWATER
    STORE --> PRODUCT
    STORE --> CONCENTRATE

    %% Redux interacts with the API Service
    STORE -->|"calls_API"| API
    API -->|"returns_data"| STORE

    %% Styling connections
    CSS ---|"styles"| APP
    CSS ---|"styles"| NAV
    CSS ---|"styles"| FLOW
    CSS ---|"styles"| PRED
    CSS ---|"styles"| ARRPOP
    CSS ---|"styles"| CONPOP
    CSS ---|"styles"| FWPPOP
    CSS ---|"styles"| FRPOP
    CSS ---|"styles"| PRODPOP

    %% Click Events
    click APP "https://github.com/0xanon0602/feed-flow-frontend/blob/main/src/App.js"
    click NAV "https://github.com/0xanon0602/feed-flow-frontend/blob/main/src/components/Navbar.js"
    click FLOW "https://github.com/0xanon0602/feed-flow-frontend/blob/main/src/components/FlowDiagram.js"
    click PRED "https://github.com/0xanon0602/feed-flow-frontend/blob/main/src/components/PredictionForm.js"
    click ARRPOP "https://github.com/0xanon0602/feed-flow-frontend/blob/main/src/components/popups/ArrayReactorPopup.js"
    click CONPOP "https://github.com/0xanon0602/feed-flow-frontend/blob/main/src/components/popups/ConcentrateDataPopup.js"
    click FWPPOP "https://github.com/0xanon0602/feed-flow-frontend/blob/main/src/components/popups/FeedWaterDataPopup.js"
    click FRPOP "https://github.com/0xanon0602/feed-flow-frontend/blob/main/src/components/popups/FlowRatesPopup.js"
    click PRODPOP "https://github.com/0xanon0602/feed-flow-frontend/blob/main/src/components/popups/ProductDataPopup.js"
    click CSS "https://github.com/0xanon0602/feed-flow-frontend/tree/main/src/css"
    click STORE "https://github.com/0xanon0602/feed-flow-frontend/blob/main/src/redux/store.js"
    click REACTOR "https://github.com/0xanon0602/feed-flow-frontend/blob/main/src/redux/slices/reactorSlice.js"
    click FLOWRATES "https://github.com/0xanon0602/feed-flow-frontend/blob/main/src/redux/slices/flowRatesSlice.js"
    click FEEDWATER "https://github.com/0xanon0602/feed-flow-frontend/blob/main/src/redux/slices/feedWaterSlice.js"
    click PRODUCT "https://github.com/0xanon0602/feed-flow-frontend/blob/main/src/redux/slices/productSlice.js"
    click CONCENTRATE "https://github.com/0xanon0602/feed-flow-frontend/blob/main/src/redux/slices/concentrateSlice.js"
    click API "https://github.com/0xanon0602/feed-flow-frontend/blob/main/src/services/api.js"
    click INDEX "https://github.com/0xanon0602/feed-flow-frontend/blob/main/public/index.html"

    %% Style Definitions
    classDef ui fill:#cce5ff,stroke:#004085,stroke-width:2px;
    classDef redux fill:#d4edda,stroke:#155724,stroke-width:2px;
    classDef service fill:#fff3cd,stroke:#856404,stroke-width:2px;
    classDef public fill:#f8d7da,stroke:#721c24,stroke-width:2px;
    classDef css fill:#e2e3e5,stroke:#383d41,stroke-width:2px;
```
