How yaodebian/human-hormones works
Project Type and Purpose
• This is a full-stack (front-end heavy) Next.js 13 application using the App Router for server-side rendering (SSR), static-site generation (SSG), and client hydration.
• Its primary function is to serve localized educational content about hormones (cortisol, dopamine, etc.) in multiple languages.
Top-Level Architecture Components
a. Client (Browser / Mobile)
b. CDN / Edge Layer (e.g., Vercel)
c. Next.js Application Server
• App Router (app/[locale]/… pages)
• Route Handlers & Layouts
• Server Components (data-fetching, SSR/SSG)
• Client Components (interactive UI bits)
d. Internationalization Module (lib/i18n)
e. React Component Library
• UI primitives (components/ui)
• Common design blocks (components/common)
• Page-specific containers (components/pages, components/home)
f. Static Assets
• Images (public/images/…)
• CSS (tailwind.config.ts, globals.css)
• Fonts (via next/font)
• UI-design prototypes (UI-design/…)
g. Build & Config
• next.config.ts, postcss.config.mjs, tsconfig.json
• ESLint config, package.json, pnpm-lock.yaml
Component Relationships and Data Flow
• The Browser issues HTTP requests → routed through CDN/Edge → forwarded to Next.js Server.
• Next.js App Router matches /{locale}/{page} → loads server layout (app/[locale]/layout.tsx) → resolves translations from lib/i18n using language-store → fetches or generates page props → renders Server Components.
• On the client, React hydrates interactive components (language-switcher, sheet, button) pulled from components/ui.
• Static assets (images, CSS) are served directly by the CDN.
• Tailwind CSS and next/font optimize styles and fonts at build time.
Architectural Patterns and Design Principles
• “Component-based” front-end: clear separation between UI primitives, common patterns, and page containers.
• i18n context/provider pattern: language-store + language-context for dynamic locale injection.
• App Router’s file-based routing for SSR/SSG hybrid pages.
• Static assets and UI-design prototypes decoupled from runtime code.
• Clear labels (e.g., “Next.js App Router,” “lib/i18n translation store”).
• Notes for “Server Components” vs. “Client Components” boundary.