How jarryuser/calendar-app works
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: eventStore.ts Event store · AppLayout.tsx Layout · index.ts Local DB · MonthView.tsx Calendar views
Components 21
Frontend app
React/Vite UI surfaces and user interaction flow
- App shell · Root composition and route-less app bootstrap
src/App.tsx - Layout · Header, sidebar, mobile nav, and viewport framing
src/components/layout/AppLayout.tsx - Calendar views · Month, week, day, agenda, and year presentation layer
src/components/views/MonthView.tsx - Event UI · Modal, popover, recurrence, and color editing interactions
src/components/event/EventModal.tsx - Sidebar · Calendar list, mini calendar, and task list
src/components/sidebar/Sidebar.tsx - Task UI · Task editing and lightweight task entry surfaces
src/components/task/TaskModal.tsx
State & data
Zustand stores and local persistence
- UI store · Selected date, active view, dialogs, theme, and UI state
src/store/uiStore.ts - Calendar store · Calendar metadata and visibility state
src/store/calendarStore.ts - Event store · Events, range queries, mutations, import/export, and drafts
src/store/eventStore.ts - Task store · Task and todo state management
src/store/taskStore.ts - Local DB · Persistent local source of truth for calendars, events, tasks, and exceptions
src/db/index.ts
Domain logic
Calendar math, recurrence, import/export, localization
- Recurrence · In-memory expansion and exception handling for recurring events
src/utils/recurrence.ts - Date logic · Date arithmetic, visible ranges, and locale-aware calendar calculations
src/utils/dates.ts - Timezone · IANA timezone handling and display formatting
src/utils/timezone.ts - ICS bridge · ICS normalization and export via ical.js
src/utils/ical.ts - Natural language · Free-text time parsing into event drafts
src/utils/nlp.ts
Platform shells
Desktop bridge, notifications, and auxiliary sync/backend scaffolding
- Notifications · Browser notification and background reminder behavior
src/hooks/useNotifications.ts - Tauri bridge · Frontend adapter for the desktop shell
src/tauri.ts - Desktop shell · Rust-side Tauri host and packaged desktop runtime
src-tauri/src/main.rs - Sync layer · Optional client sync engine and Cloudflare-style API scaffolding
src/sync/engine.ts - Service worker · Offline/background support for notifications and app shell behavior
public/sw.js
Connections 23
- 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