# ahmedkhaleel2004/leftright architecture

> Architecture diagram of the GitHub repository ahmedkhaleel2004/leftright, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ahmedkhaleel2004/leftright
- Repository: https://github.com/ahmedkhaleel2004/leftright

## Overview

Left-Right Typing Test is a client-driven Next.js typing application. The user selects a keyboard layout and word/time mode, types generated text, and receives accuracy plus separate left/right WPM and balance feedback. Completed tests submit a validated hand-speed ratio to Redis-backed community statistics and retrieve the updated average. The sampled code directly supports the typing, layout, metrics, community API, and analytics paths; other UI details remain unsampled.

Main entry points: [`src/app/page.tsx`](https://github.com/ahmedkhaleel2004/leftright/blob/main/src/app/page.tsx) (Typing Interface), [`src/app/api/ratio/[layout]/route.ts`](https://github.com/ahmedkhaleel2004/leftright/blob/main/src/app/api/ratio/%5Blayout%5D/route.ts) (Ratio API), [`src/app/providers.tsx`](https://github.com/ahmedkhaleel2004/leftright/blob/main/src/app/providers.tsx) (Analytics Provider), [`src/app/layout.tsx`](https://github.com/ahmedkhaleel2004/leftright/blob/main/src/app/layout.tsx) (App Shell)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Typing Experience"]
  node_typing_ui["Typing Interface<br/>[page.tsx]"]
  node_results["Results View<br/>[page.tsx]"]
end

subgraph group_domain["Typing Domain"]
  node_text_generator["Text Generator<br/>[commonWords.ts]"]
  node_layout_catalog["Keyboard Layouts<br/>[keyboardLayouts.ts]"]
  node_session_metrics["Session Metrics<br/>[page.tsx]"]
end

subgraph group_community["Community Statistics"]
  node_ratio_api["Ratio API<br/>[route.ts]"]
  node_redis[("Community Redis")]
end

subgraph group_platform["Application Platform"]
  node_app_shell["App Shell<br/>[layout.tsx]"]
  node_analytics_provider["Analytics Provider<br/>[providers.tsx]"]
end

node_user(("Typist"))
node_posthog["PostHog Analytics"]

node_user -->|"types and selects"| node_typing_ui
node_typing_ui -->|"generates prompts"| node_text_generator
node_typing_ui -->|"reads layout"| node_layout_catalog
node_typing_ui -->|"tracks input"| node_session_metrics
node_session_metrics -->|"computes feedback"| node_results
node_typing_ui -->|"submits ratio"| node_ratio_api
node_typing_ui -->|"fetches average"| node_ratio_api
node_ratio_api -->|"reads ratios"| node_redis
node_ratio_api -->|"writes ratios"| node_redis
node_ratio_api -->|"returns statistics"| node_typing_ui
node_app_shell -->|"wraps application"| node_analytics_provider
node_analytics_provider -.->|"captures pageviews"| node_posthog

click node_typing_ui "https://github.com/ahmedkhaleel2004/leftright/blob/main/src/app/page.tsx"
click node_results "https://github.com/ahmedkhaleel2004/leftright/blob/main/src/app/page.tsx"
click node_text_generator "https://github.com/ahmedkhaleel2004/leftright/blob/main/src/app/commonWords.ts"
click node_layout_catalog "https://github.com/ahmedkhaleel2004/leftright/blob/main/src/app/keyboardLayouts.ts"
click node_session_metrics "https://github.com/ahmedkhaleel2004/leftright/blob/main/src/app/page.tsx"
click node_ratio_api "https://github.com/ahmedkhaleel2004/leftright/blob/main/src/app/api/ratio/%5Blayout%5D/route.ts"
click node_app_shell "https://github.com/ahmedkhaleel2004/leftright/blob/main/src/app/layout.tsx"
click node_analytics_provider "https://github.com/ahmedkhaleel2004/leftright/blob/main/src/app/providers.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_typing_ui,node_results toneBlue
class node_text_generator,node_layout_catalog,node_session_metrics toneAmber
class node_ratio_api,node_redis toneMint
class node_app_shell,node_analytics_provider toneRose
class node_user,node_posthog toneIndigo
```

## Components

### Typing Experience

- [Typing Interface](https://github.com/ahmedkhaleel2004/leftright/blob/main/src/app/page.tsx): `src/app/page.tsx`
- [Results View](https://github.com/ahmedkhaleel2004/leftright/blob/main/src/app/page.tsx): `src/app/page.tsx`

### Typing Domain

- [Text Generator](https://github.com/ahmedkhaleel2004/leftright/blob/main/src/app/commonWords.ts): `src/app/commonWords.ts`
- [Keyboard Layouts](https://github.com/ahmedkhaleel2004/leftright/blob/main/src/app/keyboardLayouts.ts): `src/app/keyboardLayouts.ts`
- [Session Metrics](https://github.com/ahmedkhaleel2004/leftright/blob/main/src/app/page.tsx): `src/app/page.tsx`

### Community Statistics

- [Ratio API](https://github.com/ahmedkhaleel2004/leftright/blob/main/src/app/api/ratio/%5Blayout%5D/route.ts): `src/app/api/ratio/[layout]/route.ts`
- **Community Redis**

### Application Platform

- [App Shell](https://github.com/ahmedkhaleel2004/leftright/blob/main/src/app/layout.tsx): `src/app/layout.tsx`
- [Analytics Provider](https://github.com/ahmedkhaleel2004/leftright/blob/main/src/app/providers.tsx): `src/app/providers.tsx`

### Other components

- **Typist**
- **PostHog Analytics**

## Connections

- Typist → Typing Interface: types and selects
- Typing Interface → Text Generator: generates prompts
- Typing Interface → Keyboard Layouts: reads layout
- Typing Interface → Session Metrics: tracks input
- Session Metrics → Results View: computes feedback
- Typing Interface → Ratio API: submits ratio
- Typing Interface → Ratio API: fetches average
- Ratio API → Community Redis: reads ratios
- Ratio API → Community Redis: writes ratios
- Ratio API → Typing Interface: returns statistics
- App Shell → Analytics Provider: wraps application
- Analytics Provider → PostHog Analytics: captures pageviews
