How muffinthedragon/daily-habit-tracker works
• Frontend (Next.js Application)
– Pages (e.g., home page at src/app/page.tsx, habits pages at src/app/habits/page.tsx)
– Layout and global styles (src/app/layout.tsx, globals.css, next.config.mjs)
– UI Components (organized under src/components and src/components/ui). This covers all visual elements such as habit cards, dialogs, spinners, alerts, etc.
– Business logic and Hooks (src/hooks and src/lib)
– Testing modules (located in src/__tests__)
• Offline/Data Layer
– Local database setup (src/db.tsx) integrating Dexie cloud for managing offline state and data persistence.
– Service Worker (src/service-worker directory) ensuring offline support and caching.
• API and External Integrations
– API routes for Stripe payments (under src/app/api/stripe and its nested directories). These endpoints handle payment operations and related business logic.
– External Services like Stripe for payment processing.
Relationships and interactions
• The Frontend is responsible for rendering UI pages, invoking API endpoints, and interacting with the offline/data layer.
• API Endpoints (Stripe Payment Routes) are invoked by the Next.js pages or client-side components when processing user transactions.
• The Offline/Data Layer (using Dexie cloud and the service worker) handles data persistence and synchronization.
• Internal utility libraries (src/lib, src/hooks) support data formatting, state management, and responsive UI interactions.
Architectural patterns and design principles
• Minimum separation of concerns: Frontend rendering (UI components, pages) is separated from API logic and data management.
• Offline-first design: The presence of a service worker and Dexie cloud indicates a focus on using a client-side database and caching for offline availability.
• Modular design: Numerous small, reusable components suggest a modular, composable UI architecture.
Relevant technologies, frameworks, and libraries
• Next.js for server-side rendering and routing
• React for building UI components
• Tailwind CSS for styling (tailwind.config.ts)
• Dexie cloud (and likely IndexedDB) for offline support and client-side storage
• Stripe (via API routes) for payment processing
• Testing frameworks (Vitest, as seen in vitest.config.ts and tests in __tests__)