# timothytnm26/abugikha architecture

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

- Interactive diagram: https://gitdiagram.com/timothytnm26/abugikha
- Repository: https://github.com/timothytnm26/abugikha

## Overview

NarakThai is a Thai-script learning product with web and mobile clients, a shared language engine, and an API for accounts and synced learning state. The main learner workflow is to explore Thai sounds and script, then compose syllables and inspect their pronunciation and tone rules. The README documents the clients’ shared-engine and mobile-sync roles; sampled API routes show how requests reach domain services. Some client-to-widget and unsampled engine internals are not shown, so those links are intentionally omitted.

Main entry points: [`apps/mobile/src/app`](https://github.com/timothytnm26/abugikha/tree/main/apps/mobile/src/app) (Mobile learning app), [`apps/api/src/db/client.ts`](https://github.com/timothytnm26/abugikha/blob/main/apps/api/src/db/client.ts) (D1 database), [`apps/web/src/pages`](https://github.com/timothytnm26/abugikha/tree/main/apps/web/src/pages) (Web learning app), [`apps/api/src/app.ts`](https://github.com/timothytnm26/abugikha/blob/main/apps/api/src/app.ts) (API router)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_clients["Learning clients"]
  node_web["Web learning app"]
  node_mobile["Mobile learning app"]
  node_builder["Syllable builder<br/>[builder-store.ts]"]
  node_mobileprogress[("Offline progress<br/>[learning.ts]")]
end

subgraph group_engine["Thai language engine"]
  node_syllables["Syllable analysis"]
  node_consonants["Consonants and vowels"]
  node_phonetics["Phonetics and romanization"]
  node_writing["Thai writing"]
end

subgraph group_content["Learning content"]
  node_lexicon["Lexicon"]
  node_history["Script history"]
  node_translations["Localized content<br/>[catalog.ts]"]
end

subgraph group_backend["Sync and accounts"]
  node_api["API router<br/>[app.ts]"]
  node_authroutes["Authentication routes<br/>[routes.ts]"]
  node_authservice["Session service<br/>[service.ts]"]
  node_auth["Session authentication<br/>[auth.ts]"]
  node_useroutes["User routes<br/>[routes.ts]"]
  node_userservice["User service<br/>[service.ts]"]
  node_prefs["Preference routes<br/>[routes.ts]"]
  node_prefservice["Preference service<br/>[service.ts]"]
  node_progressroutes["Progress routes<br/>[routes.ts]"]
  node_progressservice["Progress sync service<br/>[service.ts]"]
  node_db[("D1 database<br/>[client.ts]")]
end

subgraph group_shared["Shared interfaces"]
  node_contracts["API schemas and client<br/>[client.ts]"]
end

node_learner(("Learner"))
node_cloudflare[("Cloudflare D1")]

node_learner -->|"explores"| node_web
node_learner -->|"learns with"| node_mobile
node_web -->|"uses shared engine"| node_syllables
node_mobile -->|"uses shared engine"| node_syllables
node_web -->|"displays localized content"| node_translations
node_mobile -->|"displays localized content"| node_translations
node_mobile -->|"stores progress offline"| node_mobileprogress
node_mobile -->|"syncs progress"| node_api
node_web -->|"offers composition controls"| node_builder
node_builder -->|"builds syllables with"| node_syllables
node_api -->|"mounts routes"| node_authroutes
node_api -->|"mounts routes"| node_useroutes
node_api -->|"mounts routes"| node_prefs
node_api -->|"mounts routes"| node_progressroutes
node_authroutes -->|"calls"| node_authservice
node_useroutes -->|"calls"| node_userservice
node_prefs -->|"calls"| node_prefservice
node_progressroutes -->|"calls"| node_progressservice
node_authroutes -->|"requires authentication"| node_auth
node_useroutes -->|"requires authentication"| node_auth
node_prefs -->|"requires authentication"| node_auth
node_progressroutes -->|"requires authentication"| node_auth
node_authservice -->|"reads and writes"| node_db
node_authservice -->|"converts user"| node_userservice
node_auth -->|"checks sessions"| node_db
node_userservice -->|"reads and writes"| node_db
node_prefservice -->|"reads and writes"| node_db
node_progressservice -->|"reads and writes"| node_db
node_db -->|"uses D1 binding"| node_cloudflare
node_mobile -->|"uses API client"| node_contracts
node_web -->|"uses API client"| node_contracts

click node_web "https://github.com/timothytnm26/abugikha/tree/main/apps/web/src/pages"
click node_mobile "https://github.com/timothytnm26/abugikha/tree/main/apps/mobile/src/app"
click node_builder "https://github.com/timothytnm26/abugikha/blob/main/apps/web/src/features/build-syllable/model/builder-store.ts"
click node_mobileprogress "https://github.com/timothytnm26/abugikha/blob/main/apps/mobile/src/store/learning.ts"
click node_syllables "https://github.com/timothytnm26/abugikha/tree/main/packages/core/src/syllable"
click node_consonants "https://github.com/timothytnm26/abugikha/tree/main/packages/core/src/consonant"
click node_phonetics "https://github.com/timothytnm26/abugikha/tree/main/packages/core/src/phoneme"
click node_writing "https://github.com/timothytnm26/abugikha/tree/main/packages/core/src/writing"
click node_lexicon "https://github.com/timothytnm26/abugikha/tree/main/packages/core/src/lexicon"
click node_history "https://github.com/timothytnm26/abugikha/tree/main/packages/core/src/script-history"
click node_translations "https://github.com/timothytnm26/abugikha/blob/main/packages/i18n/src/catalog.ts"
click node_contracts "https://github.com/timothytnm26/abugikha/blob/main/packages/contracts/src/client.ts"
click node_api "https://github.com/timothytnm26/abugikha/blob/main/apps/api/src/app.ts"
click node_authroutes "https://github.com/timothytnm26/abugikha/blob/main/apps/api/src/modules/auth/routes.ts"
click node_authservice "https://github.com/timothytnm26/abugikha/blob/main/apps/api/src/modules/auth/service.ts"
click node_auth "https://github.com/timothytnm26/abugikha/blob/main/apps/api/src/middleware/auth.ts"
click node_useroutes "https://github.com/timothytnm26/abugikha/blob/main/apps/api/src/modules/users/routes.ts"
click node_userservice "https://github.com/timothytnm26/abugikha/blob/main/apps/api/src/modules/users/service.ts"
click node_prefs "https://github.com/timothytnm26/abugikha/blob/main/apps/api/src/modules/preferences/routes.ts"
click node_prefservice "https://github.com/timothytnm26/abugikha/blob/main/apps/api/src/modules/preferences/service.ts"
click node_progressroutes "https://github.com/timothytnm26/abugikha/blob/main/apps/api/src/modules/progress/routes.ts"
click node_progressservice "https://github.com/timothytnm26/abugikha/blob/main/apps/api/src/modules/progress/service.ts"
click node_db "https://github.com/timothytnm26/abugikha/blob/main/apps/api/src/db/client.ts"

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_web,node_mobile,node_builder,node_mobileprogress toneBlue
class node_syllables,node_consonants,node_phonetics,node_writing,node_cloudflare toneAmber
class node_lexicon,node_history,node_translations toneMint
class node_api,node_authroutes,node_authservice,node_auth,node_useroutes,node_userservice,node_prefs,node_prefservice,node_progressroutes,node_progressservice,node_db toneRose
class node_contracts,node_learner toneIndigo
```

## Components

### Learning clients

- [Web learning app](https://github.com/timothytnm26/abugikha/tree/main/apps/web/src/pages): `apps/web/src/pages`
- [Mobile learning app](https://github.com/timothytnm26/abugikha/tree/main/apps/mobile/src/app): `apps/mobile/src/app`
- [Syllable builder](https://github.com/timothytnm26/abugikha/blob/main/apps/web/src/features/build-syllable/model/builder-store.ts): `apps/web/src/features/build-syllable/model/builder-store.ts`
- [Offline progress](https://github.com/timothytnm26/abugikha/blob/main/apps/mobile/src/store/learning.ts): `apps/mobile/src/store/learning.ts`

### Thai language engine

- [Syllable analysis](https://github.com/timothytnm26/abugikha/tree/main/packages/core/src/syllable): `packages/core/src/syllable`
- [Consonants and vowels](https://github.com/timothytnm26/abugikha/tree/main/packages/core/src/consonant): `packages/core/src/consonant`
- [Phonetics and romanization](https://github.com/timothytnm26/abugikha/tree/main/packages/core/src/phoneme): `packages/core/src/phoneme`
- [Thai writing](https://github.com/timothytnm26/abugikha/tree/main/packages/core/src/writing): `packages/core/src/writing`

### Learning content

- [Lexicon](https://github.com/timothytnm26/abugikha/tree/main/packages/core/src/lexicon): `packages/core/src/lexicon`
- [Script history](https://github.com/timothytnm26/abugikha/tree/main/packages/core/src/script-history): `packages/core/src/script-history`
- [Localized content](https://github.com/timothytnm26/abugikha/blob/main/packages/i18n/src/catalog.ts): `packages/i18n/src/catalog.ts`

### Sync and accounts

- [API router](https://github.com/timothytnm26/abugikha/blob/main/apps/api/src/app.ts): `apps/api/src/app.ts`
- [Authentication routes](https://github.com/timothytnm26/abugikha/blob/main/apps/api/src/modules/auth/routes.ts): `apps/api/src/modules/auth/routes.ts`
- [Session service](https://github.com/timothytnm26/abugikha/blob/main/apps/api/src/modules/auth/service.ts): `apps/api/src/modules/auth/service.ts`
- [Session authentication](https://github.com/timothytnm26/abugikha/blob/main/apps/api/src/middleware/auth.ts): `apps/api/src/middleware/auth.ts`
- [User routes](https://github.com/timothytnm26/abugikha/blob/main/apps/api/src/modules/users/routes.ts): `apps/api/src/modules/users/routes.ts`
- [User service](https://github.com/timothytnm26/abugikha/blob/main/apps/api/src/modules/users/service.ts): `apps/api/src/modules/users/service.ts`
- [Preference routes](https://github.com/timothytnm26/abugikha/blob/main/apps/api/src/modules/preferences/routes.ts): `apps/api/src/modules/preferences/routes.ts`
- [Preference service](https://github.com/timothytnm26/abugikha/blob/main/apps/api/src/modules/preferences/service.ts): `apps/api/src/modules/preferences/service.ts`
- [Progress routes](https://github.com/timothytnm26/abugikha/blob/main/apps/api/src/modules/progress/routes.ts): `apps/api/src/modules/progress/routes.ts`
- [Progress sync service](https://github.com/timothytnm26/abugikha/blob/main/apps/api/src/modules/progress/service.ts): `apps/api/src/modules/progress/service.ts`
- [D1 database](https://github.com/timothytnm26/abugikha/blob/main/apps/api/src/db/client.ts): `apps/api/src/db/client.ts`

### Shared interfaces

- [API schemas and client](https://github.com/timothytnm26/abugikha/blob/main/packages/contracts/src/client.ts): `packages/contracts/src/client.ts`

### Other components

- **Learner**
- **Cloudflare D1**

## Connections

- Learner → Web learning app: explores (evidence: `README.md`)
- Learner → Mobile learning app: learns with (evidence: `README.md`)
- Web learning app → Syllable analysis: uses shared engine (evidence: `README.md`)
- Mobile learning app → Syllable analysis: uses shared engine (evidence: `README.md`)
- Web learning app → Localized content: displays localized content (evidence: `README.md`)
- Mobile learning app → Localized content: displays localized content (evidence: `README.md`)
- Mobile learning app → Offline progress: stores progress offline (evidence: `README.md`)
- Mobile learning app → API router: syncs progress (evidence: `README.md`)
- Web learning app → Syllable builder: offers composition controls (evidence: `README.md`)
- Syllable builder → Syllable analysis: builds syllables with (evidence: `README.md`)
- API router → Authentication routes: mounts routes (evidence: `apps/api/src/app.ts`)
- API router → User routes: mounts routes (evidence: `apps/api/src/app.ts`)
- API router → Preference routes: mounts routes (evidence: `apps/api/src/app.ts`)
- API router → Progress routes: mounts routes (evidence: `apps/api/src/app.ts`)
- Authentication routes → Session service: calls (evidence: `apps/api/src/modules/auth/routes.ts`)
- User routes → User service: calls (evidence: `apps/api/src/modules/users/routes.ts`)
- Preference routes → Preference service: calls (evidence: `apps/api/src/modules/preferences/routes.ts`)
- Progress routes → Progress sync service: calls (evidence: `apps/api/src/modules/progress/routes.ts`)
- Authentication routes → Session authentication: requires authentication (evidence: `apps/api/src/modules/auth/routes.ts`)
- User routes → Session authentication: requires authentication (evidence: `apps/api/src/modules/users/routes.ts`)
- Preference routes → Session authentication: requires authentication (evidence: `apps/api/src/modules/preferences/routes.ts`)
- Progress routes → Session authentication: requires authentication (evidence: `apps/api/src/modules/progress/routes.ts`)
- Session service → D1 database: reads and writes (evidence: `apps/api/src/modules/auth/service.ts`)
- Session service → User service: converts user (evidence: `apps/api/src/modules/auth/service.ts`)
- Session authentication → D1 database: checks sessions (evidence: `apps/api/src/middleware/auth.ts`)
- User service → D1 database: reads and writes (evidence: `apps/api/src/modules/users/service.ts`)
- Preference service → D1 database: reads and writes (evidence: `apps/api/src/modules/preferences/service.ts`)
- Progress sync service → D1 database: reads and writes (evidence: `apps/api/src/modules/progress/service.ts`)
- D1 database → Cloudflare D1: uses D1 binding (evidence: `apps/api/src/db/client.ts`)
- Mobile learning app → API schemas and client: uses API client (evidence: `README.md`)
- Web learning app → API schemas and client: uses API client (evidence: `README.md`)
