# rodrigovasdev/night-market-app architecture

> Architecture diagram of the GitHub repository rodrigovasdev/night-market-app, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-06-15). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/rodrigovasdev/night-market-app
- Repository: https://github.com/rodrigovasdev/night-market-app

## Overview

##### 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.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% User Layer
    Browser["Browser (Mobile/Desktop)"]:::frontend

    %% Edge Layer
    subgraph "Edge Layer"
        CDN["CDN / Vercel Edge Network"]:::edge
    end

    %% Application Layer
    subgraph "Application Layer"
        NextServer["Next.js Serverless Runtime"]:::backend

        subgraph "Next.js App (src/app)"
            Layout["Global Layout"]:::backend
            Home["Home Page (SSR/SSG)"]:::backend
            ProductsList["Products List Page"]:::backend
            ProductDetails["Product Details Page"]:::backend
            CheckoutPage["Checkout Flow Page"]:::backend
            AdminPage["Admin Dashboard Page"]:::backend

            Navbar["Navbar Component"]:::frontend
            Footer["Footer Component"]:::frontend
        end
    end

    %% API Layer
    subgraph "External Services"
        EcomAPI["E-commerce API"]:::service
        Auth["Authentication Service"]:::service
        Payment["Payment Gateway"]:::service
    end

    %% Data Layer
    subgraph "Data Layer"
        DB["Database"]:::datastore
    end

    %% Data Flows
    Browser -->|"HTTPS: request JS/CSS, assets"| CDN
    Browser -->|"HTTPS: page request"| NextServer
    CDN -->|"Cache HTML/JSON"| Browser
    NextServer -->|"SSR/SSG render"| CDN
    NextServer -->|"REST/GraphQL fetch"| EcomAPI
    NextServer -->|"Auth API calls"| Auth
    NextServer -->|"Payment POST"| Payment
    EcomAPI -->|"SQL/NoSQL queries"| DB

    %% Click Events
    click Layout "https://github.com/rodrigovasdev/night-market-app/blob/master/src/app/layout.tsx"
    click Home "https://github.com/rodrigovasdev/night-market-app/blob/master/src/app/page.tsx"
    click AdminPage "https://github.com/rodrigovasdev/night-market-app/blob/master/src/app/admin/page.tsx"
    click CheckoutPage "https://github.com/rodrigovasdev/night-market-app/blob/master/src/app/checkout/page.tsx"
    click ProductsList "https://github.com/rodrigovasdev/night-market-app/blob/master/src/app/products/page.tsx"
    click ProductDetails "https://github.com/rodrigovasdev/night-market-app/blob/master/src/app/products/details/page.tsx"
    click Navbar "https://github.com/rodrigovasdev/night-market-app/blob/master/src/app/components/layout/Navbar.tsx"
    click Footer "https://github.com/rodrigovasdev/night-market-app/blob/master/src/app/components/layout/Footer.tsx"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#0288D1,color:#000;
    classDef edge fill:#E0F7FA,stroke:#00ACC1,color:#000;
    classDef backend fill:#E8F5E9,stroke:#43A047,color:#000;
    classDef service fill:#FFF3E0,stroke:#FB8C00,color:#000;
    classDef datastore fill:#F5F5F5,stroke:#9E9E9E,color:#000;
```
