How nguyenhung-hub/blog-ui works
Main Components
• Next.js Framework: At the core, the Next.js framework manages routing (via the file system), server-side rendering, and static site generation. Mark the Next.js engine as the central framework layer.
• Sections by Application Area:
• Admin Section: Located under src/app/(admin) with features such as dashboard, write functionality, and specialized components (_components folder). This group is used for administrative actions like managing posts, profiles, and resources.
• Authentication: Under src/app/(auth) housing the login (dang-nhap) and logout pages for handling user sessions.
• Main/Public Section: Under src/app/(main) which handles the public routes (for posts, resources, etc.) and includes its own set of common UI components.
• State Management & Services:
• Store: Located in src/store (with reducers, providers, and services) for managing global state, including specific slices like user, editor, and search functionality.
• Service Layer: Files in src/service provide API or business logic interactions for posts, categories, resources, and user data.
• Utility Modules: Including configuration (src/config), custom hooks (src/hook), utility functions (src/util), and a set of interfaces and types (src/interfaces and src/types) that help maintain type safety and shared contracts.
Out Relationships and Interactions
• Routing & Page Components: The Next.js file-based routing (as seen under src/app with distinct grouping for admin, auth, and main) drives the user navigation. Each page component (e.g., page.tsx files) should be shown as endpoints that render views.
• UI Components Interactions: Indicate that pages use reusable components (like headers, footers, sidebars, and cards) from folders such as src/components and the subfolders within src/app (e.g., dashboard/_components).
• Utility Integration: Show that common functions (src/util), configuration information (src/config), and custom hooks (src/hook) are supporting the logic and behavior of both components and services.
Architectural Patterns and Design Principles
• Modular & Layered Structure: Emphasize division into UI (pages and components), Service (API/data handling), and State layers.
• File-System Based Routing: Display how Next.js leverages folder structure for route definitions.
• Separation of Concerns: Different folders responsibly encapsulate admin, auth, and main functionalities.
• Reusability: Many components (in src/components and subcomponents under the app folders) are designed for reuse across different parts of the application.
• Type Safety and Custom Hooks: The use of TypeScript interfaces (src/interfaces and src/types) and custom hooks (src/hook) suggests an architecture that values maintainability and consistency.
Putting It All Together
• Branch out three main sections: Admin, Auth, and Main interfaces.
• Under each section, include sub-components:
• For Admin: Dashboard pages, write routes, and components like SideBarDashboard and Card components.
• For Auth: Login and logout pages.
• For Main: Dynamic routes for posts and resources, along with shared UI components (e.g., Header, Footer, Nav components).
• Sections to the global state management layer and indicate their interactions with the service layer.
• External dependencies such as Next.js libraries (e.g., next/font) and any third-party integrations shown in the configuration (Tailwind, ESLint, Prettier, etc.).