How anhvanhoa/ebook works
Main Components
• Frontend UI Layers:
– Public UI: Contains static resources (fonts, images, PDF/EPUB files) available under the public folder.
– Layouts & Shared Components: In the src/app directory (and inside src/components), you see base layouts (e.g., global, header, footer) that wrap pages and enforce consistency.
– Page Groups: Multiple route groups such as:
• (auth) – Handles login and sign‑up for user authentication.
• (client) – Displays category and book details, reviews, and general client browsing.
• (read) – Provides specialized reading interfaces including different subcomponents (EpubViewer, PDF view, HTML view, etc.).
• Core Utility Libraries:
– lib folder: Contains helper functions (for EPUB processing, font management, and other utilities).
– hooks folder: Custom hooks like useTriggerPdf likely assist with dynamic content loading or state management related to PDF processing.
• Context & Providers:
– provider/pdf: Provides PDF-related context using React Context API for state sharing and functionality among components that handle PDF interactions.
• Configurations & Tooling:
– Various configuration files (e.g., eslint.config.mjs, next.config.ts, postcss.config.mjs, tsconfig.json) that define code linting, build parameters, and styling.
Relationships and Interactions
• Navigation Flow:
– The (client) components allow users to browse book categories and individual books. Upon selection, navigation occurs to the (read) section which loads a detailed reading interface.
– The (auth) section is accessed for signing up or logging in; successful auth likely unlocks further functionalities or personalizations on the client and read routes.
• Component Reusability:
– Shared elements such as headers, footers, and theme providers (e.g., ThemeProvider, ModeToggle) are used across the application, linking various pages.
• Data Flow:
– Utility functions (from lib) support content processing in reader components.
• Routing & Layout:
Architectural Patterns & Design Principles
• Next‑JS File Based Routing & Nested Layouts:
– Emphasize the modular structure provided by Next.js where route-based directories govern the layout and behavior of each section.
• Separation of Concerns:
– Authentication, content browsing, and reading functionalities are separated into different route folders.
– UI components are kept in their own directories (e.g., src/components and src/app/(client)/_components).
• Component Reusability:
– The presence of shared components (like header, button, card, and various display components) shows a reusable UI library design.
Relevant Technologies & Frameworks
• Next.js for React‑based server‑side rendering and routing.
• React Context API (as seen in the pdf provider) to manage state across the app.
• ESLint for code quality (configured via eslint.config.mjs).
• Tailwind or PostCSS (as implied by postcss.config.mjs) for styling.
• Utility libraries and hooks for managing UI state and content processing.
Instructing the Principal Software Engineer – What
– Label high-level route groups: “Authentication”, “Client Content”, “Reading Interface”.
– Label shared components (e.g., Header, Footer, ThemeProvider) and utility modules (e.g., lib, hooks).
– Show navigation flow (e.g., from the Client Content to the Reading Interface).
– For example:
○ Rectangles for layout containers.
○ Circles for reusable UI components.
• Be as Detailed as Possible:
– Start by drawing a big picture: pages grouped by function (Auth, Client, Read).
– Drill down to show internal components in each group (e.g., within the “Reading Interface”—list each subcomponent from the _components folder).
– Include external dependencies (Next.js, React Context API, build tools) to provide context on how the application is structured and deployed.