# mrmirfan/houseofsandwiches architecture

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

- Interactive diagram: https://gitdiagram.com/mrmirfan/houseofsandwiches
- Repository: https://github.com/mrmirfan/houseofsandwiches

## Overview

##### Project Type and Purpose
- This is a full-stack web application (primarily a frontend app using Next.js) that allows users to deploy their own Food Stall site.
- The key functionality is powered by Google Sheets, which is used as the data source (likely hosting your food menu and related data) making it a lightweight CMS.

##### File Structure
- Top-level files such as .env, next.config.mjs, package.json, tailwind.config.ts, and tsconfig.json indicate environment, configuration, and type checking for a Next.js TypeScript project.
- The "app" directory contains core pages and global layout/styles which form the entry point and overall frontend structure.
- The "components" directory (with subfolder "components/ui") holds reusable UI components (accordion, card, table, etc.) that are used to render dynamic content.
- The "data" directory suggests that some static sample data (foodmenu.ts) is used to drive content – representing the food menu possibly loaded either initially or synced with Google Sheets.
- The "lib" folder includes utility functions (utils.ts) to support core business logic such as data fetching, transformation, or integration with external APIs (Google Sheets).

a. Main Components:
- Frontend (Next.js Application):
- Pages and Layout: Located under the "app" folder providing entry points and global styles.
- UI Components: Found in "components/ui", which includes accordion, card, numberinput, etc.
- Data Layer:
- Google Sheets: Acts as the external headless CMS for managing your food stall menu.
- Data Module: "data/foodmenu.ts" (or similar) that might act as a bridge or cache for Google Sheets content.
- Type Definitions:
- Interfaces: Ensure correct data types are consistently used (MenuCard, Receipt, etc.).
- Utility Functions:
- Lib: Common utilities (such as data parsing and API calls to Google Sheets) support the application.
- Supporting Configurations:
- Environment & Build Configs: .env, next.config.mjs, tailwind.config.ts etc., used to control environment-specific behavior and styling.

b. Relationships and Interactions:
- The Next.js frontend interacts directly with the UI components within the "components" directory.
- The pages in the "app" directory render views that utilize UI components and fetch data using utility functions from the "lib" folder.
- These utility functions likely interact with the external data source (Google Sheets) to populate the "data" directory content or fetch real-time data on-demand.
- TypeScript interfaces ensure that the data fetched from Google Sheets or static files conforms to the expected formats.

c. Architectural Patterns and Design Principles:
- Separation of concerns: Clear division between views (pages and components), data sources (Google Sheets) and business logic (utilities and interfaces).
- Component reusability: Organized within a dedicated "components/ui" directory to maximize modularity.
- Type safety: Enforced through TypeScript interfaces.
- External Integration: The system is designed to integrate seamlessly with Google Sheets as the primary data backend.

d. Technologies, Frameworks, or Libraries:
- Next.js (with the new app directory structure) for SSR and frontend routing.
- React for component-based UI design.
- Tailwind CSS for styling (indicated by tailwind.config.ts and postcss.config.js).
- TypeScript for static type checking (tsconfig.json).
- ESLint for code quality.
- Google Sheets integration – either directly or through API calls implemented in the "lib" utilities.

