How nduongg04/se100.p12-cafe works
Main Components
• Client/Presentation Layer:
• Next.js Frontend with separate route segments like “admin”, “employee”, “login”, “feedback”, etc.
• Shared UI components (under components/ui) and domain-specific components (under components/admin and components/employee).
• Global styles and assets (app/globals.css, public/assets).
• Server/Business Logic Layer:
• API Routes: The app/api directory (e.g. export-analytics) which handles API requests.
• Lib modules: Directories such as /lib/actions and /lib/apis represent business rules and API calling logic.
• Authentication & Utility functions (lib/auth.ts, middleware.ts, etc.)
• Configuration & Deployment:
• Next.js configuration (next.config.mjs, tailwind.config.ts, tsconfig.json)
• Build and deployment settings (GitHub workflows, Vercel deployment instructions in the README)
Out Interactions and Data Flow
• From the browser, users first interact with the Next.js pages (e.g., login, admin/dashboard, employee views).
• The Next.js server uses middleware (e.g., middleware.ts) to manage authentication and routing.
• When a user requests data (for example, on an admin page), the frontend components make calls via the client layer. This can involve:
• API calls to server routes in app/api, which then utilize business logic in the lib directory.
• Directly invoking utility functions to fetch or manipulate data.
• The components then render the results using either server-side or client-side rendering.
Architectural Patterns
• Separation of Concerns: Each major feature (admin vs. employee) has its dedicated folder with clear boundaries for page components, data fetching logic, and reusable UI components.
• Modular Design: Use of lib/actions and lib/apis to encapsulate business logic and API interactions ensures that the front-end remains decoupled from data manipulation code.
• Component Reusability: Distinct directories for shared UI components (components/ui) support a reusable and extensible design.