How nhducit/multi-tenants works
Main Components
• Next.js Application: This is the core framework. Emphasize that the project is structured using Next.js 13’s appDir, which includes both server and client components.
• Routing & Dynamic Pages: The “src/app” directory is organized with dynamic segments ([domain] and [language]) to handle multi-tenancy and multi-language support. Notice the “gift-card” subdirectory under these dynamic routes.
• API Layer: There is an “src/apis” folder which likely contains API utilities used by the Next.js pages.
• Middleware: The “src/middleware.ts” file indicates that there is some middleware logic (for tasks like authentication, routing, or header manipulation) applied globally.
• Static Assets & Styles: The “public” folder for static files and “src/globals.css” for global CSS styling, along with Tailwind styling configurations (tailwind.config.ts) are essential parts.
• Build & Configuration Files: Environment configuration, ESLint rules, Next.js configuration, and TypeScript configuration files indicate a well-configured application environment.
Relationships and Interactions
• Dynamic Routing: Show that requests are routed based on the domain and language segments, leading into specific areas of the app (for example, the “gift-card” pages).
• API Calls: Illustrate connections between pages (or middleware) and the API layer from “src/apis” to denote data fetching or manipulation.
• Middleware: Represent middleware as a layer between the incoming request and the page rendering logic.