How rodrigovasdev/night-market-app works
Project Type and Purpose
• This is a Next.js full-stack e-commerce front-end application (bootstrapped via create-next-app) with sections for landing pages, product catalogs, checkout, user login/registration, and an admin dashboard.
• The project focuses on server and client React components under the src/app directory. It delivers pages via SSR/SSG and client-side navigation.
File Structure Analysis
• Top-level files:
• next.config.ts, tsconfig.json, postcss.config.mjs, eslint.config.mjs – Next.js build and lint configurations.
• package.json & package-lock.json – Dependencies and scripts.
• src/app:
• layout.tsx, globals.css – Global layout, CSS resets.
• Subfolders by feature:
– admin: Admin dashboard page
– checkout: Checkout flow page
– products: List & detail pages
– components: Reusable UI and section components, organized by function (layout, sections, ui, card)
• There is no built-in pages/api folder, implying that any data comes from external HTTP APIs or server functions defined elsewhere (e.g., middleware or server components using fetch).
Key Insights from README
• Uses Next.js’s App Router and server/client components via src/app.
• Deployed on Vercel with automatic font optimization and SSR/SSG capabilities.
Main Components
a. Frontend (Next.js App)
• Client-side React components (e.g., Navbar, Footer, Carrousel, ProductCard).
• Server-side (SSR/SSG) routes under src/app: home, products list/detail, checkout, login/register, admin.
b. CDN / Static Asset Host
• public/assets served via CDN.
c. External Backend Services
• E-commerce API (product, order, user endpoints).
• Authentication service (NextAuth, OAuth provider, etc.).
• Payment gateway (Stripe, PayPal).
d. Database (if applicable behind the API)
• Products, Users, Orders, Reviews storage.
Relationships & Data Flow
• Browser → CDN: Retrieves JS/CSS bundles, static assets.
• Browser → Next.js Server (SSR/SSG):
• Initial page requests
• Data fetching during server rendering
• Next.js Server → External APIs:
• Fetch product listings, user authentication, order creation
• Next.js Server → CDN: Caches static HTML/JSON for SSG pages.
• Browser (client components) → Next.js Server/API routes:
• Checkout submissions, login/register posts
• Next.js Server/API → Payment Gateway (via secured server-to-server call)
Architectural Patterns & Design Principles
• App Router: Separation of server vs. client components.
• Feature-based module organization: Each section (landing, product, user, admin) has its own folder.
• Reusability: UI primitives under components/ui.
• SSR/SSG: Fast first-load and SEO benefits for product pages.
• CDN + Caching: Public assets and pre-rendered pages.