# ashutosh-live/charaka-fe-new architecture

> Architecture diagram of the GitHub repository ashutosh-live/charaka-fe-new, 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/charaka-fe-new
- Repository: https://github.com/ashutosh-live/charaka-fe-new

## Overview

##### Project Type and Purpose
- This is a single‐page front-end application built with React (TypeScript), Redux (Redux Toolkit slices), Webpack, and styled via SCSS/CSS.
- It’s packaged in Docker and served via Nginx. It “speaks” to one or more back-end APIs (authentication, product management, chats, OCR, etc.).

##### Top-Level Architectural Components
a. Container:
- Nginx (Docker container) – serves static assets and handles routing/fallback.
- React App – the compiled JS/CSS bundle.
b. Client-Side Modules:
- Pages (src/Pages) – route–based containers (Auth, Dashboard, Product, Plant, Additives, Chat, NotFound).
- Components (src/components) – reusable UI (Dialogs, Toaster, Chat modules, Swipers, Layout, Webcam, etc.).
- State Management (src/slices + src/store.ts) – Redux slices for auth, products, plants, additives, chat, dashboard, UI alerts/animations, etc.
- Services (src/services) – API abstractions per domain (auth.ts, product.ts, additives.ts, plants.ts, chat, OCR, etc.) built on a requestBuilder.
- Helpers & Utilities (src/helper, src/utils) – common functions (navigation, OCR handling, encryption, tag inputs, validation).
- Styling & Assets – SCSS partials (src/styles), CSS overrides (src/assets/css), images (src/assets/images).

##### Interactions & Data Flow
- User’s browser requests `index.html` → Nginx serves built React app.
- React Router directs to a Page component → Page mounts child Components.
- UI Components dispatch Redux actions → slices trigger async thunks which call Services.
- Services use requestBuilder → send HTTP/HTTPS requests to external backend APIs (Auth API, Product API, Plant API, Chat Server, OCR service).
- Responses update Redux store → UI re-renders.
- Real-time chat: potentially WebSocket or long-polling via Chat service.

