# megodog1110/phrase-library architecture

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

- Interactive diagram: https://gitdiagram.com/megodog1110/phrase-library
- Repository: https://github.com/megodog1110/phrase-library

## Overview

ことばメモは、出典付きのフレーズを端末内に保存して読み返す個人向けライブラリです。主な流れは、利用者がライブラリで検索・絞り込み、入力フォームで記録や編集を行い、端末内ストアからカード表示することです。ログイン時は暗号化した差分を同期し、アカウントの端末間で共有できます。READMEに記載された書き出し、オフライン利用、問い合わせも含めました。未抜粋の実装関係はREADMEまたはSOURCE INDEXで確認できる範囲に留めています。

Main entry points: [`features/library/QuoteCollection.tsx`](https://github.com/megodog1110/phrase-library/blob/dev/features/library/QuoteCollection.tsx) (ライブラリ画面), [`features/sync/client.ts`](https://github.com/megodog1110/phrase-library/blob/dev/features/sync/client.ts) (同期クライアント), [`features/library/useLocalQuotes.ts`](https://github.com/megodog1110/phrase-library/blob/dev/features/library/useLocalQuotes.ts) (ローカル操作), [`db/encrypted-sync.ts`](https://github.com/megodog1110/phrase-library/blob/dev/db/encrypted-sync.ts) (同期ストア)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_library["ライブラリ体験"]
  node_home["ホーム<br/>[page.tsx]"]
  node_collection["ライブラリ画面"]
  node_filters["検索・絞り込み"]
  node_form["フレーズ入力<br/>[QuoteForm.tsx]"]
  node_drafts["作品別下書き<br/>[useQuoteDrafts.ts]"]
  node_grid["カード表示<br/>[PhraseGrid.tsx]"]
  node_typography["表示整形<br/>[typography.ts]"]
end

subgraph group_local["端末内データ"]
  node_localhook["ローカル操作<br/>[useLocalQuotes.ts]"]
  node_store[("端末内ストア<br/>[localQuoteStore.ts]")]
  node_export["JSON書き出し<br/>[backup.ts]"]
  node_offline["オフライン表示<br/>[OfflineShell.tsx]"]
end

subgraph group_accounts["アカウント・同期"]
  node_accountpage["アカウント画面<br/>[page.tsx]"]
  node_accountform["アカウント管理<br/>[AccountForm.tsx]"]
  node_auth["認証サービス"]
  node_syncclient["同期クライアント<br/>[client.ts]"]
  node_crypto["暗号化処理<br/>[crypto.ts]"]
  node_syncapi["同期API<br/>[route.ts]"]
  node_syncdb[("同期ストア<br/>[encrypted-sync.ts]")]
end

subgraph group_service["サービス機能"]
  node_contact["問い合わせAPI<br/>[route.ts]"]
  node_contactdb[("問い合わせ保存<br/>[contact.ts]")]
  node_legal["利用規約・方針<br/>[policy.ts]"]
end

node_user(("利用者"))

node_user -->|"開く"| node_home
node_home -->|"表示する"| node_collection
node_user -->|"検索・閲覧"| node_collection
node_collection -->|"絞り込む"| node_filters
node_collection -->|"表示する"| node_grid
node_grid -->|"整形する"| node_typography
node_user -->|"記録・編集"| node_form
node_drafts -->|"再開する"| node_form
node_collection -.->|"操作する"| node_localhook
node_localhook -->|"読み書きする"| node_store
node_user -->|"書き出す"| node_export
node_user -->|"オフライン利用"| node_offline
node_user -->|"ログインする"| node_accountpage
node_accountpage -->|"表示する"| node_accountform
node_accountform -->|"認証する"| node_auth
node_localhook -->|"同期する"| node_syncclient
node_syncclient -->|"差分を読む・反映"| node_store
node_syncclient -->|"暗号化・復号"| node_crypto
node_syncclient -->|"API通信"| node_syncapi
node_syncapi -->|"保存・取得"| node_syncdb
node_syncdb -->|"暗号形式を利用"| node_crypto
node_syncdb -.->|"アカウント認証"| node_auth
node_user -->|"問い合わせ送信"| node_contact
node_contact -->|"保存する"| node_contactdb
node_user -->|"内容を確認"| node_legal

click node_home "https://github.com/megodog1110/phrase-library/blob/dev/app/page.tsx"
click node_collection "https://github.com/megodog1110/phrase-library/blob/dev/features/library/QuoteCollection.tsx"
click node_filters "https://github.com/megodog1110/phrase-library/tree/dev/features/library/components"
click node_form "https://github.com/megodog1110/phrase-library/blob/dev/components/QuoteForm.tsx"
click node_drafts "https://github.com/megodog1110/phrase-library/blob/dev/features/library/useQuoteDrafts.ts"
click node_grid "https://github.com/megodog1110/phrase-library/blob/dev/components/phrase/PhraseGrid.tsx"
click node_typography "https://github.com/megodog1110/phrase-library/blob/dev/app/quotes/typography.ts"
click node_localhook "https://github.com/megodog1110/phrase-library/blob/dev/features/library/useLocalQuotes.ts"
click node_store "https://github.com/megodog1110/phrase-library/blob/dev/features/library/localQuoteStore.ts"
click node_export "https://github.com/megodog1110/phrase-library/blob/dev/features/library/backup.ts"
click node_offline "https://github.com/megodog1110/phrase-library/blob/dev/features/library/OfflineShell.tsx"
click node_accountpage "https://github.com/megodog1110/phrase-library/blob/dev/app/account/page.tsx"
click node_accountform "https://github.com/megodog1110/phrase-library/blob/dev/features/account/AccountForm.tsx"
click node_syncclient "https://github.com/megodog1110/phrase-library/blob/dev/features/sync/client.ts"
click node_crypto "https://github.com/megodog1110/phrase-library/blob/dev/features/sync/crypto.ts"
click node_syncapi "https://github.com/megodog1110/phrase-library/blob/dev/app/api/v1/%5B%5B...route%5D%5D/route.ts"
click node_syncdb "https://github.com/megodog1110/phrase-library/blob/dev/db/encrypted-sync.ts"
click node_contact "https://github.com/megodog1110/phrase-library/blob/dev/app/api/contact/route.ts"
click node_contactdb "https://github.com/megodog1110/phrase-library/blob/dev/db/contact.ts"
click node_legal "https://github.com/megodog1110/phrase-library/blob/dev/features/legal/policy.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_home,node_collection,node_filters,node_form,node_drafts,node_grid,node_typography toneBlue
class node_localhook,node_store,node_export,node_offline toneAmber
class node_accountpage,node_accountform,node_auth,node_syncclient,node_crypto,node_syncapi,node_syncdb toneMint
class node_contact,node_contactdb,node_legal toneRose
class node_user toneIndigo
```

## Components

### ライブラリ体験

- [ホーム](https://github.com/megodog1110/phrase-library/blob/dev/app/page.tsx): `app/page.tsx`
- [ライブラリ画面](https://github.com/megodog1110/phrase-library/blob/dev/features/library/QuoteCollection.tsx): `features/library/QuoteCollection.tsx`
- [検索・絞り込み](https://github.com/megodog1110/phrase-library/tree/dev/features/library/components): `features/library/components`
- [フレーズ入力](https://github.com/megodog1110/phrase-library/blob/dev/components/QuoteForm.tsx): `components/QuoteForm.tsx`
- [作品別下書き](https://github.com/megodog1110/phrase-library/blob/dev/features/library/useQuoteDrafts.ts): `features/library/useQuoteDrafts.ts`
- [カード表示](https://github.com/megodog1110/phrase-library/blob/dev/components/phrase/PhraseGrid.tsx): `components/phrase/PhraseGrid.tsx`
- [表示整形](https://github.com/megodog1110/phrase-library/blob/dev/app/quotes/typography.ts): `app/quotes/typography.ts`

### 端末内データ

- [ローカル操作](https://github.com/megodog1110/phrase-library/blob/dev/features/library/useLocalQuotes.ts): `features/library/useLocalQuotes.ts`
- [端末内ストア](https://github.com/megodog1110/phrase-library/blob/dev/features/library/localQuoteStore.ts): `features/library/localQuoteStore.ts`
- [JSON書き出し](https://github.com/megodog1110/phrase-library/blob/dev/features/library/backup.ts): `features/library/backup.ts`
- [オフライン表示](https://github.com/megodog1110/phrase-library/blob/dev/features/library/OfflineShell.tsx): `features/library/OfflineShell.tsx`

### アカウント・同期

- [アカウント画面](https://github.com/megodog1110/phrase-library/blob/dev/app/account/page.tsx): `app/account/page.tsx`
- [アカウント管理](https://github.com/megodog1110/phrase-library/blob/dev/features/account/AccountForm.tsx): `features/account/AccountForm.tsx`
- **認証サービス**
- [同期クライアント](https://github.com/megodog1110/phrase-library/blob/dev/features/sync/client.ts): `features/sync/client.ts`
- [暗号化処理](https://github.com/megodog1110/phrase-library/blob/dev/features/sync/crypto.ts): `features/sync/crypto.ts`
- [同期API](https://github.com/megodog1110/phrase-library/blob/dev/app/api/v1/%5B%5B...route%5D%5D/route.ts): `app/api/v1/[[...route]]/route.ts`
- [同期ストア](https://github.com/megodog1110/phrase-library/blob/dev/db/encrypted-sync.ts): `db/encrypted-sync.ts`

### サービス機能

- [問い合わせAPI](https://github.com/megodog1110/phrase-library/blob/dev/app/api/contact/route.ts): `app/api/contact/route.ts`
- [問い合わせ保存](https://github.com/megodog1110/phrase-library/blob/dev/db/contact.ts): `db/contact.ts`
- [利用規約・方針](https://github.com/megodog1110/phrase-library/blob/dev/features/legal/policy.ts): `features/legal/policy.ts`

### Other components

- **利用者**

## Connections

- 利用者 → ホーム: 開く
- ホーム → ライブラリ画面: 表示する (evidence: `app/page.tsx`)
- 利用者 → ライブラリ画面: 検索・閲覧
- ライブラリ画面 → 検索・絞り込み: 絞り込む (evidence: `features/library/QuoteCollection.tsx`)
- ライブラリ画面 → カード表示: 表示する (evidence: `features/library/QuoteCollection.tsx`)
- カード表示 → 表示整形: 整形する (evidence: `components/phrase/PhraseGrid.tsx`)
- 利用者 → フレーズ入力: 記録・編集
- 作品別下書き → フレーズ入力: 再開する (evidence: `features/library/useQuoteDrafts.ts`)
- ライブラリ画面 → ローカル操作: 操作する (evidence: `features/library/QuoteCollection.tsx`)
- ローカル操作 → 端末内ストア: 読み書きする (evidence: `features/library/useLocalQuotes.ts`)
- 利用者 → JSON書き出し: 書き出す
- 利用者 → オフライン表示: オフライン利用
- 利用者 → アカウント画面: ログインする
- アカウント画面 → アカウント管理: 表示する (evidence: `app/account/page.tsx`)
- アカウント管理 → 認証サービス: 認証する
- ローカル操作 → 同期クライアント: 同期する (evidence: `features/library/useLocalQuotes.ts`)
- 同期クライアント → 端末内ストア: 差分を読む・反映 (evidence: `features/sync/client.ts`)
- 同期クライアント → 暗号化処理: 暗号化・復号 (evidence: `features/sync/client.ts`)
- 同期クライアント → 同期API: API通信
- 同期API → 同期ストア: 保存・取得 (evidence: `app/api/v1/[[...route]]/route.ts`)
- 同期ストア → 暗号化処理: 暗号形式を利用 (evidence: `db/encrypted-sync.ts`)
- 同期ストア → 認証サービス: アカウント認証
- 利用者 → 問い合わせAPI: 問い合わせ送信
- 問い合わせAPI → 問い合わせ保存: 保存する (evidence: `app/api/contact/route.ts`)
- 利用者 → 利用規約・方針: 内容を確認
