# amandubey923/reader-hub architecture

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

- Interactive diagram: https://gitdiagram.com/amandubey923/reader-hub
- Repository: https://github.com/amandubey923/reader-hub

## Overview

Reader’s HUB is a local-first digital reading and study environment. Readers discover curated books, open a book, read in a PDF workspace, annotate and translate, then track activity and revisit reading memory. The README documents these stages and capabilities; the source index and excerpts confirm key catalog, reader-storage, library-state, authentication, and social responsibilities. Several feature implementations are unsampled, so their relationships are shown only where documented, and source-level call details are not inferred.

Main entry points: [`components/reader/BookReader.tsx`](https://github.com/amandubey923/reader-hub/blob/main/components/reader/BookReader.tsx) (PDF Reader), [`context/LibraryContext.tsx`](https://github.com/amandubey923/reader-hub/blob/main/context/LibraryContext.tsx) (Library State), [`app/page.tsx`](https://github.com/amandubey923/reader-hub/blob/main/app/page.tsx) (Home Discovery), [`lib/reader-storage.ts`](https://github.com/amandubey923/reader-hub/blob/main/lib/reader-storage.ts) (Local Reader Storage)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_discovery["Discovery"]
  node_home["Home Discovery<br/>[page.tsx]"]
  node_catalog[("Book Catalog<br/>[books.ts]")]
  node_bookcard["Book Cards<br/>[BookCard.tsx]"]
end

subgraph group_reading["Reading &amp; Study"]
  node_bookdetail["Book Details"]
  node_pdfreader["PDF Reader<br/>[BookReader.tsx]"]
  node_annotations["Study Annotations"]
  node_translation["Spread Translation"]
  node_timer["Reading Timer"]
end

subgraph group_personal["Personal Library"]
  node_memoryview["Reading Memory"]
  node_storage[("Local Reader Storage<br/>[reader-storage.ts]")]
  node_library["Library State<br/>[LibraryContext.tsx]"]
  node_cloudsync["Cloud Sync<br/>[firestore-sync.ts]"]
  node_analytics["Reading Analytics"]
end

subgraph group_identity["Identity &amp; Community"]
  node_auth["Authentication<br/>[AuthContext.tsx]"]
  node_social[("Social Features<br/>[social.ts]")]
  node_profile["Reader Profiles<br/>[page.tsx]"]
end

subgraph group_services["Platform Services"]
  node_translateapi["Translation API<br/>[route.ts]"]
  node_assistant["Library Assistant"]
  node_chatapi["Assistant API<br/>[route.ts]"]
  node_entitlements["Entitlements<br/>[entitlements.ts]"]
  node_payment["Payment API<br/>[route.ts]"]
  node_admin["Catalog Administration<br/>[page.tsx]"]
  node_adminapi["Admin APIs<br/>[route.ts]"]
  node_firebase[("Firebase Services<br/>[firebase.ts]")]
end

node_reader(("Reader"))

node_reader -->|"discovers"| node_home
node_home -->|"filters catalog"| node_catalog
node_home -->|"renders books"| node_bookcard
node_bookcard -->|"opens book"| node_bookdetail
node_bookdetail -->|"embeds reader"| node_pdfreader
node_pdfreader -->|"supports annotation"| node_annotations
node_pdfreader -->|"translates spread"| node_translation
node_translation -->|"requests translation"| node_translateapi
node_pdfreader -->|"tracks activity"| node_timer
node_timer -->|"records activity"| node_storage
node_memoryview -->|"reads memory"| node_storage
node_library -->|"persists locally"| node_storage
node_library -->|"syncs user data"| node_cloudsync
node_library -->|"uses identity"| node_auth
node_profile -->|"shows analytics"| node_analytics
node_profile -->|"loads social profile"| node_social
node_auth -->|"initializes auth"| node_firebase
node_social -->|"stores social data"| node_firebase
node_assistant -->|"sends questions"| node_chatapi
node_chatapi -->|"uses assistant logic"| node_assistant
node_payment -.->|"checks access"| node_entitlements
node_admin -.->|"manages catalog"| node_adminapi

click node_home "https://github.com/amandubey923/reader-hub/blob/main/app/page.tsx"
click node_catalog "https://github.com/amandubey923/reader-hub/blob/main/data/books.ts"
click node_bookcard "https://github.com/amandubey923/reader-hub/blob/main/components/BookCard.tsx"
click node_bookdetail "https://github.com/amandubey923/reader-hub/blob/main/app/book/%5Bid%5D/BookDetailClient.tsx"
click node_pdfreader "https://github.com/amandubey923/reader-hub/blob/main/components/reader/BookReader.tsx"
click node_annotations "https://github.com/amandubey923/reader-hub/blob/main/components/reader/AnnotationDrawer.tsx"
click node_translation "https://github.com/amandubey923/reader-hub/blob/main/components/reader/TranslationDrawer.tsx"
click node_translateapi "https://github.com/amandubey923/reader-hub/blob/main/app/api/translate/route.ts"
click node_timer "https://github.com/amandubey923/reader-hub/blob/main/components/reader/ReadingSessionTimer.tsx"
click node_memoryview "https://github.com/amandubey923/reader-hub/blob/main/components/memory/BookReadingMemory.tsx"
click node_storage "https://github.com/amandubey923/reader-hub/blob/main/lib/reader-storage.ts"
click node_library "https://github.com/amandubey923/reader-hub/blob/main/context/LibraryContext.tsx"
click node_cloudsync "https://github.com/amandubey923/reader-hub/blob/main/lib/firestore-sync.ts"
click node_analytics "https://github.com/amandubey923/reader-hub/blob/main/lib/reading-analytics.ts"
click node_auth "https://github.com/amandubey923/reader-hub/blob/main/context/AuthContext.tsx"
click node_social "https://github.com/amandubey923/reader-hub/blob/main/lib/social.ts"
click node_profile "https://github.com/amandubey923/reader-hub/blob/main/app/profile/page.tsx"
click node_assistant "https://github.com/amandubey923/reader-hub/blob/main/components/assistant/LibraryAssistant.tsx"
click node_chatapi "https://github.com/amandubey923/reader-hub/blob/main/app/api/chat/route.ts"
click node_entitlements "https://github.com/amandubey923/reader-hub/blob/main/lib/entitlements.ts"
click node_payment "https://github.com/amandubey923/reader-hub/blob/main/app/api/payment/create-order/route.ts"
click node_admin "https://github.com/amandubey923/reader-hub/blob/main/app/admin/page.tsx"
click node_adminapi "https://github.com/amandubey923/reader-hub/blob/main/app/api/admin/catalog/route.ts"
click node_firebase "https://github.com/amandubey923/reader-hub/blob/main/lib/firebase.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_catalog,node_bookcard toneBlue
class node_bookdetail,node_pdfreader,node_annotations,node_translation,node_timer toneAmber
class node_memoryview,node_storage,node_library,node_cloudsync,node_analytics toneMint
class node_auth,node_social,node_profile toneRose
class node_translateapi,node_assistant,node_chatapi,node_entitlements,node_payment,node_admin,node_adminapi,node_firebase,node_reader toneIndigo
```

## Components

### Discovery

- [Home Discovery](https://github.com/amandubey923/reader-hub/blob/main/app/page.tsx): `app/page.tsx`
- [Book Catalog](https://github.com/amandubey923/reader-hub/blob/main/data/books.ts): `data/books.ts`
- [Book Cards](https://github.com/amandubey923/reader-hub/blob/main/components/BookCard.tsx): `components/BookCard.tsx`

### Reading & Study

- [Book Details](https://github.com/amandubey923/reader-hub/blob/main/app/book/%5Bid%5D/BookDetailClient.tsx): `app/book/[id]/BookDetailClient.tsx`
- [PDF Reader](https://github.com/amandubey923/reader-hub/blob/main/components/reader/BookReader.tsx): `components/reader/BookReader.tsx`
- [Study Annotations](https://github.com/amandubey923/reader-hub/blob/main/components/reader/AnnotationDrawer.tsx): `components/reader/AnnotationDrawer.tsx`
- [Spread Translation](https://github.com/amandubey923/reader-hub/blob/main/components/reader/TranslationDrawer.tsx): `components/reader/TranslationDrawer.tsx`
- [Reading Timer](https://github.com/amandubey923/reader-hub/blob/main/components/reader/ReadingSessionTimer.tsx): `components/reader/ReadingSessionTimer.tsx`

### Personal Library

- [Reading Memory](https://github.com/amandubey923/reader-hub/blob/main/components/memory/BookReadingMemory.tsx): `components/memory/BookReadingMemory.tsx`
- [Local Reader Storage](https://github.com/amandubey923/reader-hub/blob/main/lib/reader-storage.ts): `lib/reader-storage.ts`
- [Library State](https://github.com/amandubey923/reader-hub/blob/main/context/LibraryContext.tsx): `context/LibraryContext.tsx`
- [Cloud Sync](https://github.com/amandubey923/reader-hub/blob/main/lib/firestore-sync.ts): `lib/firestore-sync.ts`
- [Reading Analytics](https://github.com/amandubey923/reader-hub/blob/main/lib/reading-analytics.ts): `lib/reading-analytics.ts`

### Identity & Community

- [Authentication](https://github.com/amandubey923/reader-hub/blob/main/context/AuthContext.tsx): `context/AuthContext.tsx`
- [Social Features](https://github.com/amandubey923/reader-hub/blob/main/lib/social.ts): `lib/social.ts`
- [Reader Profiles](https://github.com/amandubey923/reader-hub/blob/main/app/profile/page.tsx): `app/profile/page.tsx`

### Platform Services

- [Translation API](https://github.com/amandubey923/reader-hub/blob/main/app/api/translate/route.ts): `app/api/translate/route.ts`
- [Library Assistant](https://github.com/amandubey923/reader-hub/blob/main/components/assistant/LibraryAssistant.tsx): `components/assistant/LibraryAssistant.tsx`
- [Assistant API](https://github.com/amandubey923/reader-hub/blob/main/app/api/chat/route.ts): `app/api/chat/route.ts`
- [Entitlements](https://github.com/amandubey923/reader-hub/blob/main/lib/entitlements.ts): `lib/entitlements.ts`
- [Payment API](https://github.com/amandubey923/reader-hub/blob/main/app/api/payment/create-order/route.ts): `app/api/payment/create-order/route.ts`
- [Catalog Administration](https://github.com/amandubey923/reader-hub/blob/main/app/admin/page.tsx): `app/admin/page.tsx`
- [Admin APIs](https://github.com/amandubey923/reader-hub/blob/main/app/api/admin/catalog/route.ts): `app/api/admin/catalog/route.ts`
- [Firebase Services](https://github.com/amandubey923/reader-hub/blob/main/lib/firebase.ts): `lib/firebase.ts`

### Other components

- **Reader**

## Connections

- Reader → Home Discovery: discovers
- Home Discovery → Book Catalog: filters catalog (evidence: `app/page.tsx`)
- Home Discovery → Book Cards: renders books (evidence: `app/page.tsx`)
- Book Cards → Book Details: opens book (evidence: `components/BookCard.tsx`)
- Book Details → PDF Reader: embeds reader (evidence: `app/book/[id]/BookDetailClient.tsx`)
- PDF Reader → Study Annotations: supports annotation
- PDF Reader → Spread Translation: translates spread
- Spread Translation → Translation API: requests translation
- PDF Reader → Reading Timer: tracks activity
- Reading Timer → Local Reader Storage: records activity
- Reading Memory → Local Reader Storage: reads memory (evidence: `components/memory/BookReadingMemory.tsx`)
- Library State → Local Reader Storage: persists locally (evidence: `context/LibraryContext.tsx`)
- Library State → Cloud Sync: syncs user data (evidence: `context/LibraryContext.tsx`)
- Library State → Authentication: uses identity (evidence: `context/LibraryContext.tsx`)
- Reader Profiles → Reading Analytics: shows analytics (evidence: `app/profile/page.tsx`)
- Reader Profiles → Social Features: loads social profile (evidence: `app/profile/page.tsx`)
- Authentication → Firebase Services: initializes auth (evidence: `context/AuthContext.tsx`)
- Social Features → Firebase Services: stores social data (evidence: `lib/social.ts`)
- Library Assistant → Assistant API: sends questions
- Assistant API → Library Assistant: uses assistant logic (evidence: `app/api/chat/route.ts`)
- Payment API → Entitlements: checks access
- Catalog Administration → Admin APIs: manages catalog
