How dt418/nghien-phim works
Main components
• Client/Browser: Represents the end-user using the application.
• Next.js Server Application: This central component handles both page rendering and API endpoints. It incorporates:
• Page Components: In folders like src/app/[...slug], src/app/phim, src/app/danh-sach, etc., these define the routing and UI pages.
• API Routes: Found in src/app/api (e.g., increment, set-search) which serve as backend endpoints for dynamic data.
• Layout and Error Handling: Includes layouts (e.g., layout.tsx), loading states, and not-found pages.
• UI Component Library: A collection of reusable UI parts (e.g., buttons, dialogs, navigation menus) located in src/components/ui and related folders.
• Data and Utility Layer: Logic for API configuration, fetching, error handling, and other utilities found under src/lib (such as src/lib/api and src/lib/utils).
• Configuration & Theming: Includes theme providers (src/providers/theme.tsx) and configuration files (e.g., tailwind.config.ts, next.config.ts) that affect both the appearance and behavior of the app.
• External Services & Deployment Pipelines: Deployment configurations (Dockerfile, docker-compose.yml), CI/CD configurations (in .github/workflows), and testing frameworks (vitest and tests directory) to ensure quality and scalable deployment.
Relationships and interactions
• The Client (browser) communicates with the Next.js Server through HTTP requests.
• When a user navigates, the server dynamically renders pages and may use server-side logic to call API routes for data.
• UI components are assembled within these pages, while API calls from the client often route through the Next.js API endpoints.
• The data fetching and utilities (in src/lib) provide abstraction layers for consuming back-end data and handling business logic.
• Deployment and containerization (Dockerfile, docker-compose.yml, GitHub workflows) support building, testing, and distributing the app.
• Testing components (in tests) validate functionality at both unit and integration levels.
Architectural patterns and design principles
• Utilization of the App Router from Next.js: The project leverages Next.js’ file-based routing to define pages, layouts, and nested routes.
• Separation of Concerns: Distinct folders for API logic, UI components, and business logic promote modularity.
• Configuration and Deployment as Code: Docker and CI configurations highlight a modern, DevOps-oriented approach to deployment.
Relevant technologies and frameworks
• Next.js and React for building the user interface.
• Server-side rendering with dynamic and static generation patterns.
• CSS and Tailwind CSS for styling (as indicated by tailwind.config.ts and related postcss configurations).
• API design using Next.js API routes.
• Testing infrastructure with Vitest and a custom test setup.
• Deployment tools like Docker, GitHub workflows, and scripts (build-image.sh, build-image.ps1).