# ashutosh-live/food-analyzer-fe architecture

> Architecture diagram of the GitHub repository ashutosh-live/food-analyzer-fe, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-02-11). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ashutosh-live/food-analyzer-fe
- Repository: https://github.com/ashutosh-live/food-analyzer-fe

## Overview

##### Project Type and Purpose
- This is a single-page React/TypeScript front-end (SPA).
- It uses Redux Toolkit for state management, SCSS for styling, Webpack for bundling, and Docker+Nginx for containerized deployment.
- It communicates with one or more external RESTful back-end services (auth, additive, plant, report, etc.).

##### File Structure
- src/ – React application code
– components/ – UI components organized by feature (Additive, Plant, User, Reports, etc.)
– services/ – HTTP clients for each API endpoint
– slices/ – Redux slices (state + reducers + async thunks)
– store.ts – Redux store configuration
– assets/, styles/, utils/ – static assets, theming, helpers
- webpack/ – build configurations (common/dev/prod)
- nginx/ – nginx.conf to serve static files
- Dockerfile – builds the production container image

##### Extract Key Insights from README
- Built and run via Docker:
docker build … && docker run … –p 3000:80
- No back-end code here – calls external APIs.

##### Main Components
a. Browser (User Agent)
– React App entry point (index.tsx → App.tsx)
– UI Components (feature modules: Additive, Plant, User, Lab Validation, Reports)
– Global Store (Redux)
– Service Layer (API clients in src/services)
b. Static Asset Server
– Nginx (Docker container) serving compiled bundle + assets
c. External Back-end Services
– Auth API
– Additive API
– Plant API
– Report API
– Lab-validation API
d. Build Pipeline (optional)
– Webpack (bundler)
– Docker (containerization)

##### Relationships & Data Flows
- User clicks UI → React component dispatches Redux action
- Middleware / Thunks invoke service layer → HTTP request to external API → JSON response
- Response flows back through Redux reducers → updated state → re-render UI
- Static assets (fonts, templates, images) are loaded from the Nginx-served file system

##### Architectural Patterns & Design Principles
- Component-based UI (React)
- Unidirectional data flow (Redux/Flux pattern)
- Separation of concerns:
– Presentation (components) vs. State (slices/store) vs. Data Access (services)
- Containerized deployment (Docker + Nginx)

- “Components (src/components)”
- “Redux Store (src/store.ts + src/slices)”
- “Services (src/services)”
– Connect React SPA ←–– Static files (bundle.js, assets) ←–– Nginx
– Auth API
– Additive API
– Plant API
– Report API
– Lab-Validation API
4. Optionally, annotate the “Build Pipeline”:
– Webpack → bundle → Dockerfile → Docker Image → Nginx Container

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Browser / React SPA"
        direction TB
        entry["src/index.tsx"]:::entry
        App["src/App.tsx"]:::ui
        subgraph "Components"
            direction TB
            AddComp["UI Components"]:::ui
        end
        subgraph "Redux Store"
            direction TB
            storeFile["store.ts"]:::state
            slices["Slices (src/slices/)"]:::state
        end
        services["Service Layer"]:::service
    end

    nginx["Nginx Server (Docker)"]:::infra

    subgraph "External APIs"
        direction TB
        authAPI["Auth API"]:::external
        additiveAPI["Additive API"]:::external
        plantAPI["Plant API"]:::external
        reportAPI["Report API"]:::external
        labAPI["Lab-Validation API"]:::external
    end

    entry -->|"renders"| App
    App -->|"renders UI"| AddComp
    AddComp -->|"dispatch action"| storeFile
    storeFile --> slices
    slices -->|"thunks call"| services
    services -->|"HTTP"| authAPI
    services -->|"HTTP"| additiveAPI
    services -->|"HTTP"| plantAPI
    services -->|"HTTP"| reportAPI
    services -->|"HTTP"| labAPI
    nginx -->|"serves bundle & assets"| entry

    click entry "https://github.com/ashutosh-live/food-analyzer-fe/blob/TGLC-203/src/index.tsx"
    click App "https://github.com/ashutosh-live/food-analyzer-fe/blob/TGLC-203/src/App.tsx"
    click AddComp "https://github.com/ashutosh-live/food-analyzer-fe/tree/TGLC-203/src/components/"
    click storeFile "https://github.com/ashutosh-live/food-analyzer-fe/blob/TGLC-203/src/store.ts"
    click slices "https://github.com/ashutosh-live/food-analyzer-fe/tree/TGLC-203/src/slices/"
    click services "https://github.com/ashutosh-live/food-analyzer-fe/tree/TGLC-203/src/services/"

    classDef ui fill:#add8e6,stroke:#333,stroke-width:1px
    classDef state fill:#98fb98,stroke:#333,stroke-width:1px
    classDef service fill:#ffff99,stroke:#333,stroke-width:1px
    classDef external fill:#d3d3d3,stroke:#333,stroke-width:1px
    classDef infra fill:#ffa500,stroke:#333,stroke-width:1px
    classDef entry fill:#ffa500,stroke:#333,stroke-width:1px
```
