How amtsh/routine works
Project type and purpose
• This is a React-based, Next.js “app-directory” web application for managing habits.
• It’s primarily front-end (no API routes directory), using Next.js for routing, SSR/SSG, and client hydration.
• The app offers pages to add, edit, reorder, clear cache, and get suggestions for habits.
File structure
• app/ – Next.js “App Router” pages and layouts (server components by default, with client components when needed).
• Subfolders: clearcache, edit/[id], home, new, reorder, suggestions – each with a page.tsx and helper components.
• components/ – Shared React UI components (PillMenu, SelectEmoji, theme-provider).
• components/ui/ – Primitive UI elements (button, input, dialog, dropdown, etc.), likely based on shadcn/ui.
• lib/ – Application logic & types.
• context/SavedHabitsContext.tsx – React context for persisting habits (probably in localStorage).
• utils.ts, types.ts – helpers and type definitions.
• Config & build: next.config.ts, tsconfig.json, tailwind.config.ts, postcss.config.mjs.
Key insights from README
• Bootstrapped with create-next-app; uses next/font and TailwindCSS.
• Deploys seamlessly to Vercel.
• No serverless API routes present, so data stays on client (local storage) or could integrate external services later.
a. Main components
• Browser Client (User’s device)
• Next.js Application Server (or Vercel Edge)
• Static Asset Store / CDN (for public/ folder, optimized fonts)
• React Context / Local Storage (client-side persistence)
• UI Library (components/ui)
b. Relationships & data flows
• Browser → Next.js Server: HTTP GET page requests → SSR/SSG → HTML + JS sent back.
• Next.js Client-side: React hydrates, routes between app/** pages.
• Client Components use SavedHabitsContext to read/write browser localStorage.
c. Architectural patterns & principles
• App Router: Server Components vs. “use client” for interactive parts.
• Context API for global state (habit list).
• Component-driven UI with shared primitives (shadcn ui pattern).
• CSS utility approach (TailwindCSS).
d. Key technologies
• Next.js (App Router, SSR/SSG, next/font)
• React 18 (Server & Client Components)
• TailwindCSS + PostCSS
• shadcn/ui primitives (components/ui)
• TypeScript
Detailed breakdown
• Inside Next.js App Server:
[App Router]
– Layouts (app/layout.tsx)
– Pages (add, edit, reorder, suggestions, clearcache)
– “use client” React components for interactivity
• To the side: “components/ui” & “components” (shared UI primitives)
• Below: Build & Deploy tools (TailwindCSS, next/font, Vercel)