# loopfruits/fizz-demo architecture

> Architecture diagram of the GitHub repository loopfruits/fizz-demo, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-05). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/loopfruits/fizz-demo
- Repository: https://github.com/loopfruits/fizz-demo

## Overview

##### Main System Components

a) Client Layer
- Next.js Frontend (React Components)
- Three.js 3D Rendering System
- Client-side State Management

b) API Layer
- Next.js API Routes
- Prismic Integration
- Preview/Revalidation Systems

c) CMS Layer
- Prismic Content Management System
- Slice Machine
- Custom Types

##### Component Organization

Create distinct sections showing:

a) Page Components
- Layout Structure (/src/app/layout.tsx)
- Dynamic Routes (/src/app/[uid])
- Static Pages

b) Slice Components (Group these visually)
- AlternatingText
- BigText
- Carousel
- Hero
- SkyDive

c) 3D Components (Highlight these specially)
- SodaCan
- Bubbles
- FloatingCan
- ViewCanvas

##### Data Flow Representation

- Content flow from Prismic CMS to Next.js
- API routes handling (preview, revalidate)
- Client-side state management (useStore)
- 3D model loading and rendering pipeline

##### Specific Implementation Details

Create dedicated sections for:

a) Three.js Integration
- Model loading pipeline (/public/*.gltf, *.bin)
- Scene management
- 3D component hierarchy

b) Prismic Integration
- Custom types
- Slice Machine configuration
- Preview system

##### Important Connections to Highlight

- How the preview system connects components
- Relationship between Slice Machine and component generation
- Demonstrate how 3D models integrate with regular React components
- State management flow using useStore

##### Technical Stack Indicators

- Next.js 13+ (App Router)
- Prismic CMS
- Three.js
- TypeScript
- Tailwind CSS

Special Considerations:
##### Build/deploy pipeline

This system design should provide a clear understanding of how the application's various components interact while maintaining a focus on the unique aspects of this project, particularly the integration of 3D elements with a headless CMS.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        Frontend["Next.js Frontend"]:::frontend
        click Frontend "https://github.com/LoopFruits/fizz-demo/blob/main/src/app/layout.tsx"
        Layout["Layout Component"]:::frontend
        click Layout "https://github.com/LoopFruits/fizz-demo/blob/main/src/app/layout.tsx"
        Pages["Dynamic Pages"]:::frontend
        click Pages "https://github.com/LoopFruits/fizz-demo/blob/main/src/app/[uid]/page.tsx"
        
        subgraph ThreeJS["Three.js Layer"]
            ViewCanvas["ViewCanvas"]:::threejs
            click ViewCanvas "https://github.com/LoopFruits/fizz-demo/blob/main/src/app/components/ViewCanvas.tsx"
            SodaCan["SodaCan Model"]:::threejs
            click SodaCan "https://github.com/LoopFruits/fizz-demo/blob/main/src/app/components/SodaCan.tsx"
            Bubbles["Bubbles Effect"]:::threejs
            click Bubbles "https://github.com/LoopFruits/fizz-demo/blob/main/src/app/components/Bubbles.tsx"
            FloatingCan["Floating Can"]:::threejs
            click FloatingCan "https://github.com/LoopFruits/fizz-demo/blob/main/src/app/components/FloatingCan.tsx"
            Models["3D Models"]:::threejs
            click Models "https://github.com/LoopFruits/fizz-demo/blob/main/public/Soda-can.gltf"
        end

        subgraph StateManagement["State Management"]
            Store["useStore"]:::state
            click Store "https://github.com/LoopFruits/fizz-demo/blob/main/src/hooks/useStore.ts"
            MediaQuery["useMediaQuery"]:::state
            click MediaQuery "https://github.com/LoopFruits/fizz-demo/blob/main/src/hooks/useMediaQuery.ts"
        end

        subgraph UIComponents["UI Components"]
            Header["Header"]:::ui
            click Header "https://github.com/LoopFruits/fizz-demo/blob/main/src/app/components/Header.tsx"
            Footer["Footer"]:::ui
            click Footer "https://github.com/LoopFruits/fizz-demo/blob/main/src/app/components/Footer.tsx"
            Button["Button"]:::ui
            click Button "https://github.com/LoopFruits/fizz-demo/blob/main/src/app/components/Button.tsx"
            Bounded["Bounded"]:::ui
            click Bounded "https://github.com/LoopFruits/fizz-demo/blob/main/src/app/components/Bounded.tsx"
        end

        subgraph Slices["Slice Components"]
            AlternatingText["AlternatingText"]:::slice
            click AlternatingText "https://github.com/LoopFruits/fizz-demo/blob/main/src/slices/AlternatingText/index.tsx"
            BigText["BigText"]:::slice
            click BigText "https://github.com/LoopFruits/fizz-demo/blob/main/src/slices/BigText/index.tsx"
            Carousel["Carousel"]:::slice
            click Carousel "https://github.com/LoopFruits/fizz-demo/blob/main/src/slices/Carousel/index.tsx"
            Hero["Hero"]:::slice
            click Hero "https://github.com/LoopFruits/fizz-demo/blob/main/src/slices/Hero/index.tsx"
            SkyDive["SkyDive"]:::slice
            click SkyDive "https://github.com/LoopFruits/fizz-demo/blob/main/src/slices/SkyDive/index.tsx"
        end
    end

    subgraph API["API Layer"]
        Preview["Preview API"]:::api
        click Preview "https://github.com/LoopFruits/fizz-demo/blob/main/src/app/api/preview/route.ts"
        ExitPreview["Exit Preview API"]:::api
        click ExitPreview "https://github.com/LoopFruits/fizz-demo/blob/main/src/app/api/exit-preview/route.ts"
        Revalidate["Revalidate API"]:::api
        click Revalidate "https://github.com/LoopFruits/fizz-demo/blob/main/src/app/api/revalidate/route.ts"
    end

    subgraph CMS["CMS Layer"]
        Prismic["Prismic CMS"]:::cms
        click Prismic "https://github.com/LoopFruits/fizz-demo/blob/main/src/prismicio.ts"
        SliceMachine["Slice Machine"]:::cms
        click SliceMachine "https://github.com/LoopFruits/fizz-demo/blob/main/slicemachine.config.json"
        CustomTypes["Custom Types"]:::cms
        click CustomTypes "https://github.com/LoopFruits/fizz-demo/blob/main/customtypes/page/index.json"
        SliceSimulator["Slice Simulator"]:::cms
        click SliceSimulator "https://github.com/LoopFruits/fizz-demo/blob/main/src/app/slice-simulator/page.tsx"
    end

    %% Connections
    Frontend --> Layout
    Layout --> Pages
    Layout --> UIComponents
    Pages --> Slices
    Slices --> ThreeJS
    Frontend --> StateManagement
    Frontend --> API
    API --> Prismic
    Prismic --> SliceMachine
    Prismic --> CustomTypes
    SliceMachine --> SliceSimulator
    ThreeJS --> Models

    %% Styles
    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef threejs fill:#9b59b6,stroke:#8e44ad,color:white
    classDef state fill:#2ecc71,stroke:#27ae60,color:white
    classDef api fill:#e67e22,stroke:#d35400,color:white
    classDef cms fill:#1abc9c,stroke:#16a085,color:white
    classDef ui fill:#95a5a6,stroke:#7f8c8d,color:white
    classDef slice fill:#e74c3c,stroke:#c0392b,color:white
```
