# sammie-oje/character-counter architecture

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

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

## Overview

1. This repository is a small client-side React application built with Vite. It has no backend, database, or API layer in the tree shown. The whole architecture is a single-page UI that runs in the browser.

2. The runtime entry point is `src/main.jsx`, which mounts `src/App.jsx` into the HTML shell in `index.html`. `App.jsx` is the top-level composition layer that wires together the app’s header, text input area, copy action, and analytics panels.

3. The core product boundary is a text-analysis workspace. Users type or paste content into the text area, and the app immediately derives statistics from that input. The user input is the single primary data source flowing through the system.

4. The input subsystem is split into reusable UI pieces under `src/components/TextArea/`: `TextArea.jsx`, `TextInput.jsx`, and `TextOptions.jsx`. This suggests a separation between the raw editor surface, input handling, and configuration controls such as formatting or counting modes.

5. The metrics subsystem lives under `src/components/metrics/`. `Container.jsx` and `Stat.jsx` appear to provide layout and repeated stat-card rendering, while `letter-list/` contains specialized UI for letter-density analysis, including `DensityList.jsx`, `LetterDensity.jsx`, and `ToggleList.jsx`. This indicates the app presents both summary metrics and a drill-down view for character frequency.

6. The computation layer is isolated in `src/utils/`. It includes focused pure functions for `character-count`, `character-limit`, `exclude-spaces`, `word-count`, `sentence-count`, `reading-time`, `segmenter`, and `letter-density`. This is the main architectural boundary separating UI rendering from text-processing logic.

7. Data flow is likely: user input enters the text area, utility functions compute derived values, and those values are rendered in metric components. This makes the app a one-way transformation pipeline from text to statistics, with no server round-trip.

8. Clipboard behavior is encapsulated separately in `src/utils/copyToClipboard.js` and surfaced through `src/components/CopyText.jsx`. That implies export/share is a client-only action and not part of the main text-analysis flow.

9. `src/components/Header.jsx` and `src/components/MaximizeInput.jsx` suggest secondary UX concerns: branding/navigation at the top and a larger editor mode for focusing on input. These are presentation-layer features rather than core computation.

10. Static assets are bundled in `public/assets/`, including fonts (`DM_Sans`) and images. This means the app has a custom visual identity but still remains a fully static frontend deployment.

11. Tooling-wise, the repo is a standard Vite React setup with ESLint. There is no evidence of state management libraries, routing, or server-side rendering, so the architecture is intentionally lightweight and component-driven.

12. If you were drawing the architecture, the main boxes would be: browser shell → React app root → text input/editor → pure text-analysis utilities → metrics and density views, plus a separate clipboard action path. The key boundary is between interactive UI state and pure text-processing functions.

