# ixtk/product-feedback architecture

> Architecture diagram of the GitHub repository ixtk/product-feedback, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ixtk/product-feedback
- Repository: https://github.com/ixtk/product-feedback

## Overview

##### Project Type and Purpose
- This is a Next.js + TypeScript front-end application (“Product Feedback App”) that implements CRUD operations on product feedback items using a local JSON data source. It uses React for rendering, Next.js for routing/SSR/SSG, TailwindCSS for styling, and React Context for global state.

##### Main Components
a. User’s Browser (Client)
b. Next.js Server (Node.js runtime for SSR/SSG)
c. Data Source
- Local JSON file (src/shared/data.ts)
- Cloudinary (external service for user avatar images)
d. React Application Layer
- Pages layer (src/pages/*)
- Global Context (src/context/FeedbackList.ts)
- Component modules (src/components/* subfolders: common, input, feedback, comment)
e. Build & Tooling Layer (optional, for completeness)
- TailwindCSS (tailwind.config.js, postcss.config.js)
- ESLint / Prettier / Husky

##### Relationships & Data Flows
- Next.js Server → Data Source: reads JSON at build time (SSG/SSR)
- Next.js Server → Cloudinary: presigned HTTP fetch of avatar images
- Next.js Server → Browser: delivers HTML + bundled JS/CSS
- Browser (hydrated React) → Context: initializes global state from JSON props
- Components → Context: read/update feedback list, comments, votes
- Components → Browser: render UI, handle user actions (upvote, add comment)
- Components → Context → JSON data (in-memory only) for client-side mutations

##### Architectural Patterns & Principles
- Component-based UI (atomic/feature folders under src/components)
- Next.js hybrid SSG/SSR for initial data bundling and routing
- Global State via React Context for decoupled state management
- Separation of concerns:
- Presentation (components)
- Business logic & form validation (React-hook-form + utils/validators.ts)
- Styling (TailwindCSS)

- React Context Store
- UI Component modules (common, feedback, comment)

## Diagram (Mermaid)

```mermaid
flowchart TD
    classDef client fill:#d0e7ff,stroke:#004ea2,color:#004ea2
    classDef server fill:#d6f5d6,stroke:#228B22,color:#228B22
    classDef external fill:#ffe5b4,stroke:#ff8c00,color:#ff8c00
    classDef config fill:#f0f0f0,stroke:#666666,color:#666666

    subgraph "Client Browser" 
        Browser["User's Browser"]:::client
        subgraph "React App (CSR)" 
            Context["FeedbackList Context"]:::client
            subgraph "UI Components"
                Common["Common Components"]:::client
                Input["Input Components"]:::client
                Feedback["Feedback Components"]:::client
                Comment["Comment Components"]:::client
                Layout["Layout & Navigation"]:::client
                Headers["Page Headers & Banners"]:::client
            end
        end
    end

    subgraph "Application/Runtime Layer"
        NextServer["Next.js Server\n(SSG at build, SSR on demand)"]:::server
        Pages["Pages Layer"]:::server
    end

    subgraph "Data Layer"
        JSON["Local JSON Data"]:::server
        Cloudinary["Cloudinary Avatar Service"]:::external
    end

    subgraph "Tooling & Config"
        Tailwind["Tailwind CSS Config"]:::config
        PostCSS["PostCSS Config"]:::config
        ESLint["ESLint Config"]:::config
        Prettier["Prettier Config"]:::config
        Husky["Husky Hooks"]:::config
        TSConfig["TypeScript Config"]:::config
        NextConfig["Next.js Config"]:::config
        Package["package.json / package-lock.json"]:::config
    end

    Browser -->|"HTTP request"| NextServer
    NextServer -->|"reads data.json at build"| JSON
    NextServer -->|"fetch avatars"| Cloudinary
    NextServer -->|"HTML + JS Bundle"| Browser

    Browser -->|"hydrate"| Context
    Context -->|"provides state to"| Common
    Context -->|"provides state to"| Input
    Context -->|"provides state to"| Feedback
    Context -->|"provides state to"| Comment
    Context -->|"provides state to"| Layout
    Context -->|"provides state to"| Headers

    Pages -->|"fetch initial props"| Context
    NextServer --> Pages

    class Browser,Context,Common,Input,Feedback,Comment,Layout,Headers client
    class NextServer,Pages,JSON server
    class Cloudinary external
    class Tailwind,PostCSS,ESLint,Prettier,Husky,TSConfig,NextConfig,Package config

    %% Click Events
    click JSON "https://github.com/ixtk/product-feedback/blob/main/src/shared/data.ts"
    click Pages "https://github.com/ixtk/product-feedback/tree/main/src/pages"
    click Common "https://github.com/ixtk/product-feedback/tree/main/src/components/common"
    click Input "https://github.com/ixtk/product-feedback/tree/main/src/components/input"
    click Feedback "https://github.com/ixtk/product-feedback/tree/main/src/components/feedback"
    click Comment "https://github.com/ixtk/product-feedback/tree/main/src/components/comment"
    click Layout "https://github.com/ixtk/product-feedback/blob/main/src/components/Layout.tsx"
    click Headers "https://github.com/ixtk/product-feedback/blob/main/src/components/Banner.tsx"
    click Tailwind "https://github.com/ixtk/product-feedback/blob/main/tailwind.config.js"
    click PostCSS "https://github.com/ixtk/product-feedback/blob/main/postcss.config.js"
    click ESLint "https://github.com/ixtk/product-feedback/blob/main/.eslintrc.json"
    click Prettier "https://github.com/ixtk/product-feedback/blob/main/.prettierrc.json"
    click Husky "https://github.com/ixtk/product-feedback/blob/main/.husky"
    click TSConfig "https://github.com/ixtk/product-feedback/blob/main/tsconfig.json"
    click NextConfig "https://github.com/ixtk/product-feedback/blob/main/next.config.js"
    click Package "https://github.com/ixtk/product-feedback/blob/main/package.json"
```
