# kurniawan26/character-counter architecture

> Architecture diagram of the GitHub repository kurniawan26/character-counter, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-11-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/kurniawan26/character-counter
- Repository: https://github.com/kurniawan26/character-counter

## Overview

##### Project type and purpose
- This is a single-page React application (built with Vite) that implements a “character counter” UI challenge.
- Users type or paste text into an editor, and the app displays: character/word/sentence counts (with or without spaces), letter-density analysis, reading time estimate, and theme selection.

##### File structure
- Top-level files:
- index.html – the HTML shell for the SPA
- vite.config.js – Vite build/dev configuration
- eslint.config.js, package.json/lock – linters and dependencies
- public/ – static assets (fonts, images) served as-is
- src/ – application source code:
- main.jsx – React entry point hooking into index.html
- App.jsx & App.hook.jsx – root component and custom hook for state/logic
- components/ – presentational and container components (AppBar, TextArea, CardInformation, LetterDensity)
- utils/index.js – pure functions computing counts, densities, reading time
- styles/index.css – global / Tailwind CSS imports

##### README for additional insights
- Confirms use of React + Tailwind CSS
- Mobile-first, semantic HTML, Flexbox/CSS Grid
- Emphasis on UX states (hover, focus) and theme toggling

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Browser Layer
    subgraph "Browser"
        Browser(("User Browser")):::user
    end

    %% Build & Serve Layer
    subgraph "Build & Serve"
        Vite["Vite (Dev/Build)"]:::tool
        IndexHTML["index.html"]:::asset
        ESLint["eslint.config.js"]:::tool
        Vite -->|bundles| IndexHTML
        Browser -->|requests| IndexHTML
    end

    %% Client-side App Layer
    subgraph "Client-side App"
        ReactEntry["main.jsx (React Entry)"]:::react
        ReactRuntime["React Runtime / Virtual DOM"]:::react
        ReactEntry -->|mounts| ReactRuntime

        %% Root and Hook
        App["App.jsx (Root Component)"]:::react
        Hook["App.hook.jsx (useAppState)"]:::react
        ReactRuntime --> App
        App --> Hook

        %% Presentational Components
        AppBar["AppBar.jsx (Theme Selector)"]:::react
        TextArea["TextArea.jsx (Text Input & Limit Toggle)"]:::react
        CardInfo["CardInformation.jsx (Counts & Reading Time)"]:::react
        LetterDensity["LetterDensity.jsx (Letter Frequency Chart)"]:::react

        App --> AppBar
        App --> TextArea
        App --> CardInfo
        App --> LetterDensity

        %% Data Flow & Events
        TextArea -- "user input" --> Hook
        Hook -- "state update" --> CardInfo
        Hook -- "state update" --> LetterDensity
        AppBar -.->|"toggle theme"| App

    end

    %% Utilities Layer
    subgraph "Utilities"
        Utils["utils/index.js (Text Analysis)"]:::utility
        Hook -->|calls| Utils
        CardInfo -->|uses| Utils
        LetterDensity -->|uses| Utils
    end

    %% Static Assets Layer
    subgraph "Static Assets"
        Assets["public/assets"]:::asset
        IndexHTML -->|loads| Assets
    end

    %% Connections
    Browser --> Vite

    %% Click Events
    click IndexHTML "https://github.com/kurniawan26/character-counter/blob/master/index.html"
    click Vite "https://github.com/kurniawan26/character-counter/blob/master/vite.config.js"
    click ESLint "https://github.com/kurniawan26/character-counter/blob/master/eslint.config.js"
    click ReactEntry "https://github.com/kurniawan26/character-counter/blob/master/src/main.jsx"
    click App "https://github.com/kurniawan26/character-counter/blob/master/src/App.jsx"
    click Hook "https://github.com/kurniawan26/character-counter/blob/master/src/App.hook.jsx"
    click AppBar "https://github.com/kurniawan26/character-counter/blob/master/src/components/AppBar.jsx"
    click TextArea "https://github.com/kurniawan26/character-counter/blob/master/src/components/TextArea.jsx"
    click CardInfo "https://github.com/kurniawan26/character-counter/blob/master/src/components/CardInformation.jsx"
    click LetterDensity "https://github.com/kurniawan26/character-counter/blob/master/src/components/LetterDensity.jsx"
    click Utils "https://github.com/kurniawan26/character-counter/blob/master/src/utils/index.js"
    click Assets "https://github.com/kurniawan26/character-counter/tree/master/public/assets"

    %% Styles
    classDef react fill:#cce5ff,stroke:#6699cc
    classDef utility fill:#d4edda,stroke:#43a047
    classDef asset fill:#e0e0e0,stroke:#9e9e9e
    classDef tool fill:#f3e5f5,stroke:#ab47bc
    classDef user fill:#ffe0b2,stroke:#fb8c00
```
