How vietducc/brainy-kids-frontend works
Main Components
• Frontend UI Layer: This is primarily in the “app” and “components” directories. The “app” folder holds the major pages and layouts (e.g., homepage, courses, learn, leaderboard) while the “components” folder contains reusable UI components (landing sections, headers, buttons, sidebars, etc.).
• Business Logic & Utilities: The “actions”, “lib”, “utils”, and “types” directories house business logic, utility functions, and type definitions.
• Static Assets: The “public” folder includes assets (like audio files) used by the application.
• Configuration & Build: Files such as next.config.ts, tsconfig.json, tailwind.config.ts, and others represent deployment, build configurations, and styling setups.
Relationships and Interactions
• User Interface pages (for example, courses and lessons) are rendered via components and layouts, and they then interact with backend API endpoints to fetch or update data.
• UI Elements such as course cards, lesson screens, and sidebars will trigger calls (using the actions and/or utilities) to the API routes.
• The API routes encapsulate business logic, connecting the UI with the underlying data processing.
• There is a shared logic layer (in “utils”, “lib”, and “actions”) that is used by both the UI and API endpoints.
• The Next.js middleware and global configurations (e.g., next.config.ts) handle request routing and overall application behavior.
Architectural Patterns and Design Principles
• Separation of Concerns: Notice how the project cleanly separates the frontend UI (pages/layouts/components) from the backend business logic (API routes).
• Modular Design: Reusable components are placed in a dedicated “components” directory. The API routes are modularly organized per resource (courses, lessons, progress).
• Next.js App Router Pattern: Leveraging file-based routing with “app/(main)” and “app/api” directories allows for a clear delineation between server-side and client-side code.
• Type Safety: Use of TypeScript with type definitions in the “types” folder ensures data consistency across the application.
Relevant Technologies & Frameworks
• Next.js: For full-stack React development using server components and file-based routing.
• Tailwind CSS: Implied by tailwind.config.ts for styling.
• TypeScript: For type-checking across components, API routes, and utilities.
• ESLint: For code quality, evidenced by .eslintrc.json and eslint.config.mjs.
○ Client Side Rendering: Modules for “UI Components” (components, pages, layouts).
○ API Layer: Blocks representing API routes for courses, lessons, lesson-progress, user-progress.
○ Utilities & Business Logic: Separate module representing “actions”, “lib”, “utils”, and “types”.
○ Configuration Layer: A smaller block for config files (next.config.ts, tailwind.config.ts, etc.).
○ Public Assets: Represented as a resource that the UI can access.
○ The flow from user interactions with the UI to API calls.
○ Data flow from the API to the business logic/utilities.
○ How static assets are integrated into the frontend.
• If needed, include annotations to describe how middleware and global application configurations affect requests.