##### Instructing the Principal Software Engineer to Include the Following
- Clearly labeled components:
- "Next.js Frontend", subdivided into "Pages/Layout" (from the app folder) and "Reusable UI Components" (from components/ui).
- "Data Source – Google Sheets" (displaying how the site uses Google Sheets for content management).
- "Data Handling Layer" for utilities (lib) and static sample data (data folder).
- "Type Definitions" (interfaces) ensuring robust data interactions.
- From "Next.js Frontend" to "Data Handling Layer" indicating API calls or data fetch interactions.
- From "Data Handling Layer" to "Google Sheets", demonstrating external data retrieval.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Frontend Layer
    subgraph "Next.js Frontend"
        subgraph "Pages & Layout"
            layout["layout.tsx"]:::frontend
            page["page.tsx"]:::frontend
            globals["globals.css"]:::frontend
        end
        subgraph "Reusable UI Components"
            accordion["accordion.tsx"]:::component
            card["card.tsx"]:::component
            numberinput["numberinput.tsx"]:::component
            table["table.tsx"]:::component
            tabs["tabs.tsx"]:::component
        end
    end

    %% Data Handling Layer
    subgraph "Data Handling Layer"
        static["foodmenu.ts"]:::data
        utils["utils.ts"]:::data
    end

    %% Type Definitions
    subgraph "Type Definitions"
        menuCard["MenuCard.ts"]:::interface
        receipt["Receipt.ts"]:::interface
    end

    %% Configurations
    subgraph "Configurations"
        env[".env"]:::config
        nextconfig["next.config.mjs"]:::config
        tailwind["tailwind.config.ts"]:::config
        tsconfig["tsconfig.json"]:::config
    end

    %% External Data Source
    google["Google Sheets"]:::external

    %% Relationships
    %% Frontend uses UI Components
    layout -->|"renders"| accordion
    page -->|"renders"| card

    %% Frontend fetches data via utility functions
    layout -->|"fetchData"| utils

    %% Utility functions interact with external data and static fallback
    utils -->|"callAPI"| google
    utils -->|"fallback"| static

    %% Type Definitions used by Frontend and Data Handling
    menuCard -->|"useTypes"| layout
    receipt -->|"useTypes"| layout
    menuCard -->|"useTypes"| utils
    receipt -->|"useTypes"| utils

    %% Configurations used by Frontend and Data Handling
    env -->|"config"| layout
    nextconfig -->|"config"| layout
    tailwind -->|"config"| layout
    tsconfig -->|"config"| layout

    env -->|"config"| utils
    nextconfig -->|"config"| utils
    tailwind -->|"config"| utils
    tsconfig -->|"config"| utils

    %% Click Events for Next.js Frontend
    click layout "https://github.com/mrmirfan/houseofsandwiches/blob/main/app/layout.tsx"
    click page "https://github.com/mrmirfan/houseofsandwiches/blob/main/app/page.tsx"
    click globals "https://github.com/mrmirfan/houseofsandwiches/blob/main/app/globals.css"

    %% Click Events for Reusable UI Components
    click accordion "https://github.com/mrmirfan/houseofsandwiches/blob/main/components/ui/accordion.tsx"
    click card "https://github.com/mrmirfan/houseofsandwiches/blob/main/components/ui/card.tsx"
    click numberinput "https://github.com/mrmirfan/houseofsandwiches/blob/main/components/ui/numberinput.tsx"
    click table "https://github.com/mrmirfan/houseofsandwiches/blob/main/components/ui/table.tsx"
    click tabs "https://github.com/mrmirfan/houseofsandwiches/blob/main/components/ui/tabs.tsx"

    %% Click Event for Data Handling Layer
    click static "https://github.com/mrmirfan/houseofsandwiches/blob/main/data/foodmenu.ts"
    click utils "https://github.com/mrmirfan/houseofsandwiches/blob/main/lib/utils.ts"

    %% Click Events for Type Definitions
    click menuCard "https://github.com/mrmirfan/houseofsandwiches/blob/main/interfaces/MenuCard.ts"
    click receipt "https://github.com/mrmirfan/houseofsandwiches/blob/main/interfaces/Receipt.ts"

    %% Click Events for Configurations
    click env "https://github.com/mrmirfan/houseofsandwiches/blob/main/.env"
    click nextconfig "https://github.com/mrmirfan/houseofsandwiches/blob/main/next.config.mjs"
    click tailwind "https://github.com/mrmirfan/houseofsandwiches/blob/main/tailwind.config.ts"
    click tsconfig "https://github.com/mrmirfan/houseofsandwiches/blob/main/tsconfig.json"

%% Styles
classDef frontend fill:#AED6F1,stroke:#1F618D,stroke-width:2px;
classDef component fill:#F9E79F,stroke:#B7950B,stroke-width:2px;
classDef data fill:#A9DFBF,stroke:#229954,stroke-width:2px;
classDef interface fill:#F5B7B1,stroke:#C0392B,stroke-width:2px;
classDef config fill:#D2B4DE,stroke:#8E44AD,stroke-width:2px;
classDef external fill:#FAD7A0,stroke:#D35400,stroke-width:2px;
```
