# jiro-developers/snack architecture

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

- Interactive diagram: https://gitdiagram.com/jiro-developers/snack
- Repository: https://github.com/jiro-developers/snack

## Overview

##### Main Components Identification

a) Frontend Layer:
- Next.js Application (App Router architecture)
- Component Structure
- Client-side State Management
- Styling System

b) Backend Layer:
- Next.js API Routes
- Database Layer (Prisma + Supabase)

c) External Services:
- Image Storage System
- Data Management Scripts

**┌─ Next.js Frontend Layer ─────────────────────┐**
- ┌─ Components ─┐ ┌─ Context ─┐ ┌─ Hooks ──┐ │
- AllItems   │ │ - Toast   │ │ - Counter│ │
- Counter    │ │ - Test    │ │ - Toggle │ │
- Items      │ └──────────┘ └─────────┘ │
- ┘                           │
- ┌─ Styles ────┐ ┌─ Core ────┐            │
- Utils     │ │ - Styles  │            │
- ┘ └──────────┘             │
- ┘

**┌─ Data Management Layer ──────────────────────┐**
- ┌─ Prisma ORM ─┐ ┌─ Supabase ┐             │
- Schema     │ │ - Auth    │             │
- Migrations │ │ - Storage │             │
- ┘ └──────────┘              │
- ┘

**┌─ Scripts & Utils ───────────────────────────┐**
- ┌─ Image Processing ┐ ┌─ Data Processing ┐  │
- Drink Images    │ │ - JSON Creation  │  │
- Snack Images    │ │ - Text to JSON   │  │
- ┘ └─────────────────┘   │
- ┘

##### Additional Elements

- Configuration files (next.config.js, tsconfig.json)
- Type definitions (src/type)
- Public assets structure

##### The static asset handling for drinks and snacks

Keep the abstraction level focused on the main architectural components while showing the relationships between the different parts of the system. This will provide a clear understanding of how the application handles drink and snack management, image processing, and data storage.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Frontend
        AppRouter["App Router"]
        Components["Components"]
        Context["Context System"]
        Hooks["Hooks System"]
        Styles["Styling System"]
        
        subgraph ComponentsDetail["Component Detail"]
            AllItems["All Items"]
            Counter["Counter"]
            Items["Items"]
        end
        
        subgraph ContextDetail["Context Detail"]
            ToastContext["Toast Context"]
        end
        
        subgraph StylesDetail["Styles Detail"]
            GlobalStyles["Global Styles"]
            CoreColors["Core Colors"]
            StyleUtils["Style Utils"]
        end
    end
    
    subgraph DataLayer["Data Management Layer"]
        PrismaORM["Prisma ORM"]
        Supabase["Supabase"]
        
        subgraph Database["Database Components"]
            Schema["Schema"]
            Migrations["Migrations"]
            Auth["Auth"]
            Storage["Storage"]
        end
    end
    
    subgraph Utils["Scripts & Utils"]
        ImageProcessing["Image Processing"]
        DataProcessing["Data Processing"]
        
        subgraph Assets["Asset Management"]
            DrinkImages["Drink Images"]
            SnackImages["Snack Images"]
            DrinkData["Drink Data"]
            SnackData["Snack Data"]
        end
    end
    
    AppRouter --> Components
    AppRouter --> Context
    Components --> ComponentsDetail
    Context --> ContextDetail
    Styles --> StylesDetail
    
    ComponentsDetail --> DataLayer
    ContextDetail --> DataLayer
    
    DataLayer --> Utils
    PrismaORM --> Schema
    PrismaORM --> Migrations
    Supabase --> Auth
    Supabase --> Storage
    
    ImageProcessing --> DrinkImages
    ImageProcessing --> SnackImages
    DataProcessing --> DrinkData
    DataProcessing --> SnackData
    
    classDef frontend fill:#2196F3,stroke:#1565C0,color:white
    classDef data fill:#FFC107,stroke:#FFA000,color:black
    classDef utils fill:#4CAF50,stroke:#388E3C,color:white
    
    class AppRouter,Components,Context,Hooks,Styles,ComponentsDetail,ContextDetail,StylesDetail,AllItems,Counter,Items,ToastContext,GlobalStyles,CoreColors,StyleUtils frontend
    class DataLayer,PrismaORM,Supabase,Schema,Migrations,Auth,Storage data
    class Utils,ImageProcessing,DataProcessing,Assets,DrinkImages,SnackImages,DrinkData,SnackData utils
    
    click AllItems "https://github.com/jiro-developers/snack/blob/main/src/components/AllItems.tsx"
    click Counter "https://github.com/jiro-developers/snack/blob/main/src/components/Counter.tsx"
    click Items "https://github.com/jiro-developers/snack/blob/main/src/components/Items.tsx"
    click Components "https://github.com/jiro-developers/snack/tree/main/src/components/"
    click Context "https://github.com/jiro-developers/snack/tree/main/src/context/"
    click ToastContext "https://github.com/jiro-developers/snack/blob/main/src/context/toastContext.tsx"
    click GlobalStyles "https://github.com/jiro-developers/snack/blob/main/src/styles/GlobalStyles.tsx"
    click CoreColors "https://github.com/jiro-developers/snack/blob/main/core/colors/index.ts"
    click StyleUtils "https://github.com/jiro-developers/snack/blob/main/core/style.util/css.util.ts"
    click Schema "https://github.com/jiro-developers/snack/blob/main/prisma/schema.prisma"
    click Migrations "https://github.com/jiro-developers/snack/tree/main/prisma/migrations/"
    click DrinkImages "https://github.com/jiro-developers/snack/tree/main/public/images/drink"
    click SnackImages "https://github.com/jiro-developers/snack/tree/main/public/images/snack"
    click DrinkData "https://github.com/jiro-developers/snack/blob/main/public/DRINK.json"
    click SnackData "https://github.com/jiro-developers/snack/blob/main/public/SNACK.json"
    click ImageProcessing "https://github.com/jiro-developers/snack/blob/main/scripts/saveDrinkImage.js"
    click DataProcessing "https://github.com/jiro-developers/snack/blob/main/scripts/createTextToJson.js"
```
