How tusgino/gp-webapp works
Project Type and Purpose
• This is a full-stack web front-end built with Next.js (App Router), React, Redux (with Redux-Saga), and Tailwind CSS.
• It consumes a set of RESTful back-end microservices (Auth, Course, Discussion, etc.) via Axios and Redux actions.
• It provides user flows for authentication, browsing courses, lesson playback, quizzes, payments, profiles, dashboards, and internationalization.
File-Structure Analysis
• Top-level “app/” directory holds Next.js pages, layouts, and route segments using the App Router.
• “components/” organized by feature (auth, course, dashboard, profile, shared UI primitives, etc.).
• “lib/” contains API wrappers and Redux modules:
– lib/*/api.ts → HTTP calls to each microservice
– lib/*/action.ts → action creators
– lib/redux/* → slice + saga + selectors per domain
• “public/” holds static assets and locale JSON files for next-i18next.
• “styles/” and Tailwind config for global styling.
• Config files: next.config.mjs, next-i18next.config.js, tsconfig.json, ESLint/Prettier, etc.
Key Components
a. Browser (Client)
– Next.js App Router → Server-side and Client-side components
– React / Redux store with Saga middleware
– UI component library (components/ui, shared, theme-provider)
– i18n loader fetching locale files (public/locales)
b. CDN / Static Assets
– Served from “public/assets” and built CSS/JS bundles
c. Next.js Server (Node.js)
– SSR/SSG pipelines
– App ‑> route handlers → initial props / API calls
d. External Services (Microservices)
– Auth Service
– Course Service
– Lesson Service
– Discussion Service
– Enrollment Service
– Payment Service (e.g., Stripe)
– Profile Service
– Progress & Review Services
e. Data Stores (implicit on back-end)
– User DB, Course DB, Payment DB, etc.
Interactions and Data Flow
1. Browser requests a page → Next.js server renders (SSR/SSG) or serves a client bundle.
2. Client-side navigation dispatches Redux actions → Sagas intercept → call lib/*/api.ts via Axios → HTTP request to microservices.
3. Responses update Redux store → React components re-render.
4. UI pulls translations from public/locales via next-i18next.
5. Payment flows redirect to external gateway → return to “/payment-return” route.
Architectural Patterns and Design Principles
– Feature-based component organization
– Separation of concerns: Router, UI, state management, API layer
– Redux-Saga for side-effects orchestration
– Next.js App Router for hybrid SSR/CSR
– i18n via next-i18next and locale JSONs
– Strict typing with TypeScript interfaces in “interface/”
– Theming and CSS utility via Tailwind
Essential Elements
– Notes on SSR vs CSR responsibilities