How shegga9x/phungfrontend works
Main Layers and Components
• Frontend User Interface: Split into two main sections – the public “landing” pages (user authentication, book browsing, cart, profile, etc.) and the “admin” pages (admin dashboard, user and notification management).
• API Routes: Located in the /app/api directory. These endpoints handle key business logic such as book details, purchasing, ratings, cart management, GHN for shipping, order processing, and VNP (likely payment).
• Authentication Module: Clearly integrated via NextAuth.js (as mentioned in the README) along with supporting code under the lib/auth folder.
• Integration with PhungBackend: Although not part of this repo, the frontend’s API integration and authentication allude to a backend service (PhungBackend) providing data and CRUD operations.
• External Deployment Environment: The application is deployed on Vercel; include this as the hosting and delivery layer.
Architectural Patterns & Technologies
• SSR/Static Generation advantage of Next.js.
• Use of file-based routing (especially under /app and /app/api) indicating a separation of concerns.
• A dedicated section or annotation for the authentication flow:
• User credentials pass through NextAuth.js.
• Protected routes/components (e.g., admin pages, permission/role guards in components such as role-guard.tsx and permission-guard.tsx) enforce access control.
• Modularity of the system by listing reusable UI components (from the components and components/v2 directories) and utility modules (e.g., lib/utils, models).