# ken-jeong/ds-word-counter architecture

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

- Interactive diagram: https://gitdiagram.com/ken-jeong/ds-word-counter
- Repository: https://github.com/ken-jeong/ds-word-counter

## Overview

This repository is a C command-line word-frequency counter. Its main workflow validates a requested word and positive frequency, reads and counts whitespace-separated tokens, then prints totals and sorted summaries plus matching-word and matching-frequency results. The counter uses uthash for accumulation and word lookup; qsort and a linear scan support the two reporting views. The benchmark program is a separate research artifact, not part of the user-facing runtime workflow. Runtime relationships are based on wordCount.c and the README’s design description.

Main entry points: [`wordCount.c`](https://github.com/ken-jeong/ds-word-counter/blob/main/wordCount.c) (Argument Validation), [`uthash.h`](https://github.com/ken-jeong/ds-word-counter/blob/main/uthash.h) (Hash Table), [`words/tom-word-list.txt`](https://github.com/ken-jeong/ds-word-counter/blob/main/words/tom-word-list.txt) (Word List)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_input["Input Handling"]
  node_arguments["Argument Validation<br/>[wordCount.c]"]
  node_wordfile["Word List<br/>[tom-word-list.txt]"]
end

subgraph group_counting["Frequency Counting"]
  node_token_count["Token Counting<br/>[wordCount.c]"]
  node_hash["Hash Table<br/>[uthash.h]"]
end

subgraph group_reporting["Reports And Search"]
  node_summary["Count Summary<br/>[wordCount.c]"]
  node_word_view["Word-Sorted View<br/>[wordCount.c]"]
  node_word_lookup["Word Lookup<br/>[wordCount.c]"]
  node_frequency_view["Frequency-Sorted View<br/>[wordCount.c]"]
  node_frequency_lookup["Frequency Lookup<br/>[wordCount.c]"]
end

node_user(("CLI User"))
node_terminal(("Terminal Output"))

node_user -->|"provides arguments"| node_arguments
node_arguments -->|"selects input"| node_wordfile
node_wordfile -->|"supplies tokens"| node_token_count
node_token_count -->|"finds and adds"| node_hash
node_token_count -->|"reports totals"| node_summary
node_hash -->|"copies entries"| node_word_view
node_arguments -->|"provides search word"| node_word_lookup
node_word_lookup -->|"finds word"| node_hash
node_hash -->|"provides entries"| node_frequency_view
node_arguments -->|"provides target frequency"| node_frequency_lookup
node_frequency_view -->|"scans sorted entries"| node_frequency_lookup
node_summary -->|"prints totals"| node_terminal
node_word_view -->|"prints report"| node_terminal
node_word_lookup -->|"prints match"| node_terminal
node_frequency_view -->|"prints report"| node_terminal
node_frequency_lookup -->|"prints matches"| node_terminal

click node_arguments "https://github.com/ken-jeong/ds-word-counter/blob/main/wordCount.c"
click node_wordfile "https://github.com/ken-jeong/ds-word-counter/blob/main/words/tom-word-list.txt"
click node_token_count "https://github.com/ken-jeong/ds-word-counter/blob/main/wordCount.c"
click node_hash "https://github.com/ken-jeong/ds-word-counter/blob/main/uthash.h"
click node_summary "https://github.com/ken-jeong/ds-word-counter/blob/main/wordCount.c"
click node_word_view "https://github.com/ken-jeong/ds-word-counter/blob/main/wordCount.c"
click node_word_lookup "https://github.com/ken-jeong/ds-word-counter/blob/main/wordCount.c"
click node_frequency_view "https://github.com/ken-jeong/ds-word-counter/blob/main/wordCount.c"
click node_frequency_lookup "https://github.com/ken-jeong/ds-word-counter/blob/main/wordCount.c"

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_arguments,node_wordfile,node_user toneBlue
class node_token_count,node_hash toneAmber
class node_summary,node_word_view,node_word_lookup,node_frequency_view,node_frequency_lookup toneMint
class node_terminal toneIndigo
```

## Components

### Input Handling

- [Argument Validation](https://github.com/ken-jeong/ds-word-counter/blob/main/wordCount.c): `wordCount.c`
- [Word List](https://github.com/ken-jeong/ds-word-counter/blob/main/words/tom-word-list.txt): `words/tom-word-list.txt`

### Frequency Counting

- [Token Counting](https://github.com/ken-jeong/ds-word-counter/blob/main/wordCount.c): `wordCount.c`
- [Hash Table](https://github.com/ken-jeong/ds-word-counter/blob/main/uthash.h): `uthash.h`

### Reports And Search

- [Count Summary](https://github.com/ken-jeong/ds-word-counter/blob/main/wordCount.c): `wordCount.c`
- [Word-Sorted View](https://github.com/ken-jeong/ds-word-counter/blob/main/wordCount.c): `wordCount.c`
- [Word Lookup](https://github.com/ken-jeong/ds-word-counter/blob/main/wordCount.c): `wordCount.c`
- [Frequency-Sorted View](https://github.com/ken-jeong/ds-word-counter/blob/main/wordCount.c): `wordCount.c`
- [Frequency Lookup](https://github.com/ken-jeong/ds-word-counter/blob/main/wordCount.c): `wordCount.c`

### Other components

- **CLI User**
- **Terminal Output**

## Connections

- CLI User → Argument Validation: provides arguments (evidence: `wordCount.c`)
- Argument Validation → Word List: selects input (evidence: `wordCount.c`)
- Word List → Token Counting: supplies tokens (evidence: `wordCount.c`)
- Token Counting → Hash Table: finds and adds (evidence: `wordCount.c`)
- Token Counting → Count Summary: reports totals (evidence: `wordCount.c`)
- Hash Table → Word-Sorted View: copies entries (evidence: `wordCount.c`)
- Argument Validation → Word Lookup: provides search word (evidence: `wordCount.c`)
- Word Lookup → Hash Table: finds word (evidence: `wordCount.c`)
- Hash Table → Frequency-Sorted View: provides entries (evidence: `wordCount.c`)
- Argument Validation → Frequency Lookup: provides target frequency (evidence: `wordCount.c`)
- Frequency-Sorted View → Frequency Lookup: scans sorted entries (evidence: `wordCount.c`)
- Count Summary → Terminal Output: prints totals (evidence: `wordCount.c`)
- Word-Sorted View → Terminal Output: prints report (evidence: `wordCount.c`)
- Word Lookup → Terminal Output: prints match (evidence: `wordCount.c`)
- Frequency-Sorted View → Terminal Output: prints report (evidence: `wordCount.c`)
- Frequency Lookup → Terminal Output: prints matches (evidence: `wordCount.c`)