##### Architectural Patterns & Principles
- Component Hierarchy: Page containers orchestrate child components; presentational vs. container separation.
- State centralization in Redux (single store, feature slices).
- API service layer abstracts HTTP details.
- SCSS modularity via partials (`_components.scss`, `_index.scss`).
- Build-time configuration: Webpack for dev/prod, Babel for TS/JX, ESLint/Prettier for code quality.
- Containerization best practices: Dockerfile for multi-stage builds, Nginx config for hosting.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% User and Hosting
    Browser["User Browser"]:::user
    Nginx["Nginx Container"]:::container
    ReactApp["React Application\n(React + TypeScript)"]:::frontend

    Browser -->|"GET index.html"| Nginx
    Nginx -->|"serves static assets"| ReactApp

    %% React App Structure
    subgraph "React Application"
        direction TB
        HTML["HTML Template"]:::frontend
        Entry["App Entry Point"]:::frontend
        AppComp["Root App Component"]:::frontend

        subgraph "Pages (Route Containers)" 
            direction TB
            PagesDir["src/Pages"]:::frontend
        end

        subgraph "Components (UI)" 
            direction TB
            ComponentsDir["src/components"]:::frontend
        end

        subgraph "State Management" 
            direction TB
            StoreInit["Store Initialization"]:::state
            Slices["Feature Slices"]:::state
        end

        subgraph "Services (API Layer)" 
            direction TB
            DomainSvc["Domain Services"]:::service
            ReqBuilder["Request Builder"]:::service
        end

        subgraph "Helpers & Utilities"
            direction TB
            Helpers["src/helper"]:::helper
            Utils["src/utils"]:::helper
        end

        subgraph "Styling & Assets"
            direction TB
            Styles["SCSS Partials"]:::asset
            CSSOverrides["CSS Overrides"]:::asset
            Images["Images Index"]:::asset
        end

        HTML --> Entry
        Entry --> AppComp
        AppComp --> PagesDir
        AppComp --> ComponentsDir
        ComponentsDir --> StoreInit
        Slices --> ComponentsDir
        ComponentsDir -->|"dispatch/select"| StoreInit
        StoreInit -->|"async thunks"| DomainSvc
        DomainSvc --> ReqBuilder
        ReqBuilder -->|"HTTP/HTTPS"| ExternalAPIs
    end

    %% External Services
    subgraph "External Back-end APIs / Services"
        direction TB
        AuthAPI["Auth API"]:::external
        ProductAPI["Product API"]:::external
        PlantAPI["Plant API"]:::external
        AdditivesAPI["Additives API"]:::external
        ChatServer["Chat Server"]:::external
        OCRService["OCR Service"]:::external
    end

    ExternalAPIs["External APIs Gateway"]:::external
    ExternalAPIs --> AuthAPI
    ExternalAPIs --> ProductAPI
    ExternalAPIs --> PlantAPI
    ExternalAPIs --> AdditivesAPI
    ExternalAPIs --> ChatServer
    ExternalAPIs --> OCRService

    %% Real-time Chat
    ChatComp["Chat Components"]:::frontend
    ChatComp -->|"WebSocket"| ChatServer
    ComponentsDir --> ChatComp

    %% Build & Deployment
    subgraph "Build & Deployment"
        direction TB
        DockerfileNode["Docker Multi-stage Build"]:::config
        NginxConf["Nginx Configuration"]:::config
        WebpackCfg["Webpack Configs"]:::config
        TSConfig["TypeScript Config"]:::config
        BabelCfg["Babel Config"]:::config
        ESLintCfg["ESLint Config"]:::config
        PrettierCfg["Prettier Config"]:::config
        EnvSample["Environment Sample"]:::config
        GitIgnore[".gitignore"]:::config
    end

    DockerfileNode --> NginxConf
    DockerfileNode --> WebpackCfg

    %% Click Events
    click NginxConf "https://github.com/ashutosh-live/charaka-fe-new/blob/main/nginx/nginx.conf"
    click DockerfileNode "https://github.com/ashutosh-live/charaka-fe-new/tree/main/Dockerfile"
    click Entry "https://github.com/ashutosh-live/charaka-fe-new/blob/main/src/index.tsx"
    click HTML "https://github.com/ashutosh-live/charaka-fe-new/blob/main/src/index.html"
    click AppComp "https://github.com/ashutosh-live/charaka-fe-new/blob/main/src/App.tsx"
    click PagesDir "https://github.com/ashutosh-live/charaka-fe-new/tree/main/src/Pages"
    click ComponentsDir "https://github.com/ashutosh-live/charaka-fe-new/tree/main/src/components"
    click StoreInit "https://github.com/ashutosh-live/charaka-fe-new/blob/main/src/store.ts"
    click Slices "https://github.com/ashutosh-live/charaka-fe-new/tree/main/src/slices"
    click DomainSvc "https://github.com/ashutosh-live/charaka-fe-new/tree/main/src/services"
    click ReqBuilder "https://github.com/ashutosh-live/charaka-fe-new/blob/main/src/services/api/requestBuilder.ts"
    click Helpers "https://github.com/ashutosh-live/charaka-fe-new/tree/main/src/helper"
    click Utils "https://github.com/ashutosh-live/charaka-fe-new/tree/main/src/utils"
    click Styles "https://github.com/ashutosh-live/charaka-fe-new/tree/main/src/styles"
    click CSSOverrides "https://github.com/ashutosh-live/charaka-fe-new/tree/main/src/assets/css"
    click Images "https://github.com/ashutosh-live/charaka-fe-new/blob/main/src/assets/images/index.ts"
    click WebpackCfg "https://github.com/ashutosh-live/charaka-fe-new/blob/main/webpack/webpack.common.js"
    click TSConfig "https://github.com/ashutosh-live/charaka-fe-new/blob/main/tsconfig.json"
    click BabelCfg "https://github.com/ashutosh-live/charaka-fe-new/blob/main/.babelrc"
    click ESLintCfg "https://github.com/ashutosh-live/charaka-fe-new/blob/main/.eslintrc.js"
    click PrettierCfg "https://github.com/ashutosh-live/charaka-fe-new/blob/main/.prettierrc.js"
    click EnvSample "https://github.com/ashutosh-live/charaka-fe-new/blob/main/.env-sample"
    click GitIgnore "https://github.com/ashutosh-live/charaka-fe-new/blob/main/.gitignore"

    %% Styles
    classDef user fill:#fef2c0,stroke:#eab308,color:#000
    classDef container fill:#d1fae5,stroke:#10b981,color:#000
    classDef frontend fill:#dbeafe,stroke:#3b82f6,color:#000
    classDef state fill:#fde68a,stroke:#f59e0b,color:#000
    classDef service fill:#fbcfe8,stroke:#ec4899,color:#000
    classDef helper fill:#e0f2fe,stroke:#0284c7,color:#000
    classDef asset fill:#f0fdf4,stroke:#22c55e,color:#000
    classDef external fill:#fee2e2,stroke:#ef4444,color:#000
    classDef config fill:#eaeaea,stroke:#6b7280,color:#000
```
