How sakatai11/todoapp-next works
Project type and purpose
• This is a full-stack Next.js application (“TodoApp-Next”) for task management.
• It provides user authentication (NextAuth.js + Firebase Auth), CRUD operations on tasks stored in Firestore, drag-and-drop ordering, modals, real-time updates, and responsive UI.
File structure
• Top-level “app/” folder uses Next.js App Router: page routes, layout, API endpoints under “app/api/”.
• “features/” directory follows a feature-based modular pattern: each feature (todo, sign, top, shared components) encapsulates components, templates, hooks, contexts, and utilities.
• “app/libs/” and “features/libs/” expose shared client/server utilities (API clients, Firebase Admin helpers, markdown processing).
• “app/utils/” and “features/utils/” contain pure functions and validation logic.
• “types/” houses TypeScript interfaces.
• Configuration and deployment files include next.config.ts, middleware.ts, vercel.json.
README for additional insights
• Confirms Next.js + React + Tailwind + MUI on front end.
• Backend logic lives in Next.js API routes calling Firebase (Auth & Firestore).
• Data fetching uses SWR; drag-and-drop uses @dnd-kit/core; validation via Zod.
• Deployed on Vercel.
Main components and interactions (to show
a. Frontend (Browser/Client)
• Next.js React components under “app/” and “features/”.
• React Context (TodoContext) for in-page state.
• SWR hook layer for data fetching and caching.
• Drag-and-drop UI (@dnd-kit/core), modals, MUI UI elements, Tailwind styling.
b. Next.js Server (Vercel Edge / Node)
• App Router handles SSR/SSG for UI pages: / (landing), /auth/(signin, signup), /dashboard/todo.
• API Routes under app/api/… implement server handlers:
– /auth/[...nextauth] → NextAuth.js
– /auth/refresh, server-login → custom token flows
– /todos, /lists, /user, /info → CRUD against Firestore via Firebase Admin SDK
c. External Services
• Firebase Authentication (sign in/up, token issuance)
• Firestore (tasks, lists, user profiles)
• NextAuth.js for session management
d. Data flows
• Browser → Next.js pages → SWR → Next.js API → Firebase → Next.js → Browser updates.
• Browser → NextAuth.js endpoints → Firebase Auth → JWT/Session cookie → Browser.
Architectural patterns and design principles
• Feature-based modularity: each feature isolates its UI, logic, and hooks.
• App Router with nested layouts: shared headers, loading states, grouping of auth vs. dashboard routes.
• API-route-as-backend: Next.js functions act as microservices connecting to Firebase.
• React Context for ephemeral UI state; SWR for remote state caching.
• Separation of concerns: libs for data layer, utils for pure helpers.