# serenbeam/ai-grammar-checker architecture

> Architecture diagram of the GitHub repository serenbeam/ai-grammar-checker, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-20). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/serenbeam/ai-grammar-checker
- Repository: https://github.com/serenbeam/ai-grammar-checker

## Overview

O’ Grammar Checker is a React Native app for AI grammar correction. The main flow is Check Screen → grammar hook → grammar service → OpenRouter API, with results held in the grammar store and successful checks added to history. History and Settings are separate product branches; the README documents persisted history and a settings interface. Several service and screen internals were not sampled, so uncertain persistence wiring is shown as unverified rather than asserted.

Main entry points: [`src/screens/Check/CheckScreen.tsx`](https://github.com/serenbeam/ai-grammar-checker/blob/main/src/screens/Check/CheckScreen.tsx) (Check Screen), [`src/navigation/BottomTabNavigator.tsx`](https://github.com/serenbeam/ai-grammar-checker/blob/main/src/navigation/BottomTabNavigator.tsx) (Bottom Tabs), [`src/hooks/useGrammar.ts`](https://github.com/serenbeam/ai-grammar-checker/blob/main/src/hooks/useGrammar.ts) (Grammar Hook), [`src/hooks/useHistory.ts`](https://github.com/serenbeam/ai-grammar-checker/blob/main/src/hooks/useHistory.ts) (History Hook)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["App and Navigation"]
  node_app_entry["App Entry<br/>[App.tsx]"]
  node_navigator["App Navigator<br/>[AppNavigator.tsx]"]
  node_tabs["Bottom Tabs"]
  node_screen_container["Screen Container<br/>[SreenContainer.tsx]"]
  node_custom_header["Custom Header<br/>[CustomHeader.tsx]"]
end

subgraph group_writing["Grammar Checking"]
  node_check_screen["Check Screen<br/>[CheckScreen.tsx]"]
  node_check_sections["Check Sections"]
  node_check_styles["Check Screen Styles"]
  node_grammar_hook["Grammar Hook<br/>[useGrammar.ts]"]
  node_grammar_store["Grammar State<br/>[grammar.store.ts]"]
  node_grammar_service["Grammar Service"]
  node_api_service["API Client<br/>[api.services.ts]"]
  node_result_card["Result Card"]
end

subgraph group_history["History and Storage"]
  node_history_screen["History Screen<br/>[HistoryScreen.tsx]"]
  node_history_hook["History Hook<br/>[useHistory.ts]"]
  node_history_store["History State<br/>[history.store.ts]"]
  node_history_service["History Service"]
  node_storage[("Local Storage")]
  node_history_list["History List<br/>[HistoryList.tsx]"]
end

subgraph group_settings["Settings and Shared UI"]
  node_settings_screen["Settings Screen<br/>[SettingsScreen.tsx]"]
  node_theme_section["Theme Section<br/>[ThemeSection.tsx]"]
  node_about_section["About Section<br/>[AboutSection.tsx]"]
  node_settings_store["Settings State<br/>[settings.store.ts]"]
  node_theme_hook["Theme Hook<br/>[useTheme.ts]"]
  node_shared_controls["Shared UI Controls<br/>[Button.styles.ts]"]
end

node_user(("App User"))
node_openrouter{{"OpenRouter API"}}

node_user -->|"opens"| node_app_entry
node_app_entry -->|"renders"| node_navigator
node_navigator -->|"routes to"| node_tabs
node_tabs -->|"routes to"| node_check_screen
node_tabs -->|"routes to"| node_history_screen
node_tabs -->|"routes to"| node_settings_screen
node_check_screen -->|"uses"| node_grammar_hook
node_check_screen -->|"renders"| node_check_sections
node_check_screen -->|"uses"| node_check_styles
node_grammar_hook -->|"reads and updates"| node_grammar_store
node_grammar_hook -->|"requests check"| node_grammar_service
node_grammar_hook -->|"adds result"| node_history_hook
node_grammar_service -->|"sends request"| node_api_service
node_api_service -.->|"HTTP request"| node_openrouter
node_history_screen -->|"reads history"| node_history_hook
node_history_screen -->|"renders"| node_history_list
node_history_hook -->|"reads and updates"| node_history_store
node_history_hook -->|"persists changes"| node_history_service
node_history_service -.->|"uses storage"| node_storage
node_settings_screen -->|"renders"| node_theme_section
node_settings_screen -->|"renders"| node_about_section
node_theme_section -->|"uses"| node_theme_hook
node_theme_hook -->|"reads state"| node_settings_store
node_check_screen -->|"renders"| node_screen_container

click node_app_entry "https://github.com/serenbeam/ai-grammar-checker/blob/main/App.tsx"
click node_navigator "https://github.com/serenbeam/ai-grammar-checker/blob/main/src/navigation/AppNavigator.tsx"
click node_tabs "https://github.com/serenbeam/ai-grammar-checker/blob/main/src/navigation/BottomTabNavigator.tsx"
click node_check_screen "https://github.com/serenbeam/ai-grammar-checker/blob/main/src/screens/Check/CheckScreen.tsx"
click node_check_sections "https://github.com/serenbeam/ai-grammar-checker/tree/main/src/screens/Check/components"
click node_check_styles "https://github.com/serenbeam/ai-grammar-checker/blob/main/src/screens/Check/CheckScreen.styles.ts"
click node_grammar_hook "https://github.com/serenbeam/ai-grammar-checker/blob/main/src/hooks/useGrammar.ts"
click node_grammar_store "https://github.com/serenbeam/ai-grammar-checker/blob/main/src/store/grammar.store.ts"
click node_grammar_service "https://github.com/serenbeam/ai-grammar-checker/blob/main/src/services/grammar.services.ts"
click node_api_service "https://github.com/serenbeam/ai-grammar-checker/blob/main/src/services/api.services.ts"
click node_history_screen "https://github.com/serenbeam/ai-grammar-checker/blob/main/src/screens/History/HistoryScreen.tsx"
click node_history_hook "https://github.com/serenbeam/ai-grammar-checker/blob/main/src/hooks/useHistory.ts"
click node_history_store "https://github.com/serenbeam/ai-grammar-checker/blob/main/src/store/history.store.ts"
click node_history_service "https://github.com/serenbeam/ai-grammar-checker/blob/main/src/services/history.services.ts"
click node_storage "https://github.com/serenbeam/ai-grammar-checker/blob/main/src/services/storage.services.ts"
click node_history_list "https://github.com/serenbeam/ai-grammar-checker/blob/main/src/screens/History/components/HistoryList/HistoryList.tsx"
click node_settings_screen "https://github.com/serenbeam/ai-grammar-checker/blob/main/src/screens/Settings/SettingsScreen.tsx"
click node_theme_section "https://github.com/serenbeam/ai-grammar-checker/blob/main/src/screens/Settings/components/ThemeSection/ThemeSection.tsx"
click node_about_section "https://github.com/serenbeam/ai-grammar-checker/blob/main/src/screens/Settings/components/AboutSection/AboutSection.tsx"
click node_settings_store "https://github.com/serenbeam/ai-grammar-checker/blob/main/src/store/settings.store.ts"
click node_theme_hook "https://github.com/serenbeam/ai-grammar-checker/blob/main/src/hooks/useTheme.ts"
click node_shared_controls "https://github.com/serenbeam/ai-grammar-checker/blob/main/src/components/common/Button/Button.styles.ts"
click node_result_card "https://github.com/serenbeam/ai-grammar-checker/blob/main/src/components/common/ResultCard/ResultCard.styles.ts"
click node_screen_container "https://github.com/serenbeam/ai-grammar-checker/blob/main/src/components/navigation/SreenContainer/SreenContainer.tsx"
click node_custom_header "https://github.com/serenbeam/ai-grammar-checker/blob/main/src/components/navigation/CustomHeader/CustomHeader.tsx"

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_app_entry,node_navigator,node_tabs,node_screen_container,node_custom_header,node_user toneBlue
class node_check_screen,node_check_sections,node_check_styles,node_grammar_hook,node_grammar_store,node_grammar_service,node_api_service,node_result_card toneAmber
class node_history_screen,node_history_hook,node_history_store,node_history_service,node_storage,node_history_list,node_openrouter toneMint
class node_settings_screen,node_theme_section,node_about_section,node_settings_store,node_theme_hook,node_shared_controls toneRose
```

## Components

### App and Navigation

- [App Entry](https://github.com/serenbeam/ai-grammar-checker/blob/main/App.tsx): `App.tsx`
- [App Navigator](https://github.com/serenbeam/ai-grammar-checker/blob/main/src/navigation/AppNavigator.tsx): `src/navigation/AppNavigator.tsx`
- [Bottom Tabs](https://github.com/serenbeam/ai-grammar-checker/blob/main/src/navigation/BottomTabNavigator.tsx): `src/navigation/BottomTabNavigator.tsx`
- [Screen Container](https://github.com/serenbeam/ai-grammar-checker/blob/main/src/components/navigation/SreenContainer/SreenContainer.tsx): `src/components/navigation/SreenContainer/SreenContainer.tsx`
- [Custom Header](https://github.com/serenbeam/ai-grammar-checker/blob/main/src/components/navigation/CustomHeader/CustomHeader.tsx): `src/components/navigation/CustomHeader/CustomHeader.tsx`

### Grammar Checking

- [Check Screen](https://github.com/serenbeam/ai-grammar-checker/blob/main/src/screens/Check/CheckScreen.tsx): `src/screens/Check/CheckScreen.tsx`
- [Check Sections](https://github.com/serenbeam/ai-grammar-checker/tree/main/src/screens/Check/components): `src/screens/Check/components`
- [Check Screen Styles](https://github.com/serenbeam/ai-grammar-checker/blob/main/src/screens/Check/CheckScreen.styles.ts): `src/screens/Check/CheckScreen.styles.ts`
- [Grammar Hook](https://github.com/serenbeam/ai-grammar-checker/blob/main/src/hooks/useGrammar.ts): `src/hooks/useGrammar.ts`
- [Grammar State](https://github.com/serenbeam/ai-grammar-checker/blob/main/src/store/grammar.store.ts): `src/store/grammar.store.ts`
- [Grammar Service](https://github.com/serenbeam/ai-grammar-checker/blob/main/src/services/grammar.services.ts): `src/services/grammar.services.ts`
- [API Client](https://github.com/serenbeam/ai-grammar-checker/blob/main/src/services/api.services.ts): `src/services/api.services.ts`
- [Result Card](https://github.com/serenbeam/ai-grammar-checker/blob/main/src/components/common/ResultCard/ResultCard.styles.ts): `src/components/common/ResultCard/ResultCard.styles.ts`

### History and Storage

- [History Screen](https://github.com/serenbeam/ai-grammar-checker/blob/main/src/screens/History/HistoryScreen.tsx): `src/screens/History/HistoryScreen.tsx`
- [History Hook](https://github.com/serenbeam/ai-grammar-checker/blob/main/src/hooks/useHistory.ts): `src/hooks/useHistory.ts`
- [History State](https://github.com/serenbeam/ai-grammar-checker/blob/main/src/store/history.store.ts): `src/store/history.store.ts`
- [History Service](https://github.com/serenbeam/ai-grammar-checker/blob/main/src/services/history.services.ts): `src/services/history.services.ts`
- [Local Storage](https://github.com/serenbeam/ai-grammar-checker/blob/main/src/services/storage.services.ts): `src/services/storage.services.ts`
- [History List](https://github.com/serenbeam/ai-grammar-checker/blob/main/src/screens/History/components/HistoryList/HistoryList.tsx): `src/screens/History/components/HistoryList/HistoryList.tsx`

### Settings and Shared UI

- [Settings Screen](https://github.com/serenbeam/ai-grammar-checker/blob/main/src/screens/Settings/SettingsScreen.tsx): `src/screens/Settings/SettingsScreen.tsx`
- [Theme Section](https://github.com/serenbeam/ai-grammar-checker/blob/main/src/screens/Settings/components/ThemeSection/ThemeSection.tsx): `src/screens/Settings/components/ThemeSection/ThemeSection.tsx`
- [About Section](https://github.com/serenbeam/ai-grammar-checker/blob/main/src/screens/Settings/components/AboutSection/AboutSection.tsx): `src/screens/Settings/components/AboutSection/AboutSection.tsx`
- [Settings State](https://github.com/serenbeam/ai-grammar-checker/blob/main/src/store/settings.store.ts): `src/store/settings.store.ts`
- [Theme Hook](https://github.com/serenbeam/ai-grammar-checker/blob/main/src/hooks/useTheme.ts): `src/hooks/useTheme.ts`
- [Shared UI Controls](https://github.com/serenbeam/ai-grammar-checker/blob/main/src/components/common/Button/Button.styles.ts): `src/components/common/Button/Button.styles.ts`

### Other components

- **App User**
- **OpenRouter API**

## Connections

- App User → App Entry: opens (evidence: `README.md`)
- App Entry → App Navigator: renders (evidence: `App.tsx`)
- App Navigator → Bottom Tabs: routes to (evidence: `src/navigation/AppNavigator.tsx`)
- Bottom Tabs → Check Screen: routes to (evidence: `src/navigation/BottomTabNavigator.tsx`)
- Bottom Tabs → History Screen: routes to (evidence: `src/navigation/BottomTabNavigator.tsx`)
- Bottom Tabs → Settings Screen: routes to (evidence: `src/navigation/BottomTabNavigator.tsx`)
- Check Screen → Grammar Hook: uses (evidence: `src/screens/Check/CheckScreen.tsx`)
- Check Screen → Check Sections: renders (evidence: `src/screens/Check/CheckScreen.tsx`)
- Check Screen → Check Screen Styles: uses (evidence: `src/screens/Check/CheckScreen.tsx`)
- Grammar Hook → Grammar State: reads and updates (evidence: `src/hooks/useGrammar.ts`)
- Grammar Hook → Grammar Service: requests check (evidence: `src/hooks/useGrammar.ts`)
- Grammar Hook → History Hook: adds result (evidence: `src/hooks/useGrammar.ts`)
- Grammar Service → API Client: sends request (evidence: `src/services/grammar.services.ts`)
- API Client → OpenRouter API: HTTP request (evidence: `README.md`)
- History Screen → History Hook: reads history (evidence: `src/screens/History/HistoryScreen.tsx`)
- History Screen → History List: renders (evidence: `src/screens/History/HistoryScreen.tsx`)
- History Hook → History State: reads and updates (evidence: `src/hooks/useHistory.ts`)
- History Hook → History Service: persists changes (evidence: `src/hooks/useHistory.ts`)
- History Service → Local Storage: uses storage
- Settings Screen → Theme Section: renders (evidence: `src/screens/Settings/SettingsScreen.tsx`)
- Settings Screen → About Section: renders (evidence: `src/screens/Settings/SettingsScreen.tsx`)
- Theme Section → Theme Hook: uses (evidence: `src/screens/Settings/components/ThemeSection/ThemeSection.tsx`)
- Theme Hook → Settings State: reads state (evidence: `src/hooks/useTheme.ts`)
- Check Screen → Screen Container: renders (evidence: `src/screens/Check/CheckScreen.tsx`)