Main entry points: [`src/App.jsx`](https://github.com/sammie-oje/character-counter/blob/main/src/App.jsx) (App), [`src/components/TextArea/TextInput.jsx`](https://github.com/sammie-oje/character-counter/blob/main/src/components/TextArea/TextInput.jsx) (Text input), [`src/components/TextArea/TextArea.jsx`](https://github.com/sammie-oje/character-counter/blob/main/src/components/TextArea/TextArea.jsx) (Text area), [`src/components/metrics/Container.jsx`](https://github.com/sammie-oje/character-counter/blob/main/src/components/metrics/Container.jsx) (Metrics)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_shell["Browser shell"]
  node_index_html["index.html<br/>html shell<br/>[index.html]"]
end

subgraph group_app["React app"]
  node_src_main(("main<br/>react entry<br/>[main.jsx]"))
  node_src_app["App<br/>composition root<br/>[App.jsx]"]
end

subgraph group_ui["Input UI"]
  node_src_header["Header<br/>[Header.jsx]"]
  node_src_textarea["Text area<br/>input workspace<br/>[TextArea.jsx]"]
  node_src_textinput["Text input<br/>editor input<br/>[TextInput.jsx]"]
  node_src_textoptions["Options<br/>input controls<br/>[TextOptions.jsx]"]
  node_src_maximize["Maximize<br/>focus mode<br/>[MaximizeInput.jsx]"]
  node_src_copytext["Copy text<br/>clipboard action<br/>[CopyText.jsx]"]
end

subgraph group_metrics["Metrics UI"]
  node_src_metrics_container["Metrics<br/>[Container.jsx]"]
  node_src_stat["Stat<br/>[Stat.jsx]"]
  node_src_densitylist["Density list<br/>density panel<br/>[DensityList.jsx]"]
  node_src_letterdensity["Letter density<br/>density row<br/>[LetterDensity.jsx]"]
  node_src_togglelist["Toggle list<br/>density controls<br/>[ToggleList.jsx]"]
end

subgraph group_utils["Text utils"]
  node_word_count(("Word count<br/>text metric<br/>[word-count.js]"))
  node_sentence_count(("Sentence count<br/>text metric<br/>[sentence-count.js]"))
  node_reading_time(("Reading time<br/>text metric<br/>[reading-time.js]"))
  node_character_count(("Character count<br/>text metric<br/>[character-count.js]"))
  node_letter_density(("Letter density<br/>analysis util<br/>[letter-density.js]"))
  node_copy_to_clipboard(("Clipboard<br/>[copyToClipboard.js]"))
end

subgraph group_assets["Static assets"]
  node_assets_fonts["Fonts<br/>static assets"]
  node_assets_images["Images<br/>static assets"]
end

node_index_html -->|"loads"| node_src_main
node_src_main -->|"mounts"| node_src_app
node_src_app -->|"composes"| node_src_header
node_src_app -->|"composes"| node_src_textarea
node_src_app -->|"composes"| node_src_copytext
node_src_app -->|"composes"| node_src_maximize
node_src_app -->|"composes"| node_src_metrics_container
node_src_textarea -->|"contains"| node_src_textinput
node_src_textarea -->|"contains"| node_src_textoptions
node_src_textinput -->|"feeds"| node_character_count
node_src_textinput -->|"feeds"| node_word_count
node_src_textinput -->|"feeds"| node_sentence_count
node_src_textinput -->|"feeds"| node_reading_time
node_src_textinput -->|"feeds"| node_letter_density
node_src_metrics_container -->|"renders"| node_src_stat
node_src_metrics_container -->|"renders"| node_src_densitylist
node_src_densitylist -->|"uses"| node_src_letterdensity
node_src_densitylist -->|"uses"| node_src_togglelist
node_src_copytext -->|"calls"| node_copy_to_clipboard
node_src_textoptions -.->|"adjusts"| node_character_count
node_src_maximize -.->|"expands"| node_src_textinput
node_src_app -.->|"uses"| node_assets_fonts
node_src_app -.->|"uses"| node_assets_images

click node_index_html "https://github.com/sammie-oje/character-counter/blob/main/index.html"
click node_src_main "https://github.com/sammie-oje/character-counter/blob/main/src/main.jsx"
click node_src_app "https://github.com/sammie-oje/character-counter/blob/main/src/App.jsx"
click node_src_header "https://github.com/sammie-oje/character-counter/blob/main/src/components/Header.jsx"
click node_src_textarea "https://github.com/sammie-oje/character-counter/blob/main/src/components/TextArea/TextArea.jsx"
click node_src_textinput "https://github.com/sammie-oje/character-counter/blob/main/src/components/TextArea/TextInput.jsx"
click node_src_textoptions "https://github.com/sammie-oje/character-counter/blob/main/src/components/TextArea/TextOptions.jsx"
click node_src_maximize "https://github.com/sammie-oje/character-counter/blob/main/src/components/MaximizeInput.jsx"
click node_src_copytext "https://github.com/sammie-oje/character-counter/blob/main/src/components/CopyText.jsx"
click node_src_metrics_container "https://github.com/sammie-oje/character-counter/blob/main/src/components/metrics/Container.jsx"
click node_src_stat "https://github.com/sammie-oje/character-counter/blob/main/src/components/metrics/Stat.jsx"
click node_src_densitylist "https://github.com/sammie-oje/character-counter/blob/main/src/components/metrics/letter-list/DensityList.jsx"
click node_src_letterdensity "https://github.com/sammie-oje/character-counter/blob/main/src/components/metrics/letter-list/LetterDensity.jsx"
click node_src_togglelist "https://github.com/sammie-oje/character-counter/blob/main/src/components/metrics/letter-list/ToggleList.jsx"
click node_word_count "https://github.com/sammie-oje/character-counter/blob/main/src/utils/word-count.js"
click node_sentence_count "https://github.com/sammie-oje/character-counter/blob/main/src/utils/sentence-count.js"
click node_reading_time "https://github.com/sammie-oje/character-counter/blob/main/src/utils/reading-time.js"
click node_character_count "https://github.com/sammie-oje/character-counter/blob/main/src/utils/character-count.js"
click node_letter_density "https://github.com/sammie-oje/character-counter/blob/main/src/utils/letter-density.js"
click node_copy_to_clipboard "https://github.com/sammie-oje/character-counter/blob/main/src/utils/copyToClipboard.js"
click node_assets_fonts "https://github.com/sammie-oje/character-counter/tree/main/public/assets/fonts"
click node_assets_images "https://github.com/sammie-oje/character-counter/tree/main/public/assets/images"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_index_html toneBlue
class node_src_main,node_src_app toneAmber
class node_src_header,node_src_textarea,node_src_textinput,node_src_textoptions,node_src_maximize,node_src_copytext toneMint
class node_src_metrics_container,node_src_stat,node_src_densitylist,node_src_letterdensity,node_src_togglelist toneRose
class node_word_count,node_sentence_count,node_reading_time,node_character_count,node_letter_density,node_copy_to_clipboard toneIndigo
class node_assets_fonts,node_assets_images toneTeal
```

## Components

### Browser shell

Static document and runtime bootstrap

- [index.html](https://github.com/sammie-oje/character-counter/blob/main/index.html): html shell · Browser document that loads the app · `index.html`

### React app

Top-level composition and page assembly

- [main](https://github.com/sammie-oje/character-counter/blob/main/src/main.jsx): react entry · Bootstraps React into the page · `src/main.jsx`
- [App](https://github.com/sammie-oje/character-counter/blob/main/src/App.jsx): composition root · Wires input, actions, and metrics · `src/App.jsx`

### Input UI

Text entry and secondary controls

- [Header](https://github.com/sammie-oje/character-counter/blob/main/src/components/Header.jsx): ui header · Top branding and page header · `src/components/Header.jsx`
- [Text area](https://github.com/sammie-oje/character-counter/blob/main/src/components/TextArea/TextArea.jsx): input workspace · Container for the text editor area · `src/components/TextArea/TextArea.jsx`
- [Text input](https://github.com/sammie-oje/character-counter/blob/main/src/components/TextArea/TextInput.jsx): editor input · Primary text entry surface · `src/components/TextArea/TextInput.jsx`
- [Options](https://github.com/sammie-oje/character-counter/blob/main/src/components/TextArea/TextOptions.jsx): input controls · Controls for input and counting modes · `src/components/TextArea/TextOptions.jsx`
- [Maximize](https://github.com/sammie-oje/character-counter/blob/main/src/components/MaximizeInput.jsx): focus mode · Expanded input viewing/editing mode · `src/components/MaximizeInput.jsx`
- [Copy text](https://github.com/sammie-oje/character-counter/blob/main/src/components/CopyText.jsx): clipboard action · Client-side copy/share action · `src/components/CopyText.jsx`

### Metrics UI

Summary stats and letter-density views

- [Metrics](https://github.com/sammie-oje/character-counter/blob/main/src/components/metrics/Container.jsx): metrics container · Layout wrapper for statistic panels · `src/components/metrics/Container.jsx`
- [Stat](https://github.com/sammie-oje/character-counter/blob/main/src/components/metrics/Stat.jsx): stat card · Reusable summary statistic tile · `src/components/metrics/Stat.jsx`
- [Density list](https://github.com/sammie-oje/character-counter/blob/main/src/components/metrics/letter-list/DensityList.jsx): density panel · Letter-density list and summary view · `src/components/metrics/letter-list/DensityList.jsx`
- [Letter density](https://github.com/sammie-oje/character-counter/blob/main/src/components/metrics/letter-list/LetterDensity.jsx): density row · Single character-density item · `src/components/metrics/letter-list/LetterDensity.jsx`
- [Toggle list](https://github.com/sammie-oje/character-counter/blob/main/src/components/metrics/letter-list/ToggleList.jsx): density controls · Show/hide controls for density details · `src/components/metrics/letter-list/ToggleList.jsx`

### Text utils

Pure text-processing and clipboard helpers

- [Word count](https://github.com/sammie-oje/character-counter/blob/main/src/utils/word-count.js): text metric · Counts words from the input text · `src/utils/word-count.js`
- [Sentence count](https://github.com/sammie-oje/character-counter/blob/main/src/utils/sentence-count.js): text metric · Counts sentences in the input text · `src/utils/sentence-count.js`
- [Reading time](https://github.com/sammie-oje/character-counter/blob/main/src/utils/reading-time.js): text metric · Estimates reading duration · `src/utils/reading-time.js`
- [Character count](https://github.com/sammie-oje/character-counter/blob/main/src/utils/character-count.js): text metric · Counts total characters · `src/utils/character-count.js`
- [Letter density](https://github.com/sammie-oje/character-counter/blob/main/src/utils/letter-density.js): analysis util · Computes character-frequency distribution · `src/utils/letter-density.js`
- [Clipboard](https://github.com/sammie-oje/character-counter/blob/main/src/utils/copyToClipboard.js): clipboard util · Low-level copy helper · `src/utils/copyToClipboard.js`

### Static assets

Fonts and imagery bundled with the app

- [Fonts](https://github.com/sammie-oje/character-counter/tree/main/public/assets/fonts): static assets · Bundled DM Sans font files · `public/assets/fonts`
- [Images](https://github.com/sammie-oje/character-counter/tree/main/public/assets/images): static assets · Bundled image assets · `public/assets/images`

## Connections

- index.html → main: loads · Document bootstraps the React entry point
- main → App: mounts · Entry point renders the app root
- App → Header: composes · App assembles the page header
- App → Text area: composes · App includes the input workspace
- App → Copy text: composes · App exposes the copy action
- App → Maximize: composes · App provides input focus mode
- App → Metrics: composes · App places the metrics area
- Text area → Text input: contains · Text area wraps the editor surface
- Text area → Options: contains · Text area wraps mode controls
- Text input → Character count: feeds · User text drives character statistics
- Text input → Word count: feeds · User text drives word statistics
- Text input → Sentence count: feeds · User text drives sentence statistics
- Text input → Reading time: feeds · User text drives reading-time estimates
- Text input → Letter density: feeds · User text drives frequency analysis
- Metrics → Stat: renders · Metrics wrapper hosts reusable stat cards
- Metrics → Density list: renders · Metrics wrapper hosts the density view
- Density list → Letter density: uses · Density panel renders individual density rows
- Density list → Toggle list: uses · Density panel includes visibility controls
- Copy text → Clipboard: calls · Copy UI delegates to clipboard helper
- Options → Character count: adjusts · Input options influence counting behavior
- Maximize → Text input: expands · Focus mode changes the editor presentation
- App → Fonts: uses · App styling depends on bundled fonts
- App → Images: uses · App styling depends on bundled imagery
