# narayan-bhattarai/kavyaswar architecture

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

- Interactive diagram: https://gitdiagram.com/narayan-bhattarai/kavyaswar
- Repository: https://github.com/narayan-bhattarai/kavyaswar

## Overview

KavyaSwar is a browser-based audio-book creator and reader: users upload a PDF, record narration page by page, save the book and its media, then open it for synchronized reading and playback. The app also provides a library and ZIP package import/export utilities. The graph follows the sampled routing, page, and persistence calls; PWA support and some reader details are documented but their implementations were not sampled.

Main entry points: [`src/lib/db.ts`](https://github.com/narayan-bhattarai/kavyaswar/blob/main/src/lib/db.ts) (Data access), [`src/pages/CreateKavya.tsx`](https://github.com/narayan-bhattarai/kavyaswar/blob/main/src/pages/CreateKavya.tsx) (PDF creator), [`src/App.tsx`](https://github.com/narayan-bhattarai/kavyaswar/blob/main/src/App.tsx) (Route selection), [`src/components/Layout.tsx`](https://github.com/narayan-bhattarai/kavyaswar/blob/main/src/components/Layout.tsx) (App layout)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Application shell"]
  node_entry["React entry<br/>[main.tsx]"]
  node_routes["Route selection<br/>[App.tsx]"]
  node_layout["App layout<br/>[Layout.tsx]"]
end

subgraph group_authoring["Book creation"]
  node_creator["PDF creator<br/>[CreateKavya.tsx]"]
  node_recorder["Audio recorder<br/>[AudioRecorder.tsx]"]
end

subgraph group_reading["Library and reading"]
  node_home["Library home<br/>[Home.tsx]"]
  node_readerpage["Book reader<br/>[ReadKavya.tsx]"]
end

subgraph group_persistence["Persistence and exchange"]
  node_bookmodel["Book data model<br/>[types.ts]"]
  node_dataaccess["Data access<br/>[db.ts]"]
  node_localdb[("IndexedDB adapter<br/>[db.local.ts]")]
  node_packages["ZIP exchange<br/>[zipUtils.ts]"]
end

node_reader(("App user"))
node_microphone["Browser microphone"]
node_supabase[("Supabase service")]

node_reader -->|"opens app"| node_entry
node_entry -->|"renders"| node_routes
node_routes -->|"wraps routes"| node_layout
node_routes -->|"routes home"| node_home
node_routes -->|"routes create"| node_creator
node_routes -->|"routes book"| node_readerpage
node_layout -->|"hosts page"| node_home
node_layout -->|"hosts page"| node_creator
node_layout -->|"hosts page"| node_readerpage
node_home -->|"loads library"| node_dataaccess
node_home -->|"navigates create"| node_creator
node_home -->|"opens book"| node_readerpage
node_layout -->|"loads and deletes"| node_dataaccess
node_creator -->|"renders recorder"| node_recorder
node_recorder -->|"requests audio"| node_microphone
node_creator -->|"saves book and media"| node_dataaccess
node_readerpage -->|"loads book and blobs"| node_dataaccess
node_dataaccess -->|"reads and writes"| node_supabase
node_creator -->|"uses book types"| node_bookmodel
node_readerpage -->|"uses book types"| node_bookmodel
node_dataaccess -->|"maps book data"| node_bookmodel
node_packages -->|"imports and exports blobs"| node_dataaccess
node_packages -->|"serializes metadata"| node_bookmodel
node_localdb -->|"stores typed records"| node_bookmodel

click node_entry "https://github.com/narayan-bhattarai/kavyaswar/blob/main/src/main.tsx"
click node_routes "https://github.com/narayan-bhattarai/kavyaswar/blob/main/src/App.tsx"
click node_layout "https://github.com/narayan-bhattarai/kavyaswar/blob/main/src/components/Layout.tsx"
click node_home "https://github.com/narayan-bhattarai/kavyaswar/blob/main/src/pages/Home.tsx"
click node_creator "https://github.com/narayan-bhattarai/kavyaswar/blob/main/src/pages/CreateKavya.tsx"
click node_recorder "https://github.com/narayan-bhattarai/kavyaswar/blob/main/src/components/AudioRecorder.tsx"
click node_readerpage "https://github.com/narayan-bhattarai/kavyaswar/blob/main/src/pages/ReadKavya.tsx"
click node_bookmodel "https://github.com/narayan-bhattarai/kavyaswar/blob/main/src/lib/types.ts"
click node_dataaccess "https://github.com/narayan-bhattarai/kavyaswar/blob/main/src/lib/db.ts"
click node_localdb "https://github.com/narayan-bhattarai/kavyaswar/blob/main/src/lib/db.local.ts"
click node_packages "https://github.com/narayan-bhattarai/kavyaswar/blob/main/src/utils/zipUtils.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_entry,node_routes,node_layout,node_reader,node_microphone toneBlue
class node_creator,node_recorder,node_supabase toneAmber
class node_home,node_readerpage toneMint
class node_bookmodel,node_dataaccess,node_localdb,node_packages toneRose
```

## Components

### Application shell

- [React entry](https://github.com/narayan-bhattarai/kavyaswar/blob/main/src/main.tsx): `src/main.tsx`
- [Route selection](https://github.com/narayan-bhattarai/kavyaswar/blob/main/src/App.tsx): `src/App.tsx`
- [App layout](https://github.com/narayan-bhattarai/kavyaswar/blob/main/src/components/Layout.tsx): `src/components/Layout.tsx`

### Book creation

- [PDF creator](https://github.com/narayan-bhattarai/kavyaswar/blob/main/src/pages/CreateKavya.tsx): `src/pages/CreateKavya.tsx`
- [Audio recorder](https://github.com/narayan-bhattarai/kavyaswar/blob/main/src/components/AudioRecorder.tsx): `src/components/AudioRecorder.tsx`

### Library and reading

- [Library home](https://github.com/narayan-bhattarai/kavyaswar/blob/main/src/pages/Home.tsx): `src/pages/Home.tsx`
- [Book reader](https://github.com/narayan-bhattarai/kavyaswar/blob/main/src/pages/ReadKavya.tsx): `src/pages/ReadKavya.tsx`

### Persistence and exchange

- [Book data model](https://github.com/narayan-bhattarai/kavyaswar/blob/main/src/lib/types.ts): `src/lib/types.ts`
- [Data access](https://github.com/narayan-bhattarai/kavyaswar/blob/main/src/lib/db.ts): `src/lib/db.ts`
- [IndexedDB adapter](https://github.com/narayan-bhattarai/kavyaswar/blob/main/src/lib/db.local.ts): `src/lib/db.local.ts`
- [ZIP exchange](https://github.com/narayan-bhattarai/kavyaswar/blob/main/src/utils/zipUtils.ts): `src/utils/zipUtils.ts`

### Other components

- **App user**
- **Browser microphone**
- **Supabase service**

## Connections

- App user → React entry: opens app (evidence: `README.md`)
- React entry → Route selection: renders (evidence: `src/main.tsx`)
- Route selection → App layout: wraps routes (evidence: `src/App.tsx`)
- Route selection → Library home: routes home (evidence: `src/App.tsx`)
- Route selection → PDF creator: routes create (evidence: `src/App.tsx`)
- Route selection → Book reader: routes book (evidence: `src/App.tsx`)
- App layout → Library home: hosts page (evidence: `src/App.tsx`)
- App layout → PDF creator: hosts page (evidence: `src/App.tsx`)
- App layout → Book reader: hosts page (evidence: `src/App.tsx`)
- Library home → Data access: loads library (evidence: `src/pages/Home.tsx`)
- Library home → PDF creator: navigates create (evidence: `src/pages/Home.tsx`)
- Library home → Book reader: opens book (evidence: `src/pages/Home.tsx`)
- App layout → Data access: loads and deletes (evidence: `src/components/Layout.tsx`)
- PDF creator → Audio recorder: renders recorder (evidence: `src/pages/CreateKavya.tsx`)
- Audio recorder → Browser microphone: requests audio (evidence: `src/components/AudioRecorder.tsx`)
- PDF creator → Data access: saves book and media (evidence: `src/pages/CreateKavya.tsx`)
- Book reader → Data access: loads book and blobs (evidence: `src/pages/ReadKavya.tsx`)
- Data access → Supabase service: reads and writes (evidence: `src/lib/db.ts`)
- PDF creator → Book data model: uses book types (evidence: `src/pages/CreateKavya.tsx`)
- Book reader → Book data model: uses book types (evidence: `src/pages/ReadKavya.tsx`)
- Data access → Book data model: maps book data (evidence: `src/lib/db.ts`)
- ZIP exchange → Data access: imports and exports blobs (evidence: `src/utils/zipUtils.ts`)
- ZIP exchange → Book data model: serializes metadata (evidence: `src/utils/zipUtils.ts`)
- IndexedDB adapter → Book data model: stores typed records (evidence: `src/lib/db.local.ts`)
