How gtc-x/gtcfx works
Project type and purpose
• This is a full-stack Next.js application that serves a marketing and content site with internationalization, dynamic routing, and serverless API endpoints.
• The README confirms it was bootstrapped with create-next-app, using Next.js’s App Router under app/, dynamic locale routing (app/[locale]/…), and API routes under app/api.
File structure
• Top-level “app” directory:
• app/[locale] — localized page hierarchy (React Server Components and Client Components via .jsx/.js).
• app/api — serverless functions (API routes) for email, OTP, CRM, data insertion.
• app/layout.js, app/globals.css, app/robots.js, app/sitemap.js — global layout, styles, metadata, and sitemap/robots configuration.
• app/lp-static — standalone landing-page variants (static builds with custom layout).
• Supporting directories:
• config/ — nodemailer configuration.
• lib/ — shared logic (API helpers, DB connection, utils).
• helpers/ — localization, index helpers.
• context/ — React Context providers for location/country details.
• public/ — static assets (images, fonts, JSON, PDFs).
• templates/ — email HTML templates.
• Configuration files: next.config.js, tailwind.config.js, Dockerfile, .env, Vercel (vercel.json).
Key architecture insights from README and code
• Uses file-system routing for pages and API routes.
• Employs Server-Side Rendering (SSR), Static Site Generation (SSG), and Incremental Static Regeneration (ISR) where appropriate.
• Multi-locale support via dynamic folder params.
• Serverless function layer for form submissions, OTP flows, email sending, data persistence (through lib/db.js).
• Deployment target: Vercel (serverless, CDN for static files).
Diagramming the system
a. Main components
• Client (Browser)
• CDN / Static Assets
• Next.js Runtime (Serverless Functions)
• API Route Layer (serverless endpoints under app/api)
• Database / Persistence Layer (lib/db.js)
• External Services – SMTP server (via nodemailer), CRM/ERP, third-party APIs
• Localization store (JSON files under messages/)
b. Relationships & data flow
• User requests → DNS → CDN (serves static HTML/CSS/JS for SSG pages)
• If page requires SSR/ISR or dynamic locale routing → request goes to Next.js serverless function → React rendering → response
• Client interactions (forms, OTP, newsletter) → HTTP POST to API routes → serverless function logic → writes to DB or calls external SMTP/CRM → returns status
• Build-time reading of message bundles, static props generation for landing pages
c. Architectural patterns & principles
• File-system routing for page/component organization
• Separation of concerns: React components (UI), Context (state), lib/helpers (business logic), API routes (server logic)
• Hybrid rendering modes: SSG for static marketing pages, SSR/ISR for dynamic content
• Serverless architecture: each API endpoint isolated in its own function
d. Relevant technologies
• Next.js (App Router, SSG, SSR, ISR)
• React (Server & Client Components)
• Tailwind CSS (via tailwind.config.js)
• Node.js Serverless Functions (Vercel)
• nodemailer (config/nodemailer.js)
• Database connector (lib/db.js – e.g., MongoDB/Postgres)
• i18n JSON files under messages/
Detail and coverage
• Essential layers: UI, routing, data, external integrations.
• Build-time vs. run-time flows.
• Multi-locale routing is represented (e.g., app/[locale]).