How inkithai/digibeat works
Purpose and runtime
DigiBeat is a client-only React 18/TypeScript PWA for fullscreen clock displays and time utilities: alarms, countdowns, stopwatch, Pomodoro, and world clocks. Vite provides development and production bundling; browser APIs provide persistence, fullscreen, wake lock, and offline behavior. Entry points are src/main.tsx, which mounts the application, and src/App.tsx, which coordinates routing and application-level UI.
Application shell and navigation
src/App.tsx is the top-level composition boundary for pages, shared settings/state, and navigation. src/components/Navigation.tsx exposes movement between the primary clock and time-tool views. Route-level features are separated into src/pages/Home.tsx, src/pages/Timer.tsx, src/pages/Stopwatch.tsx, src/pages/Pomodoro.tsx, src/pages/Alarm.tsx, and src/pages/WorldClockPage.tsx; this keeps each tool’s state and interactions distinct from the shell.
Shared clock configuration
src/ClockContext.tsx is the central cross-component state boundary for clock preferences such as style, color, format, visible date/seconds, background, accessibility, and display behavior. src/types.ts defines the shared domain contracts used by this state and consumers. Settings controls in src/components/Controls.tsx and src/components/SettingsPanel.tsx update this context; preferences are persisted locally and can be initialized from shareable URL parameters.
Live-time pipeline and renderers
src/hooks/useTime.ts is the live-time source, updating current time for consumers. src/components/Clocks.tsx selects or composes the configured clock presentation, while individual visual renderers isolate style-specific display logic: src/components/FlipClock.tsx, src/components/PixelClock.tsx, src/components/NeonClock.tsx, and src/components/BinaryClock.tsx. src/components/DateDisplay.tsx independently renders date output. This separates timing/state concerns from presentation-specific animation and markup.
Time-tool feature boundaries
Each route provides an independent stateful tool rather than extending the main live-clock renderer. src/pages/Timer.tsx owns countdown and preset behavior; src/pages/Stopwatch.tsx owns elapsed-time and lap tracking; src/pages/Pomodoro.tsx manages focus/break cycles. Alarm functionality is represented by src/pages/Alarm.tsx and reusable clock-facing UI in src/components/AlarmClock.tsx. World-time comparison is encapsulated in src/pages/WorldClockPage.tsx and src/components/WorldClock.tsx.
Display, accessibility, and browser integration
Global visual theming and responsive behavior are centralized in src/styles.css, likely driven by CSS variables set from shared preferences. Fullscreen, keyboard actions, wake-lock behavior, reduced-motion/high-contrast modes, and local storage operate at the browser boundary, primarily coordinated by application/context and control components rather than a backend. There are no server APIs, authentication systems, or external data services evident in the repository.
PWA delivery
public/manifest.json defines installable-app metadata. Offline caching has two relevant artifacts: public/sw.js for the served service worker and src/sw.ts for source-side service-worker logic/build integration. The runtime is static hosting after Vite build, with service worker registration enabling cached operation after an initial online load.
Main entry points: Navigation.tsx Navigation · ClockContext.tsx Clock preferences · App.tsx Application shell · Clocks.tsx Clock composer
Components 20
App shell
- React entry
src/main.tsx - Application shell · Coordinates routes, shared UI, and browser behavior.
src/App.tsx - Navigation
src/components/Navigation.tsx - Clock preferences · Shared display, accessibility, and behavior settings.
src/ClockContext.tsx - Domain contracts
src/types.ts - Settings controls · Updates preferences from controls and settings panel.
src/components/Controls.tsx - Browser APIs · Local storage, URL parameters, fullscreen, wake lock, and accessibility media features.
- Global styles · Responsive styling and preference-driven CSS variables.
src/styles.css
Clock display
- Clock home
src/pages/Home.tsx - Live time source
src/hooks/useTime.ts - Clock composer · Selects the configured clock presentation.
src/components/Clocks.tsx - Clock renderers · Flip, pixel, neon, and binary clock styles.
src/components/FlipClock.tsx - Date display
src/components/DateDisplay.tsx
Time tools
- Countdown timer · Owns countdown and preset state.
src/pages/Timer.tsx - Stopwatch · Owns elapsed-time and lap state.
src/pages/Stopwatch.tsx - Pomodoro · Manages focus and break cycles.
src/pages/Pomodoro.tsx - Alarm
src/pages/Alarm.tsx - World clocks
src/pages/WorldClockPage.tsx
PWA delivery
- PWA manifest & worker · Install metadata and served service worker enable offline caching.
public/manifest.json - Service worker source
src/sw.ts
Connections 21
- React entry → Application shell: mounts
- Application shell → Navigation: renders
- Navigation → Clock home: navigates
- Navigation → Countdown timer: navigates
- Navigation → Stopwatch: navigates
- Navigation → Pomodoro: navigates
- Navigation → Alarm: navigates
- Navigation → World clocks: navigates
- Application shell → Clock preferences: provides
- Clock preferences → Domain contracts: uses
- Settings controls → Clock preferences: updates
- Clock home → Clock composer: renders
- Clock home → Date display: renders
- Clock composer → Live time source: reads time
- Clock composer → Clock preferences: reads preferences
- Clock composer → Clock renderers: selects
- Clock preferences → Browser APIs: persists and initializes
- Application shell → Browser APIs: coordinates display APIs
- Clock preferences → Global styles: drives theme
- Service worker source → PWA manifest & worker: builds/registers worker
- PWA manifest & worker → Browser APIs: offline caching