# jarryuser/calendar-app architecture

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

- Interactive diagram: https://gitdiagram.com/jarryuser/calendar-app
- Repository: https://github.com/jarryuser/calendar-app

## Overview

1. **Core architecture boundary**
   - This is an **offline-first personal calendar** with two runtime surfaces: a **Vite/React web app** and a **Tauri v2 desktop app** wrapping the same frontend.
   - The primary runtime is fully client-side: the app reads and writes local data in the browser/WebView and does not depend on a central backend for normal use.

2. **Top-level UI composition**
   - `src/App.tsx` and the layout components split the screen into a **header**, **sidebar**, **main calendar view**, and mobile-specific **bottom navigation / drawer**.
   - The main calendar area swaps between five view controllers: **Month, Week, Day, Agenda, Year**. These views are the main presentation boundary for the domain data.

3. **State management layer**
   - The app uses **Zustand stores** as the central state boundary:
     - `uiStore` for selected date, active view, dialogs/modals, theme, etc.
     - `calendarStore` for calendar metadata and visibility.
     - `eventStore` for events, ranges, import/export, and event mutations.
     - `taskStore` for todos/tasks.
   - UI components subscribe to these stores; stores in turn orchestrate database reads/writes and derived data.

4. **Persistence layer**
   - Persistent storage is **Dexie over IndexedDB** in `src/db/index.ts`.
   - The database is the source of truth for calendars, events, tasks, and recurring-event exception state.
   - The README emphasizes there is **no account system and no cross-device sync**; local IndexedDB is the only durable storage for user data.

5. **Event data flow**
   - User actions in modals, drag-and-drop, keyboard shortcuts, or natural-language input flow into the **event store**.
   - The store persists canonical records to IndexedDB, then the view layer reads back the relevant date range and renders only what is visible.
   - Drag/resize interactions in week/day/month views update event times through this same store boundary.

6. **Recurring event model**
   - Recurrence is not expanded into stored copies. Instead, a recurring event is stored once as a master record with an RRULE-compatible field.
   - On read, `utils/recurrence.ts` expands instances for the currently visible date range in memory.
   - Single-instance edits create **exceptions** or tombstones, which keeps the database compact and makes “edit all / this / this and following” a first-class domain concept.

7. **Import/export and natural-language entry**
   - `utils/ical.ts` handles **ICS import/export** using `ical.js`, so external calendar files are normalized into the local event model and can also be exported back out.
   - `utils/nlp.ts` uses **chrono-node** to turn free-text input like “tomorrow at 3pm” into a prefilled event draft.
   - These are ingestion/egress boundaries into the same local event store; they do not bypass the app’s core persistence model.

8. **Date, timezone, and display logic**
   - `utils/dates.ts`, `utils/timezone.ts`, and `useDateLocale.ts` provide the calendar math, timezone formatting, and locale-aware rendering needed by all views.
   - This layer is important because the app stores and displays times in a user-selected IANA timezone rather than treating dates as plain strings.

9. **Notifications and background behavior**
   - `useNotifications.ts` plus `public/sw.js` implement browser notifications and background support for reminders.
   - This is a lightweight background boundary: the app can alert while open or when the tab is backgrounded, but it is not a server-side scheduler.

10. **Mobile and interaction helpers**
   - `useIsMobile.ts`, `useSwipe.ts`, and the mobile layout components adapt the same calendar model to touch-first navigation.
   - Keyboard shortcuts are centralized in `useKeyboardShortcuts.ts`, which drives view navigation and creation flows without coupling that logic to individual views.

11. **Theming, localization, and UI primitives**
   - Theme selection is managed via `useTheme.ts` and CSS/Tailwind tokenization.
   - Internationalization lives under `src/i18n/` with multiple locale bundles, and the app also localizes date formatting.
   - Reusable UI primitives under `src/components/ui/` provide the modal/popover/dropdown/toast boundary used across the event, task, and layout features.

12. **Desktop packaging and native bridge**
   - `src-tauri/` contains the Rust-side Tauri app shell, while `src/tauri.ts` is the frontend bridge.
   - The desktop build uses the system WebView and preserves the same IndexedDB-backed data model, so the web and desktop apps share essentially the same application architecture.

13. **Repository-level delivery and auxiliary backend files**
   - GitHub Actions in `.github/workflows/release.yml` produce packaged releases for multiple platforms.
   - The repo also contains `functions/api`, `api/schema.sql`, and `wrangler.jsonc`, which look like Cloudflare/serverless scaffolding; however, the README describes the shipped product as **fully client-side/offline-first**, so those files should be treated as auxiliary boundaries rather than the main product data path.

14. **How to draw the main diagram**
   - A clear diagram would show: **user interactions → React views/components → Zustand stores → Dexie/IndexedDB**, with side paths to **recurrence expansion**, **ICS/NLP utilities**, and **notifications/service worker**.
   - A parallel outer boundary should show the same frontend running either in a **browser** or inside **Tauri desktop**, both sharing the same local storage and domain logic.

Main entry points: [`src/store/eventStore.ts`](https://github.com/jarryuser/calendar-app/blob/main/src/store/eventStore.ts) (Event store), [`src/components/layout/AppLayout.tsx`](https://github.com/jarryuser/calendar-app/blob/main/src/components/layout/AppLayout.tsx) (Layout), [`src/db/index.ts`](https://github.com/jarryuser/calendar-app/blob/main/src/db/index.ts) (Local DB), [`src/components/views/MonthView.tsx`](https://github.com/jarryuser/calendar-app/blob/main/src/components/views/MonthView.tsx) (Calendar views)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Frontend app"]
  node_app["App shell<br/>react entry<br/>[App.tsx]"]
  node_layout["Layout<br/>shell ui<br/>[AppLayout.tsx]"]
  node_views["Calendar views<br/>view controllers<br/>[MonthView.tsx]"]
  node_eventui["Event UI<br/>event forms<br/>[EventModal.tsx]"]
  node_sidebar["Sidebar<br/>navigation panel<br/>[Sidebar.tsx]"]
  node_taskui["Task UI<br/>task forms<br/>[TaskModal.tsx]"]
end

subgraph group_state["State & data"]
  node_ui["UI store<br/>zustand store<br/>[uiStore.ts]"]
  node_calendarstore["Calendar store<br/>zustand store<br/>[calendarStore.ts]"]
  node_eventstore["Event store<br/>zustand store<br/>[eventStore.ts]"]
  node_taskstore["Task store<br/>zustand store<br/>[taskStore.ts]"]
  node_db[("Local DB<br/>dexie/IndexedDB<br/>[index.ts]")]
end

subgraph group_logic["Domain logic"]
  node_recurrence{{"Recurrence<br/>rrule expand<br/>[recurrence.ts]"}}
  node_dates{{"Date logic<br/>calendar math<br/>[dates.ts]"}}
  node_timezone{{"Timezone<br/>formatting<br/>[timezone.ts]"}}
  node_ical{{"ICS bridge<br/>import/export<br/>[ical.ts]"}}
  node_nlp{{"Natural language<br/>draft parser<br/>[nlp.ts]"}}
end

subgraph group_platform["Platform shells"]
  node_notifications(("Notifications<br/>reminders"))
  node_tauri["Tauri bridge<br/>desktop bridge<br/>[tauri.ts]"]
  node_desktop["Desktop shell<br/>tauri app<br/>[main.rs]"]
  node_sync["Sync layer<br/>auxiliary backend<br/>[engine.ts]"]
  node_serviceworker(("Service worker<br/>web worker<br/>[sw.js]"))
end

node_app -->|"composes"| node_layout
node_layout -->|"contains"| node_sidebar
node_layout -->|"hosts"| node_views
node_layout -->|"opens"| node_eventui
node_layout -->|"opens"| node_taskui
node_views -->|"reads state"| node_ui
node_sidebar -->|"reads state"| node_calendarstore
node_sidebar -->|"reads state"| node_taskstore
node_eventui -->|"mutates"| node_eventstore
node_taskui -->|"mutates"| node_taskstore
node_ui -.->|"persists"| node_db
node_calendarstore -->|"persists"| node_db
node_eventstore -->|"persists"| node_db
node_taskstore -->|"persists"| node_db
node_eventstore -->|"expands"| node_recurrence
node_views -->|"uses"| node_dates
node_views -->|"uses"| node_timezone
node_eventstore -->|"imports/exports"| node_ical
node_eventstore -->|"drafts"| node_nlp
node_notifications -->|"relies on"| node_serviceworker
node_tauri -->|"bridges"| node_desktop
node_sync -.->|"reads/writes"| node_db
node_sync -.->|"integrates"| node_eventstore

click node_app "https://github.com/jarryuser/calendar-app/blob/main/src/App.tsx"
click node_layout "https://github.com/jarryuser/calendar-app/blob/main/src/components/layout/AppLayout.tsx"
click node_views "https://github.com/jarryuser/calendar-app/blob/main/src/components/views/MonthView.tsx"
click node_eventui "https://github.com/jarryuser/calendar-app/blob/main/src/components/event/EventModal.tsx"
click node_sidebar "https://github.com/jarryuser/calendar-app/blob/main/src/components/sidebar/Sidebar.tsx"
click node_taskui "https://github.com/jarryuser/calendar-app/blob/main/src/components/task/TaskModal.tsx"
click node_ui "https://github.com/jarryuser/calendar-app/blob/main/src/store/uiStore.ts"
click node_calendarstore "https://github.com/jarryuser/calendar-app/blob/main/src/store/calendarStore.ts"
click node_eventstore "https://github.com/jarryuser/calendar-app/blob/main/src/store/eventStore.ts"
click node_taskstore "https://github.com/jarryuser/calendar-app/blob/main/src/store/taskStore.ts"
click node_db "https://github.com/jarryuser/calendar-app/blob/main/src/db/index.ts"
click node_recurrence "https://github.com/jarryuser/calendar-app/blob/main/src/utils/recurrence.ts"
click node_dates "https://github.com/jarryuser/calendar-app/blob/main/src/utils/dates.ts"
click node_timezone "https://github.com/jarryuser/calendar-app/blob/main/src/utils/timezone.ts"
click node_ical "https://github.com/jarryuser/calendar-app/blob/main/src/utils/ical.ts"
click node_nlp "https://github.com/jarryuser/calendar-app/blob/main/src/utils/nlp.ts"
click node_notifications "https://github.com/jarryuser/calendar-app/blob/main/src/hooks/useNotifications.ts"
click node_tauri "https://github.com/jarryuser/calendar-app/blob/main/src/tauri.ts"
click node_desktop "https://github.com/jarryuser/calendar-app/blob/main/src-tauri/src/main.rs"
click node_sync "https://github.com/jarryuser/calendar-app/blob/main/src/sync/engine.ts"
click node_serviceworker "https://github.com/jarryuser/calendar-app/blob/main/public/sw.js"

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_app,node_layout,node_views,node_eventui,node_sidebar,node_taskui toneBlue
class node_ui,node_calendarstore,node_eventstore,node_taskstore,node_db toneAmber
class node_recurrence,node_dates,node_timezone,node_ical,node_nlp toneMint
class node_notifications,node_tauri,node_desktop,node_sync,node_serviceworker toneRose
```

## Components

### Frontend app

React/Vite UI surfaces and user interaction flow

- [App shell](https://github.com/jarryuser/calendar-app/blob/main/src/App.tsx): react entry · Root composition and route-less app bootstrap · `src/App.tsx`
- [Layout](https://github.com/jarryuser/calendar-app/blob/main/src/components/layout/AppLayout.tsx): shell ui · Header, sidebar, mobile nav, and viewport framing · `src/components/layout/AppLayout.tsx`
- [Calendar views](https://github.com/jarryuser/calendar-app/blob/main/src/components/views/MonthView.tsx): view controllers · Month, week, day, agenda, and year presentation layer · `src/components/views/MonthView.tsx`
- [Event UI](https://github.com/jarryuser/calendar-app/blob/main/src/components/event/EventModal.tsx): event forms · Modal, popover, recurrence, and color editing interactions · `src/components/event/EventModal.tsx`
- [Sidebar](https://github.com/jarryuser/calendar-app/blob/main/src/components/sidebar/Sidebar.tsx): navigation panel · Calendar list, mini calendar, and task list · `src/components/sidebar/Sidebar.tsx`
- [Task UI](https://github.com/jarryuser/calendar-app/blob/main/src/components/task/TaskModal.tsx): task forms · Task editing and lightweight task entry surfaces · `src/components/task/TaskModal.tsx`

### State & data

Zustand stores and local persistence

- [UI store](https://github.com/jarryuser/calendar-app/blob/main/src/store/uiStore.ts): zustand store · Selected date, active view, dialogs, theme, and UI state · `src/store/uiStore.ts`
- [Calendar store](https://github.com/jarryuser/calendar-app/blob/main/src/store/calendarStore.ts): zustand store · Calendar metadata and visibility state · `src/store/calendarStore.ts`
- [Event store](https://github.com/jarryuser/calendar-app/blob/main/src/store/eventStore.ts): zustand store · Events, range queries, mutations, import/export, and drafts · `src/store/eventStore.ts`
- [Task store](https://github.com/jarryuser/calendar-app/blob/main/src/store/taskStore.ts): zustand store · Task and todo state management · `src/store/taskStore.ts`
- [Local DB](https://github.com/jarryuser/calendar-app/blob/main/src/db/index.ts): dexie/IndexedDB · Persistent local source of truth for calendars, events, tasks, and exceptions · `src/db/index.ts`

### Domain logic

Calendar math, recurrence, import/export, localization

- [Recurrence](https://github.com/jarryuser/calendar-app/blob/main/src/utils/recurrence.ts): rrule expand · In-memory expansion and exception handling for recurring events · `src/utils/recurrence.ts`
- [Date logic](https://github.com/jarryuser/calendar-app/blob/main/src/utils/dates.ts): calendar math · Date arithmetic, visible ranges, and locale-aware calendar calculations · `src/utils/dates.ts`
- [Timezone](https://github.com/jarryuser/calendar-app/blob/main/src/utils/timezone.ts): formatting · IANA timezone handling and display formatting · `src/utils/timezone.ts`
- [ICS bridge](https://github.com/jarryuser/calendar-app/blob/main/src/utils/ical.ts): import/export · ICS normalization and export via ical.js · `src/utils/ical.ts`
- [Natural language](https://github.com/jarryuser/calendar-app/blob/main/src/utils/nlp.ts): draft parser · Free-text time parsing into event drafts · `src/utils/nlp.ts`

### Platform shells

Desktop bridge, notifications, and auxiliary sync/backend scaffolding

- [Notifications](https://github.com/jarryuser/calendar-app/blob/main/src/hooks/useNotifications.ts): reminders · Browser notification and background reminder behavior · `src/hooks/useNotifications.ts`
- [Tauri bridge](https://github.com/jarryuser/calendar-app/blob/main/src/tauri.ts): desktop bridge · Frontend adapter for the desktop shell · `src/tauri.ts`
- [Desktop shell](https://github.com/jarryuser/calendar-app/blob/main/src-tauri/src/main.rs): tauri app · Rust-side Tauri host and packaged desktop runtime · `src-tauri/src/main.rs`
- [Sync layer](https://github.com/jarryuser/calendar-app/blob/main/src/sync/engine.ts): auxiliary backend · Optional client sync engine and Cloudflare-style API scaffolding · `src/sync/engine.ts`
- [Service worker](https://github.com/jarryuser/calendar-app/blob/main/public/sw.js): web worker · Offline/background support for notifications and app shell behavior · `public/sw.js`

## Connections

- App shell → Layout: composes · Root app assembles the main shell
- Layout → Sidebar: contains · Shell includes navigation and side panels
- Layout → Calendar views: hosts · Main content swaps among calendar views
- Layout → Event UI: opens · Layout-driven dialogs and popovers
- Layout → Task UI: opens · Task editing surfaces
- Calendar views → UI store: reads state · Views react to selected date and active view
- Sidebar → Calendar store: reads state · Calendar list visibility and metadata
- Sidebar → Task store: reads state · Sidebar task list state
- Event UI → Event store: mutates · Event creation and editing flows
- Task UI → Task store: mutates · Task creation and editing flows
- UI store → Local DB: persists · Stores UI-adjacent durable preferences when needed
- Calendar store → Local DB: persists · Calendar metadata stored locally
- Event store → Local DB: persists · Canonical event records and exceptions
- Task store → Local DB: persists · Task records stored locally
- Event store → Recurrence: expands · Visible recurring instances are expanded in memory
- Calendar views → Date logic: uses · All calendar views depend on date range math
- Calendar views → Timezone: uses · Times are rendered in the selected timezone
- Event store → ICS bridge: imports/exports · External ICS files map to local event model
- Event store → Natural language: drafts · Natural-language input creates event drafts
- Notifications → Service worker: relies on · Background notification support
- Tauri bridge → Desktop shell: bridges · Frontend talks to the desktop host
- Sync layer → Local DB: reads/writes · Optional auxiliary sync path around local data
- Sync layer → Event store: integrates · Sync logic shares event model and mutations
